Skip to content

Commit ab6c2cd

Browse files
committed
Update section 1 to 1.13
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
1 parent 372dc08 commit ab6c2cd

File tree

1 file changed

+63
-88
lines changed

1 file changed

+63
-88
lines changed

tests/1_host_configuration.sh

Lines changed: 63 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -13,230 +13,205 @@ else
1313
fi
1414

1515
# 1.2
16-
check_1_2="1.2 - Use an updated Linux Kernel"
17-
kernel_version=$(uname -r | cut -d "-" -f 1)
18-
do_version_check 3.10 "$kernel_version"
19-
if [ $? -eq 11 ]; then
20-
warn "$check_1_2"
21-
else
22-
pass "$check_1_2"
23-
fi
16+
check_1_2="1.2 - Harden the container host"
17+
info "$check_1_2"
2418

2519
# 1.3
26-
check_1_3="1.3 - Harden the container host"
27-
info "$check_1_3"
28-
29-
# 1.4
30-
check_1_4="1.4 - Remove all non-essential services from the host - Network"
31-
# Check for listening network services.
32-
listening_services=$(netstat -na | grep -v tcp6 | grep -v unix | grep -c LISTEN)
33-
if [ "$listening_services" -eq 0 ]; then
34-
info "1.4 - Failed to get listening services for check: $check_1_4"
35-
else
36-
if [ "$listening_services" -gt 5 ]; then
37-
info "$check_1_4"
38-
info " * Host listening on: $listening_services ports"
39-
else
40-
pass "$check_1_4"
41-
fi
42-
fi
43-
44-
# 1.5
45-
check_1_5="1.5 - Keep Docker up to date"
20+
check_1_3="1.3 - Keep Docker up to date"
4621
docker_version=$(docker version | grep -i -A1 '^server' | grep -i 'version:' \
4722
| awk '{print $NF; exit}' | tr -d '[:alpha:]-,')
4823
docker_current_version="1.13.0"
4924
docker_current_date="2017-01-18"
5025
do_version_check "$docker_current_version" "$docker_version"
5126
if [ $? -eq 11 ]; then
52-
info "$check_1_5"
27+
info "$check_1_3"
5328
info " * Using $docker_version, when $docker_current_version is current as of $docker_current_date"
54-
info " * Your operating system vendor may provide support and security maintenance for docker"
29+
info " * Your operating system vendor may provide support and security maintenance for Docker"
5530
else
56-
pass "$check_1_5"
31+
pass "$check_1_3"
5732
info " * Using $docker_version which is current as of $docker_current_date"
58-
info " * Check with your operating system vendor for support and security maintenance for docker"
33+
info " * Check with your operating system vendor for support and security maintenance for Docker"
5934
fi
6035

61-
# 1.6
62-
check_1_6="1.6 - Only allow trusted users to control Docker daemon"
36+
# 1.4
37+
check_1_4="1.4 - Only allow trusted users to control Docker daemon"
6338
docker_users=$(getent group docker)
64-
info "$check_1_6"
39+
info "$check_1_4"
6540
for u in $docker_users; do
6641
info " * $u"
6742
done
6843

69-
# 1.7
70-
check_1_7="1.7 - Audit docker daemon - /usr/bin/docker"
44+
# 1.5
45+
check_1_5="1.5 - Audit docker daemon - /usr/bin/docker"
7146
file="/usr/bin/docker"
7247
command -v auditctl >/dev/null 2>&1
7348
if [ $? -eq 0 ]; then
7449
auditctl -l | grep "$file" >/dev/null 2>&1
7550
if [ $? -eq 0 ]; then
76-
pass "$check_1_7"
51+
pass "$check_1_5"
7752
else
78-
warn "$check_1_7"
53+
warn "$check_1_5"
7954
fi
8055
else
81-
warn "1.7 - Failed to inspect: auditctl command not found."
56+
warn "1.5 - Failed to inspect: auditctl command not found."
8257
fi
8358

