Make the main script an executable for if I want to run it on my host

Fix image sprawl to work

Fix port range

Signed-off-by: Jessica Frazelle <princess@docker.com>
This commit is contained in:
Jessica Frazelle 2015-06-08 19:15:41 -07:00
parent d48d691ec2
commit 0231a7f5de
3 changed files with 16 additions and 13 deletions

0
docker-bench-security.sh Normal file → Executable file
View file

View file

@ -201,18 +201,21 @@ else
fail=0 fail=0
for c in $containers; do for c in $containers; do
port=$(docker port "$c" | awk '{print $1}' | cut -d '/' -f1) ports=$(docker port "$c" | awk '{print $1}' | cut -d '/' -f1)
if [ ! -z "$port" ] && [ "$port" -lt 1025 ]; then # iterate through port range (line delimited)
# If it's the first container, fail the test for port in $ports; do
if [ $fail -eq 0 ]; then if [ ! -z "$port" ] && [ "0$port" -lt 1025 ]; then
warn "$check_5_8" # If it's the first container, fail the test
warn " * Privileged Port in use: $port in $c" if [ $fail -eq 0 ]; then
fail=1 warn "$check_5_8"
else warn " * Privileged Port in use: $port in $c"
warn " * Privileged Port in use: $port in $c" fail=1
else
warn " * Privileged Port in use: $port in $c"
fi
fi fi
fi done
done done
# We went through all the containers and found no privileged ports # We went through all the containers and found no privileged ports
if [ $fail -eq 0 ]; then if [ $fail -eq 0 ]; then

View file

@ -40,8 +40,8 @@ images=$(docker images -q | wc -l | awk '{print $1}')
active_images=0 active_images=0
for c in $(docker inspect -f "{{.Image}}" $(docker ps -qa)); do for c in $(docker inspect -f "{{.Image}}" $(docker ps -qa)); do
if [[ $(docker images --no-trunc -a | grep $c) ]]; then if docker images --no-trunc -a | grep $c > /dev/null ; then
((active_images++)) active_images=$(( active_images += 1 ))
fi fi
done done
@ -53,7 +53,7 @@ else
info " * There are currently: $images images" info " * There are currently: $images images"
fi fi
if [[ "$active_images" -lt "$((images / 2))" ]]; then if [ "$active_images" -lt "$((images / 2))" ]; then
warn " * Only $active_images out of $images are in use" warn " * Only $active_images out of $images are in use"
fi fi