2015-05-11 06:08:28 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
logit ""
|
|
|
|
info "1 - Host Configuration"
|
|
|
|
|
|
|
|
# 1.1
|
|
|
|
check_1_1="1.1 - Create a separate partition for containers"
|
|
|
|
grep /var/lib/docker /etc/fstab >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_1"
|
|
|
|
else
|
|
|
|
warn "$check_1_1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.2
|
|
|
|
check_1_2="1.2 - Use an updated Linux Kernel"
|
2015-05-29 13:42:34 +02:00
|
|
|
kernel_version=$(uname -r | cut -d "-" -f 1)
|
|
|
|
do_version_check 3.10 "$kernel_version"
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 11 ]; then
|
|
|
|
warn "$check_1_2"
|
|
|
|
else
|
|
|
|
pass "$check_1_2"
|
|
|
|
fi
|
|
|
|
|
2016-04-14 21:27:24 +02:00
|
|
|
# 1.4
|
|
|
|
check_1_4="1.4 - Remove all non-essential services from the host - Network"
|
|
|
|
# Check for listening network services.
|
|
|
|
listening_services=$(netstat -na | grep -v tcp6 | grep -v unix | grep -c LISTEN)
|
|
|
|
if [ "$listening_services" -eq 0 ]; then
|
|
|
|
warn "1.4 - Failed to get listening services for check: $check_1_4"
|
|
|
|
else
|
|
|
|
if [ "$listening_services" -gt 5 ]; then
|
|
|
|
warn "$check_1_4"
|
|
|
|
warn " * Host listening on: $listening_services ports"
|
|
|
|
else
|
|
|
|
pass "$check_1_4"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-05-11 06:08:28 +02:00
|
|
|
# 1.5
|
2016-04-14 21:15:33 +02:00
|
|
|
check_1_5="1.5 - Keep Docker 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-01-11 11:44:37 +01:00
|
|
|
docker_current_version="1.12.6"
|
|
|
|
docker_current_date="2017-01-10"
|
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
|
2016-04-14 21:15:33 +02:00
|
|
|
warn "$check_1_5"
|
2015-12-01 15:43:13 +01:00
|
|
|
warn " * Using $docker_version, when $docker_current_version is current as of $docker_current_date"
|
2015-12-01 16:09:15 +01:00
|
|
|
info " * Your operating system vendor may provide support and security maintenance for docker"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2016-04-14 21:15:33 +02:00
|
|
|
pass "$check_1_5"
|
2015-12-01 15:43:13 +01:00
|
|
|
info " * Using $docker_version which is current as of $docker_current_date"
|
2015-12-01 16:09:15 +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
|
|
|
|
|
2016-04-14 21:15:33 +02:00
|
|
|
# 1.6
|
|
|
|
check_1_6="1.6 - Only allow trusted users to control Docker daemon"
|
2015-12-01 16:17:48 +01:00
|
|
|
docker_users=$(getent group docker)
|
2016-04-14 21:15:33 +02:00
|
|
|
info "$check_1_6"
|
2015-05-11 06:08:28 +02:00
|
|
|
for u in $docker_users; do
|
|
|
|
info " * $u"
|
|
|
|
done
|
|
|
|
|
2016-04-14 21:15:33 +02:00
|
|
|
# 1.7
|
|
|
|
check_1_7="1.7 - Audit docker daemon - /usr/bin/docker"
|
|
|
|
file="/usr/bin/docker"
|
2015-05-11 06:08:28 +02:00
|
|
|
command -v auditctl >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
2016-04-14 21:15:33 +02:00
|
|
|
auditctl -l | grep "$file" >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2016-04-14 21:15:33 +02:00
|
|
|
pass "$check_1_7"
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2016-04-14 21:15:33 +02:00
|
|
|
warn "$check_1_7"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2016-04-14 21:15:33 +02:00
|
|
|
warn "1.7 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
2016-04-14 21:15:33 +02:00
|
|
|
# 1.8
|
|
|
|
check_1_8="1.8 - Audit 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
|
|
|
|
command -v auditctl >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
auditctl -l | grep $directory >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_8"
|
|
|
|
else
|
|
|
|
warn "$check_1_8"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
warn "1.8 - Failed to inspect: auditctl command not found."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
info "$check_1_8"
|
|
|
|
info " * Directory not found"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.9
|
|
|
|
check_1_9="1.9 - Audit Docker files and directories - /etc/docker"
|
|
|
|
directory="/etc/docker"
|
2015-07-10 01:43:11 +02:00
|
|
|
if [ -d "$directory" ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
command -v auditctl >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
auditctl -l | grep $directory >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_9"
|
|
|
|
else
|
|
|
|
warn "$check_1_9"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
warn "1.9 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
info "$check_1_9"
|
|
|
|
info " * Directory not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.10
|
2016-04-14 21:15:33 +02:00
|
|
|
check_1_10="1.10 - Audit Docker files and directories - docker.service"
|
|
|
|
file="$(get_systemd_service_file docker.service)"
|
|
|
|
if [ -f "$file" ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
command -v auditctl >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2016-04-14 21:15:33 +02:00
|
|
|
auditctl -l | grep "$file" >/dev/null 2>&1
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_10"
|
|
|
|
else
|
|
|
|
warn "$check_1_10"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
warn "1.10 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
info "$check_1_10"
|
2016-04-14 21:15:33 +02:00
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.11
|
2016-04-14 21:15:33 +02:00
|
|
|
check_1_11="1.11 - Audit Docker files and directories - docker.socket"
|
|
|
|
file="$(get_systemd_service_file docker.socket)"
|
|
|
|
if [ -e "$file" ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
command -v auditctl >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2016-04-14 21:15:33 +02:00
|
|
|
auditctl -l | grep "$file" >/dev/null 2>&1
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_11"
|
|
|
|
else
|
|
|
|
warn "$check_1_11"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
warn "1.11 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
info "$check_1_11"
|
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.12
|
2016-04-14 21:15:33 +02:00
|
|
|
check_1_12="1.12 - Audit Docker files and directories - /etc/default/docker"
|
|
|
|
file="/etc/default/docker"
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ -f "$file" ]; then
|
|
|
|
command -v auditctl >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
auditctl -l | grep $file >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_12"
|
|
|
|
else
|
|
|
|
warn "$check_1_12"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
warn "1.12 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
info "$check_1_12"
|
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.13
|
2016-04-14 21:15:33 +02:00
|
|
|
check_1_13="1.13 - Audit Docker files and directories - /etc/docker/daemon.json"
|
|
|
|
file="/etc/docker/daemon.json"
|
|
|
|
if [ -f "$file" ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
command -v auditctl >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
auditctl -l | grep $file >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_13"
|
|
|
|
else
|
|
|
|
warn "$check_1_13"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
warn "1.13 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
info "$check_1_13"
|
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.14
|
2016-04-14 21:15:33 +02:00
|
|
|
check_1_14="1.14 - Audit Docker files and directories - /usr/bin/docker-containerd"
|
|
|
|
file="/usr/bin/docker-containerd"
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ -f "$file" ]; then
|
|
|
|
command -v auditctl >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
auditctl -l | grep $file >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_14"
|
|
|
|
else
|
|
|
|
warn "$check_1_14"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
warn "1.14 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
info "$check_1_14"
|
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# 1.15
|
2016-04-14 21:15:33 +02:00
|
|
|
check_1_15="1.15 - Audit Docker files and directories - /usr/bin/docker-runc"
|
|
|
|
file="/usr/bin/docker-runc"
|
2015-06-11 02:17:14 +02:00
|
|
|
if [ -f "$file" ]; then
|
|
|
|
command -v auditctl >/dev/null 2>&1
|
2015-05-11 06:08:28 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
2015-06-11 02:17:14 +02:00
|
|
|
auditctl -l | grep $file >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
pass "$check_1_15"
|
|
|
|
else
|
|
|
|
warn "$check_1_15"
|
|
|
|
fi
|
2015-05-11 06:08:28 +02:00
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
warn "1.15 - Failed to inspect: auditctl command not found."
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|
|
|
|
else
|
2015-06-11 02:17:14 +02:00
|
|
|
info "$check_1_15"
|
|
|
|
info " * File not found"
|
2015-05-11 06:08:28 +02:00
|
|
|
fi
|