mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-18 16:22:33 +01:00
Merge pull request #493 from konstruktoid/ISSUE492
if configured with no-new-privileges, pass check 5.25
This commit is contained in:
commit
1ff4a62836
1 changed files with 21 additions and 12 deletions
|
@ -970,23 +970,32 @@ check_5_25() {
|
||||||
starttestjson "$id" "$desc"
|
starttestjson "$id" "$desc"
|
||||||
|
|
||||||
fail=0
|
fail=0
|
||||||
|
no_priv_config=0
|
||||||
addprivs_containers=""
|
addprivs_containers=""
|
||||||
for c in $containers; do
|
|
||||||
if ! docker inspect --format 'SecurityOpt={{.HostConfig.SecurityOpt }}' "$c" | grep 'no-new-privileges' 2>/dev/null 1>&2; then
|
if get_docker_effective_command_line_args '--no-new-privileges' | grep "no-new-privileges" >/dev/null 2>&1; then
|
||||||
# If it's the first container, fail the test
|
no_priv_config=1
|
||||||
if [ $fail -eq 0 ]; then
|
elif get_docker_configuration_file_args 'no-new-privileges' | grep true >/dev/null 2>&1; then
|
||||||
warn -s "$check"
|
no_priv_config=1
|
||||||
|
else
|
||||||
|
for c in $containers; do
|
||||||
|
if ! docker inspect --format 'SecurityOpt={{.HostConfig.SecurityOpt }}' "$c" | grep 'no-new-privileges' 2>/dev/null 1>&2; then
|
||||||
|
# If it's the first container, fail the test
|
||||||
|
if [ $fail -eq 0 ]; then
|
||||||
|
warn -s "$check"
|
||||||
|
warn " * Privileges not restricted: $c"
|
||||||
|
addprivs_containers="$addprivs_containers $c"
|
||||||
|
fail=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
warn " * Privileges not restricted: $c"
|
warn " * Privileges not restricted: $c"
|
||||||
addprivs_containers="$addprivs_containers $c"
|
addprivs_containers="$addprivs_containers $c"
|
||||||
fail=1
|
|
||||||
continue
|
|
||||||
fi
|
fi
|
||||||
warn " * Privileges not restricted: $c"
|
done
|
||||||
addprivs_containers="$addprivs_containers $c"
|
fi
|
||||||
fi
|
|
||||||
done
|
|
||||||
# We went through all the containers and found none with capability to acquire additional privileges
|
# We went through all the containers and found none with capability to acquire additional privileges
|
||||||
if [ $fail -eq 0 ]; then
|
if [ $fail -eq 0 ] || [ $no_priv_config -eq 1 ]; then
|
||||||
pass -s "$check"
|
pass -s "$check"
|
||||||
logcheckresult "PASS"
|
logcheckresult "PASS"
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue