Skip to content

Commit 244cb2a

Browse files
authored
Merge pull request #200 from konstruktoid/permissions
update permission checks
2 parents 9b71772 + b766037 commit 244cb2a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

tests/3_docker_daemon_configuration_files.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ else
1919
fi
2020

2121
# 3.2
22-
check_3_2="3.2 - Verify that docker.service file permissions are set to 644"
22+
check_3_2="3.2 - Verify that docker.service file permissions are set to 644 or more restrictive"
2323
file="$(get_systemd_service_file docker.service)"
2424
if [ -f "$file" ]; then
25-
if [ "$(stat -c %a $file)" -eq 644 ]; then
25+
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
2626
pass "$check_3_2"
2727
else
2828
warn "$check_3_2"
@@ -49,10 +49,10 @@ else
4949
fi
5050

5151
# 3.4
52-
check_3_4="3.4 - Verify that docker.socket file permissions are set to 644"
52+
check_3_4="3.4 - Verify that docker.socket file permissions are set to 644 or more restrictive"
5353
file="$(get_systemd_service_file docker.socket)"
5454
if [ -f "$file" ]; then
55-
if [ "$(stat -c %a $file)" -eq 644 ]; then
55+
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
5656
pass "$check_3_4"
5757
else
5858
warn "$check_3_4"
@@ -79,7 +79,7 @@ else
7979
fi
8080

8181
# 3.6
82-
check_3_6="3.6 - Verify that /etc/docker directory permissions are set to 755"
82+
check_3_6="3.6 - Verify that /etc/docker directory permissions are set to 755 or more restrictive"
8383
directory="/etc/docker"
8484
if [ -d "$directory" ]; then
8585
if [ "$(stat -c %a $directory)" -eq 755 ]; then
@@ -119,7 +119,7 @@ else
119119
fi
120120

121121
# 3.8
122-
check_3_8="3.8 - Verify that registry certificate file permissions are set to 444"
122+
check_3_8="3.8 - Verify that registry certificate file permissions are set to 444 or more restrictive"
123123
directory="/etc/docker/certs.d/"
124124
if [ -d "$directory" ]; then
125125
fail=0
@@ -156,7 +156,7 @@ else
156156
fi
157157

158158
# 3.10
159-
check_3_10="3.10 - Verify that TLS CA certificate file permissions are set to 444"
159+
check_3_10="3.10 - Verify that TLS CA certificate file permissions are set to 444 or more restrictive"
160160
tlscacert=$(get_docker_effective_command_line_args '--tlscacert' | sed -n 's/.*tlscacert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
161161
if [ -f "$tlscacert" ]; then
162162
perms=$(ls -ld "$tlscacert" | awk '{print $1}')
@@ -187,7 +187,7 @@ else
187187
fi
188188

189189
# 3.12
190-
check_3_12="3.12 - Verify that Docker server certificate file permissions are set to 444"
190+
check_3_12="3.12 - Verify that Docker server certificate file permissions are set to 444 or more restrictive"
191191
tlscert=$(get_docker_effective_command_line_args '--tlscert' | sed -n 's/.*tlscert=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
192192
if [ -f "$tlscert" ]; then
193193
perms=$(ls -ld "$tlscert" | awk '{print $1}')
@@ -218,7 +218,7 @@ else
218218
fi
219219

220220
# 3.14
221-
check_3_14="3.14 - Verify that Docker server key file permissions are set to 400"
221+
check_3_14="3.14 - Verify that Docker server key file permissions are set to 400 or more restrictive"
222222
tlskey=$(get_docker_effective_command_line_args '--tlskey' | sed -n 's/.*tlskey=\([^s]\)/\1/p' | sed 's/--/ --/g' | cut -d " " -f 1)
223223
if [ -f "$tlskey" ]; then
224224
perms=$(ls -ld "$tlskey" | awk '{print $1}')
@@ -249,10 +249,10 @@ else
249249
fi
250250

251251
# 3.16
252-
check_3_16="3.16 - Verify that Docker socket file permissions are set to 660"
252+
check_3_16="3.16 - Verify that Docker socket file permissions are set to 660 or more restrictive"
253253
file="/var/run/docker.sock"
254254
if [ -S "$file" ]; then
255-
if [ "$(stat -c %a $file)" -eq 660 ]; then
255+
if [ "$(stat -c %a $file)" -eq 660 -o "$(stat -c %a $file)" -eq 600 ]; then
256256
pass "$check_3_16"
257257
else
258258
warn "$check_3_16"
@@ -279,10 +279,10 @@ else
279279
fi
280280

281281
# 3.18
282-
check_3_18="3.18 - Verify that daemon.json file permissions are set to 644"
282+
check_3_18="3.18 - Verify that daemon.json file permissions are set to 644 or more restrictive"
283283
file="/etc/docker/daemon.json"
284284
if [ -f "$file" ]; then
285-
if [ "$(stat -c %a $file)" -eq 644 ]; then
285+
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
286286
pass "$check_3_18"
287287
else
288288
warn "$check_3_18"
@@ -309,10 +309,10 @@ else
309309
fi
310310

311311
# 3.20
312-
check_3_20="3.20 - Verify that /etc/default/docker file permissions are set to 644"
312+
check_3_20="3.20 - Verify that /etc/default/docker file permissions are set to 644 or more restrictive"
313313
file="/etc/default/docker"
314314
if [ -f "$file" ]; then
315-
if [ "$(stat -c %a $file)" -eq 644 ]; then
315+
if [ "$(stat -c %a $file)" -eq 644 -o "$(stat -c %a $file)" -eq 600 ]; then
316316
pass "$check_3_20"
317317
else
318318
warn "$check_3_20"

0 commit comments

Comments
 (0)