84-
# 1.8
85-
check_1_8="1.8 - Audit Docker files and directories - /var/lib/docker"
59+
# 1.6
60+
check_1_6="1.6 - Audit Docker files and directories - /var/lib/docker"
8661
directory="/var/lib/docker"
8762
if [ -d "$directory" ]; then
8863
command -v auditctl >/dev/null 2>&1
8964
if [ $? -eq 0 ]; then
9065
auditctl -l | grep $directory >/dev/null 2>&1
9166
if [ $? -eq 0 ]; then
92-
pass "$check_1_8"
67+
pass "$check_1_6"
9368
else
94-
warn "$check_1_8"
69+
warn "$check_1_6"
9570
fi
9671
else
97-
warn "1.8 - Failed to inspect: auditctl command not found."
72+
warn "1.6 - Failed to inspect: auditctl command not found."
9873
fi
9974
else
100-
info "$check_1_8"
75+
info "$check_1_6"
10176
info " * Directory not found"
10277
fi
10378

104-
# 1.9
105-
check_1_9="1.9 - Audit Docker files and directories - /etc/docker"
79+
# 1.7
80+
check_1_7="1.7 - Audit Docker files and directories - /etc/docker"
10681
directory="/etc/docker"
10782
if [ -d "$directory" ]; then
10883
command -v auditctl >/dev/null 2>&1
10984
if [ $? -eq 0 ]; then
11085
auditctl -l | grep $directory >/dev/null 2>&1
11186
if [ $? -eq 0 ]; then
112-
pass "$check_1_9"
87+
pass "$check_1_7"
11388
else
114-
warn "$check_1_9"
89+
warn "$check_1_7"
11590
fi
11691
else
117-
warn "1.9 - Failed to inspect: auditctl command not found."
92+
warn "1.7 - Failed to inspect: auditctl command not found."
11893
fi
11994
else
120-
info "$check_1_9"
95+
info "$check_1_7"
12196
info " * Directory not found"
12297
fi
12398

124-
# 1.10
125-
check_1_10="1.10 - Audit Docker files and directories - docker.service"
99+
# 1.8
100+
check_1_8="1.8 - Audit Docker files and directories - docker.service"
126101
file="$(get_systemd_service_file docker.service)"
127102
if [ -f "$file" ]; then
128103
command -v auditctl >/dev/null 2>&1
129104
if [ $? -eq 0 ]; then
130105
auditctl -l | grep "$file" >/dev/null 2>&1
131106
if [ $? -eq 0 ]; then
132-
pass "$check_1_10"
107+
pass "$check_1_8"
133108
else
134-
warn "$check_1_10"
109+
warn "$check_1_8"
135110
fi
136111
else
137-
warn "1.10 - Failed to inspect: auditctl command not found."
112+
warn "1.8 - Failed to inspect: auditctl command not found."
138113
fi
139114
else
140-
info "$check_1_10"
115+
info "$check_1_8"
141116
info " * File not found"
142117
fi
143118

144-
# 1.11
145-
check_1_11="1.11 - Audit Docker files and directories - docker.socket"
119+
# 1.9
120+
check_1_9="1.9 - Audit Docker files and directories - docker.socket"
146121
file="$(get_systemd_service_file docker.socket)"
147122
if [ -e "$file" ]; then
148123
command -v auditctl >/dev/null 2>&1
149124
if [ $? -eq 0 ]; then
150125
auditctl -l | grep "$file" >/dev/null 2>&1
151126
if [ $? -eq 0 ]; then
152-
pass "$check_1_11"
127+
pass "$check_1_9"
153128
else
154-
warn "$check_1_11"
129+
warn "$check_1_9"
155130
fi
156131
else
157-
warn "1.11 - Failed to inspect: auditctl command not found."
132+
warn "1.9 - Failed to inspect: auditctl command not found."
158133
fi
159134
else
160-
info "$check_1_11"
135+
info "$check_1_9"
161136
info " * File not found"
162137
fi
163138

