mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-10-24 23:26:53 +00:00
Double quote to prevent globbing and word splitting.
Do not use legacy backticks. Proper use of printf Do not use wc -l with grep, instead use grep -c Use pgrep Signed-off-by: Werner Buck <wernerbuck@gmail.com>
This commit is contained in:
parent
54202b3b41
commit
f4aab9c8c5
9 changed files with 87 additions and 87 deletions
|
|
@ -15,7 +15,7 @@ else
|
|||
set -f; IFS=$'
|
||||
'
|
||||
for c in $containers; do
|
||||
volumes=`docker inspect --format '{{ .Volumes }}' $c`
|
||||
volumes=$(docker inspect --format '{{ .Volumes }}' "$c")
|
||||
|
||||
if [ "$volumes" = "map[]" ]; then
|
||||
# If it's the first container, fail the test
|
||||
|
|
@ -36,8 +36,8 @@ set +f; unset IFS
|
|||
|
||||
# 6.6
|
||||
check_6_6="6.6 - Avoid image sprawl"
|
||||
images=`docker images | wc -l | awk '{print $1}'`
|
||||
if [ $images -gt 100 ]; then
|
||||
images=$(docker images | wc -l | awk '{print $1}')
|
||||
if [ "$images" -gt 100 ]; then
|
||||
warn "$check_6_6"
|
||||
warn " * There are currently: $images images"
|
||||
else
|
||||
|
|
@ -47,10 +47,10 @@ fi
|
|||
|
||||
# 6.7
|
||||
check_6_7="6.7 - Avoid container sprawl"
|
||||
total_containers=`docker info 2>/dev/null | grep "Containers" | awk '{print $2}'`
|
||||
running_containers=`docker ps -q | wc -l | awk '{print $1}'`
|
||||
diff=`expr "$total_containers" - "$running_containers"`
|
||||
if [ $diff -gt 25 ]; then
|
||||
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')
|
||||
running_containers=$(docker ps -q | wc -l | awk '{print $1}')
|
||||
diff="$(($total_containers - $running_containers))"
|
||||
if [ "$diff" -gt 25 ]; then
|
||||
warn "$check_6_7"
|
||||
warn " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue