Skip to content

Commit 9b71772

Browse files
authored
Merge pull request #199 from konstruktoid/info_messages
update info messages, not scored
2 parents ceb516f + 7761732 commit 9b71772

File tree

5 files changed

+73
-23
lines changed

5 files changed

+73
-23
lines changed

tests/1_host_configuration.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ else
2222
pass "$check_1_2"
2323
fi
2424

25+
# 1.3
26+
check_1_3="1.3 - Harden the container host"
27+
info "$check_1_3"
28+
2529
# 1.4
2630
check_1_4="1.4 - Remove all non-essential services from the host - Network"
2731
# Check for listening network services.
2832
listening_services=$(netstat -na | grep -v tcp6 | grep -v unix | grep -c LISTEN)
2933
if [ "$listening_services" -eq 0 ]; then
30-
warn "1.4 - Failed to get listening services for check: $check_1_4"
34+
info "1.4 - Failed to get listening services for check: $check_1_4"
3135
else
3236
if [ "$listening_services" -gt 5 ]; then
33-
warn "$check_1_4"
34-
warn " * Host listening on: $listening_services ports"
37+
info "$check_1_4"
38+
info " * Host listening on: $listening_services ports"
3539
else
3640
pass "$check_1_4"
3741
fi
@@ -45,8 +49,8 @@ docker_current_version="1.13.0"
4549
docker_current_date="2017-01-18"
4650
do_version_check "$docker_current_version" "$docker_version"
4751
if [ $? -eq 11 ]; then
48-
warn "$check_1_5"
49-
warn " * Using $docker_version, when $docker_current_version is current as of $docker_current_date"
52+
info "$check_1_5"
53+
info " * Using $docker_version, when $docker_current_version is current as of $docker_current_date"
5054
info " * Your operating system vendor may provide support and security maintenance for docker"
5155
else
5256
pass "$check_1_5"

tests/2_docker_daemon_configuration.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fi
7878

7979

8080
# 2.7
81-
check_2_7="2.7 - Set default ulimit as appropriate"
81+
check_2_7="2.7 - Set default ulimit as appropriate"
8282
get_docker_effective_command_line_args '--default-ulimit' | grep "default-ulimit" >/dev/null 2>&1
8383
if [ $? -eq 0 ]; then
8484
pass "$check_2_7"

tests/4_container_images.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ set +f; unset IFS
4040

4141
images=$(docker images -q)
4242

43+
# 4.2
44+
check_4_2="4.2 - Use trusted base images for containers"
45+
info "$check_4_2"
46+
47+
# 4.3
48+
check_4_3="4.3 - Do not install unnecessary packages in the container"
49+
info "$check_4_3"
50+
51+
# 4.4
52+
check_4_4="4.4 - Scan and rebuild the images to include security patches"
53+
info "$check_4_4"
54+
4355
# 4.5
4456
check_4_5="4.5 - Enable Content trust for Docker"
4557
if [ "x$DOCKER_CONTENT_TRUST" = "x1" ]; then
@@ -88,6 +100,10 @@ if [ $fail -eq 0 ]; then
88100
pass "$check_4_7"
89101
fi
90102

103+
# 4.8
104+
check_4_8="4.8 - Remove setuid and setgid permissions in the images"
105+
info "$check_4_8"
106+
91107
# 4.9
92108
check_4_9="4.9 - Use COPY instead of ADD in Dockerfile"
93109
fail=0
@@ -107,3 +123,11 @@ done
107123
if [ $fail -eq 0 ]; then
108124
pass "$check_4_9"
109125
fi
126+
127+
# 4.10
128+
check_4_10="4.10 - Do not store secrets in Dockerfiles"
129+
info "$check_4_10"
130+
131+
# 4.11
132+
check_4_11="4.11 - Install verified packages only"
133+
info "$check_4_11"

tests/5_container_runtime.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
logit "\n"
4-
info "5 - Container Runtime"
4+
info "5 - Container Runtime"
55

66
# If containers is empty, there are no running containers
77
if [ -z "$containers" ]; then
@@ -207,8 +207,12 @@ else
207207
pass "$check_5_7"
208208
fi
209209

210+
# 5.8
211+
check_5_8="5.8 - Open only needed ports on container"
212+
info "$check_5_8"
213+
210214
# 5.9
211-
check_5_9="5.9 - Do not share the host's network namespace"
215+
check_5_9="5.9 - Do not share the host's network namespace"
212216

213217
fail=0
214218
for c in $containers; do
@@ -519,6 +523,13 @@ else
519523
pass "$check_5_21"
520524
fi
521525

526+
# 5.22
527+
check_5_22="5.22 - Do not docker exec commands with privileged option"
528+
info "$check_5_22"
529+
530+
# 5.23
531+
check_5_23="5.23 - Do not docker exec commands with user option"
532+
info "$check_5_23"
522533

523534
# 5.24
524535
check_5_24="5.24 - Confirm cgroup usage"
@@ -586,6 +597,10 @@ else
586597
pass "$check_5_26"
587598
fi
588599

600+
# 5.27
601+
check_5_27="5.27 - Ensure docker commands always get the latest version of the image"
602+
info "$check_5_27"
603+
589604
# 5.28
590605
check_5_28="5.28 - Use PIDs cgroup limit"
591606

@@ -597,10 +612,10 @@ else
597612
# If it's the first container, fail the test
598613
if [ $fail -eq 0 ]; then
599614
warn "$check_5_28"
600-
warn " * PID limit not set: $c"
615+
warn " * PIDs limit not set: $c"
601616
fail=1
602617
else
603-
warn " * PID limit not set: $c"
618+
warn " * PIDs limit not set: $c"
604619
fi
605620
fi
606621
done
@@ -621,11 +636,11 @@ else
621636
docker0Containers=$(docker network inspect --format='{{ range $k, $v := .Containers }} {{ $k }} {{ end }}' "$net" 2>/dev/null)
622637
if [ -n "$docker0Containers" ]; then
623638
if [ $fail -eq 0 ]; then
624-
warn "$check_5_29"
639+
info "$check_5_29"
625640
fail=1
626641
fi
627642
for c in $docker0Containers; do
628-
warn " * Container in docker0 network: $c"
643+
info " * Container in docker0 network: $c"
629644
done
630645
fi
631646
fi

tests/6_docker_security_operations.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
#!/bin/sh
22

33
logit "\n"
4-
info "6 - Docker Security Operations"
4+
info "6 - Docker Security Operations"
5+
6+
# 6.1
7+
check_6_1="6.1 - Perform regular security audits of your host system and containers"
8+
info "$check_6_1"
9+
10+
# 6.2
11+
check_6_2="6.2 - Monitor Docker containers usage, performance and metering"
12+
info "$check_6_2"
13+
14+
# 6.3
15+
check_6_3="6.3 - Backup container data"
16+
info "$check_6_3"
517

618
# 6.4
7-
check_6_4="6.4 - Avoid image sprawl"
19+
check_6_4="6.4 - Avoid image sprawl"
820
images=$(docker images -q | sort -u | wc -l | awk '{print $1}')
921
active_images=0
1022

@@ -14,26 +26,21 @@ for c in $(docker inspect -f "{{.Image}}" $(docker ps -qa)); do
1426
fi
1527
done
1628

17-
if [ "$images" -gt 100 ]; then
18-
warn "$check_6_4"
19-
warn " * There are currently: $images images"
20-
else
2129
info "$check_6_4"
2230
info " * There are currently: $images images"
23-
fi
2431

2532
if [ "$active_images" -lt "$((images / 2))" ]; then
26-
warn " * Only $active_images out of $images are in use"
33+
info " * Only $active_images out of $images are in use"
2734
fi
2835

2936
# 6.5
30-
check_6_5="6.5 - Avoid container sprawl"
37+
check_6_5="6.5 - Avoid container sprawl"
3138
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')
3239
running_containers=$(docker ps -q | wc -l | awk '{print $1}')
3340
diff="$((total_containers - running_containers))"
3441
if [ "$diff" -gt 25 ]; then
35-
warn "$check_6_5"
36-
warn " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
42+
info "$check_6_5"
43+
info " * There are currently a total of $total_containers containers, with only $running_containers of them currently running"
3744
else
3845
info "$check_6_5"
3946
info " * There are currently a total of $total_containers containers, with $running_containers of them currently running"

0 commit comments

Comments
 (0)