164-
# 1.12
165-
check_1_12="1.12 - Audit Docker files and directories - /etc/default/docker"
139+
# 1.10
140+
check_1_10="1.10 - Audit Docker files and directories - /etc/default/docker"
166141
file="/etc/default/docker"
167142
if [ -f "$file" ]; then
168143
command -v auditctl >/dev/null 2>&1
169144
if [ $? -eq 0 ]; then
170145
auditctl -l | grep $file >/dev/null 2>&1
171146
if [ $? -eq 0 ]; then
172-
pass "$check_1_12"
147+
pass "$check_1_10"
173148
else
174-
warn "$check_1_12"
149+
warn "$check_1_10"
175150
fi
176151
else
177-
warn "1.12 - Failed to inspect: auditctl command not found."
152+
warn "1.10 - Failed to inspect: auditctl command not found."
178153
fi
179154
else
180-
info "$check_1_12"
155+
info "$check_1_10"
181156
info " * File not found"
182157
fi
183158

184-
# 1.13
185-
check_1_13="1.13 - Audit Docker files and directories - /etc/docker/daemon.json"
159+
# 1.11
160+
check_1_11="1.11 - Audit Docker files and directories - /etc/docker/daemon.json"
186161
file="/etc/docker/daemon.json"
187162
if [ -f "$file" ]; then
188163
command -v auditctl >/dev/null 2>&1
189164
if [ $? -eq 0 ]; then
190165
auditctl -l | grep $file >/dev/null 2>&1
191166
if [ $? -eq 0 ]; then
192-
pass "$check_1_13"
167+
pass "$check_1_11"
193168
else
194-
warn "$check_1_13"
169+
warn "$check_1_11"
195170
fi
196171
else
197-
warn "1.13 - Failed to inspect: auditctl command not found."
172+
warn "1.11 - Failed to inspect: auditctl command not found."
198173
fi
199174
else
200-
info "$check_1_13"
175+
info "$check_1_11"
201176
info " * File not found"
202177
fi
203178

204-
# 1.14
205-
check_1_14="1.14 - Audit Docker files and directories - /usr/bin/docker-containerd"
179+
# 1.12
180+
check_1_12="1.12 - Audit Docker files and directories - /usr/bin/docker-containerd"
206181
file="/usr/bin/docker-containerd"
207182
if [ -f "$file" ]; then
208183
command -v auditctl >/dev/null 2>&1
209184
if [ $? -eq 0 ]; then
210185
auditctl -l | grep $file >/dev/null 2>&1
211186
if [ $? -eq 0 ]; then
212-
pass "$check_1_14"
187+
pass "$check_1_12"
213188
else
214-
warn "$check_1_14"
189+
warn "$check_1_12"
215190
fi
216191
else
217-
warn "1.14 - Failed to inspect: auditctl command not found."
192+
warn "1.12 - Failed to inspect: auditctl command not found."
218193
fi
219194
else
220-
info "$check_1_14"
195+
info "$check_1_12"
221196
info " * File not found"
222197
fi
223198

224-
# 1.15
225-
check_1_15="1.15 - Audit Docker files and directories - /usr/bin/docker-runc"
199+
# 1.13
200+
check_1_13="1.13 - Audit Docker files and directories - /usr/bin/docker-runc"
226201
file="/usr/bin/docker-runc"
227202
if [ -f "$file" ]; then
228203
command -v auditctl >/dev/null 2>&1
229204
if [ $? -eq 0 ]; then
230205
auditctl -l | grep $file >/dev/null 2>&1
231206
if [ $? -eq 0 ]; then
232-
pass "$check_1_15"
207+
pass "$check_1_13"
233208
else
234-
warn "$check_1_15"
209+
warn "$check_1_13"
235210
fi
236211
else
237-
warn "1.15 - Failed to inspect: auditctl command not found."
212+
warn "1.13 - Failed to inspect: auditctl command not found."
238213
fi
239214
else
240-
info "$check_1_15"
215+
info "$check_1_13"
241216
info " * File not found"
242217
fi

0 commit comments

Comments
 (0)