2015-05-11 06:08:28 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
logit ""
|
|
|
|
info "1 - Host Configuration"
|
2017-01-25 10:22:08 +01:00
|
|
|
auditrules="/etc/audit/audit.rules"
|
2015-05-11 06:08:28 +02:00
|
|
|
|
|
|
|
# 1.1
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_1="1.1 - Ensure a separate partition for containers has been created"
|
2017-01-25 10:22:08 +01:00
|
|
|
if grep /var/lib/docker /etc/fstab >/dev/null 2>&1; then
|
2015-05-11 06:08:28 +02:00
|
|
|
pass "$check_1_1"
|
|
|
|
else
|
|
|
|
warn "$check_1_1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.2
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_2="1.2 - Ensure the container host has been Hardened"
|
2017-03-23 11:29:58 +01:00
|
|
|
note "$check_1_2"
|
2015-05-11 06:08:28 +02:00
|
|
|
|
2017-01-23 17:06:10 +01:00
|
|
|
# 1.3
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_3="1.3 - Ensure Docker is up to date"
|
2015-07-11 20:36:04 +02:00
|
|
|
docker_version=$(docker version | grep -i -A1 '^server' | grep -i 'version:' \
|
|
|
|
| awk '{print $NF; exit}' | tr -d '[:alpha:]-,')
|
2017-05-08 14:58:16 +02:00
|
|
|
docker_current_version="$(date +%y.%m.0)"
|
|
|
|
docker_current_date="$(date +%Y-%m-01)"
|
2015-06-21 23:11:02 +02:00
|
|
|
do_version_check "$docker_current_version" "$docker_version"
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 11 ]; then
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_3"
|
2017-01-23 17:06:10 +01:00
|
|
|
info " * Using $docker_version, when $docker_current_version is current as of $docker_current_date"
|
2017-01-24 09:45:24 +01:00
|
|
|
info " * Your operating system vendor may provide support and security maintenance for Docker"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_3"
|
2017-01-23 12:40:32 +01:00
|
|
|
info " * Using $docker_version which is current as of $docker_current_date"
|
2017-01-24 09:45:24 +01:00
|
|
|
info " * Check with your operating system vendor for support and security maintenance for Docker"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.4
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_4="1.4 - Ensure only trusted users are allowed to control Docker daemon"
|
2015-12-01 16:17:48 +01:00
|
|
|
docker_users=$(getent group docker)
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_4"
|
2015-05-11 06:08:28 +02:00
|
|
|
for u in $docker_users; do
|
|
|
|
info " * $u"
|
|
|
|
done
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.5
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_5="1.5 - Ensure auditing is configured for the Docker daemon"
|
2017-01-25 10:22:08 +01:00
|
|
|
file="/usr/bin/docker "
|
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep "$file" >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_5"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_5"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
|
|
|
pass "$check_1_5"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-04-21 14:24:02 +02:00
|
|
|
warn "$check_1_5"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.6
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_6="1.6 - Ensure auditing is configured for Docker files and directories - /var/lib/docker"
|
2015-06-11 02:17:14 +02:00
|
|
|
directory="/var/lib/docker"
|
2016-04-14 21:15:33 +02:00
|
|
|
if [ -d "$directory" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep $directory >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_6"
|
2016-04-14 21:15:33 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_6"
|
2016-04-14 21:15:33 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_6"
|
2016-04-14 21:15:33 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_6"
|
2016-04-14 21:15:33 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_6"
|
2016-04-14 21:15:33 +02:00
|
|
|
info " * Directory not found"
|
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.7
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_7="1.7 - Ensure auditing is configured for Docker files and directories - /etc/docker"
|
2016-04-14 21:15:33 +02:00
|
|
|
directory="/etc/docker"
|
2015-07-10 01:43:11 +02:00
|
|
|
if [ -d "$directory" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep $directory >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_7"
|
2015-06-11 02:17:14 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_7"
|
2015-06-11 02:17:14 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$directory" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_7"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_7"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_7"
|
2015-06-11 02:17:14 +02:00
|
|
|
info " * Directory not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.8
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_8="1.8 - Ensure auditing is configured for Docker files and directories - docker.service"
|
2016-04-14 21:15:33 +02:00
|
|
|
file="$(get_systemd_service_file docker.service)"
|
|
|
|
if [ -f "$file" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep "$file" >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_8"
|
2015-06-11 02:17:14 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_8"
|
2015-06-11 02:17:14 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_8"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_8"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_8"
|
2016-04-14 21:15:33 +02:00
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.9
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_9="1.9 - Ensure auditing is configured for Docker files and directories - docker.socket"
|
2016-04-14 21:15:33 +02:00
|
|
|
file="$(get_systemd_service_file docker.socket)"
|
|
|
|
if [ -e "$file" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep "$file" >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_9"
|
2015-06-11 02:17:14 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_9"
|
2015-06-11 02:17:14 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_9"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_9"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_9"
|
2015-06-11 02:17:14 +02:00
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.10
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_10="1.10 - Ensure auditing is configured for Docker files and directories - /etc/default/docker"
|
2016-04-14 21:15:33 +02:00
|
|
|
file="/etc/default/docker"
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ -f "$file" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep $file >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_10"
|
2015-06-11 02:17:14 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_10"
|
2015-06-11 02:17:14 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_10"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_10"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_10"
|
2015-06-11 02:17:14 +02:00
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.11
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_11="1.11 - Ensure auditing is configured for Docker files and directories - /etc/docker/daemon.json"
|
2016-04-14 21:15:33 +02:00
|
|
|
file="/etc/docker/daemon.json"
|
|
|
|
if [ -f "$file" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep $file >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_11"
|
2015-06-11 02:17:14 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_11"
|
2015-06-11 02:17:14 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_11"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_11"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_11"
|
2015-06-11 02:17:14 +02:00
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.12
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_12="1.12 - Ensure auditing is configured for Docker files and directories - /usr/bin/docker-containerd"
|
2016-04-14 21:15:33 +02:00
|
|
|
file="/usr/bin/docker-containerd"
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ -f "$file" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep $file >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_12"
|
2015-06-11 02:17:14 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_12"
|
2015-06-11 02:17:14 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_12"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_12"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_12"
|
2015-06-11 02:17:14 +02:00
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2017-01-24 09:45:24 +01:00
|
|
|
# 1.13
|
2017-07-07 10:21:38 +02:00
|
|
|
check_1_13="1.13 - Ensure auditing is configured for Docker files and directories - /usr/bin/docker-runc"
|
2016-04-14 21:15:33 +02:00
|
|
|
file="/usr/bin/docker-runc"
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ -f "$file" ]; then
|
2017-01-25 10:22:08 +01:00
|
|
|
if command -v auditctl >/dev/null 2>&1; then
|
|
|
|
if auditctl -l | grep $file >/dev/null 2>&1; then
|
2017-01-24 09:45:24 +01:00
|
|
|
pass "$check_1_13"
|
2015-06-11 02:17:14 +02:00
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
warn "$check_1_13"
|
2015-06-11 02:17:14 +02:00
|
|
|
fi
|
2017-04-21 14:24:02 +02:00
|
|
|
elif grep -s "$file" "$auditrules" | grep "^[^#;]" 2>/dev/null 1>&2; then
|
2017-01-25 10:22:08 +01:00
|
|
|
pass "$check_1_13"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2017-01-25 10:22:08 +01:00
|
|
|
warn "$check_1_13"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2017-01-24 09:45:24 +01:00
|
|
|
info "$check_1_13"
|
2015-06-11 02:17:14 +02:00
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|