Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug that a container may not have ps command #481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-bench-security.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ readonly myname
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin/"

# Check for required program(s)
req_programs 'awk docker grep stat tee tail wc xargs truncate sed'
req_programs 'awk docker grep stat tee tail wc xargs truncate sed pgrep'

# Ensure we can connect to docker daemon
if ! docker ps -q >/dev/null 2>&1; then
Expand Down
2 changes: 1 addition & 1 deletion tests/5_container_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ check_5_6() {
printcheck=0
for c in $containers; do

processes=$(docker exec "$c" ps -el 2>/dev/null | grep -c sshd | awk '{print $1}')
processes=$(docker inspect "$c" --format '{{ .State.Pid }}' 2>/dev/null | xargs pgrep -a -P 2>/dev/null | grep -c sshd | awk '{print $1}')
if [ "$processes" -ge 1 ]; then
# If it's the first container, fail the test
if [ $fail -eq 0 ]; then
Expand Down