mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-31 14:22:33 +01:00
update checks
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
This commit is contained in:
parent
88b48315bc
commit
e1e902b3ed
1 changed files with 6 additions and 18 deletions
|
@ -4,19 +4,7 @@ logit "\n"
|
||||||
info "6 - Docker Security Operations"
|
info "6 - Docker Security Operations"
|
||||||
|
|
||||||
# 6.1
|
# 6.1
|
||||||
check_6_1="6.1 - Perform regular security audits of your host system and containers"
|
check_6_1="6.1 - Avoid image sprawl"
|
||||||
info "$check_6_1"
|
|
||||||
|
|
||||||
# 6.2
|
|
||||||
check_6_2="6.2 - Monitor Docker containers usage, performance and metering"
|
|
||||||
info "$check_6_2"
|
|
||||||
|
|
||||||
# 6.3
|
|
||||||
check_6_3="6.3 - Backup container data"
|
|
||||||
info "$check_6_3"
|
|
||||||
|
|
||||||
# 6.4
|
|
||||||
check_6_4="6.4 - Avoid image sprawl"
|
|
||||||
images=$(docker images -q | sort -u | wc -l | awk '{print $1}')
|
images=$(docker images -q | sort -u | wc -l | awk '{print $1}')
|
||||||
active_images=0
|
active_images=0
|
||||||
|
|
||||||
|
@ -26,22 +14,22 @@ for c in $(docker inspect -f "{{.Image}}" $(docker ps -qa)); do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
info "$check_6_4"
|
info "$check_6_1"
|
||||||
info " * There are currently: $images images"
|
info " * There are currently: $images images"
|
||||||
|
|
||||||
if [ "$active_images" -lt "$((images / 2))" ]; then
|
if [ "$active_images" -lt "$((images / 2))" ]; then
|
||||||
info " * Only $active_images out of $images are in use"
|
info " * Only $active_images out of $images are in use"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 6.5
|
# 6.2
|
||||||
check_6_5="6.5 - Avoid container sprawl"
|
check_6_2="6.2 - Avoid container sprawl"
|
||||||
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')
|
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')
|
||||||
running_containers=$(docker ps -q | wc -l | awk '{print $1}')
|
running_containers=$(docker ps -q | wc -l | awk '{print $1}')
|
||||||
diff="$((total_containers - running_containers))"
|
diff="$((total_containers - running_containers))"
|
||||||
if [ "$diff" -gt 25 ]; then
|
if [ "$diff" -gt 25 ]; then
|
||||||
info "$check_6_5"
|
info "$check_6_2"
|
||||||
info " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
|
info " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
|
||||||
else
|
else
|
||||||
info "$check_6_5"
|
info "$check_6_2"
|
||||||
info " * There are currently a total of $total_containers containers, with $running_containers of them currently running"
|
info " * There are currently a total of $total_containers containers, with $running_containers of them currently running"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue