mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-19 00:32:34 +01:00
Fix the bug that a container may not have ps command
This commit is contained in:
parent
dfb3a90f67
commit
fd9ad44344
2 changed files with 2 additions and 2 deletions
|
@ -24,7 +24,7 @@ readonly myname
|
||||||
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin/"
|
export PATH="$PATH:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin/"
|
||||||
|
|
||||||
# Check for required program(s)
|
# 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
|
# Ensure we can connect to docker daemon
|
||||||
if ! docker ps -q >/dev/null 2>&1; then
|
if ! docker ps -q >/dev/null 2>&1; then
|
||||||
|
|
|
@ -254,7 +254,7 @@ check_5_6() {
|
||||||
printcheck=0
|
printcheck=0
|
||||||
for c in $containers; do
|
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 [ "$processes" -ge 1 ]; then
|
||||||
# If it's the first container, fail the test
|
# If it's the first container, fail the test
|
||||||
if [ $fail -eq 0 ]; then
|
if [ $fail -eq 0 ]; then
|
||||||
|
|
Loading…
Reference in a new issue