2019-02-14 18:10:46 +01:00
|
|
|
# run-shellcheck
|
|
|
|
test_audit() {
|
2020-11-05 14:24:57 +01:00
|
|
|
describe Running void to generate the conf file that will later be edited
|
|
|
|
# shellcheck disable=2154
|
|
|
|
/opt/debian-cis/bin/hardening/"${script}".sh || true
|
|
|
|
echo "EXCEPTIONS=\"/:systemd-coredump:root\"" >> /opt/debian-cis/etc/conf.d/"${script}".cfg
|
|
|
|
|
2019-02-14 18:10:46 +01:00
|
|
|
describe Running on blank host
|
|
|
|
register_test retvalshouldbe 0
|
2020-11-05 14:24:57 +01:00
|
|
|
dismiss_count_for_test
|
2019-02-14 18:10:46 +01:00
|
|
|
# shellcheck disable=2154
|
|
|
|
run blank /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
|
|
|
|
2020-11-05 14:24:57 +01:00
|
|
|
local test_user="testhomeuser"
|
2020-10-26 10:55:12 +01:00
|
|
|
|
2020-11-05 14:24:57 +01:00
|
|
|
describe Test purposely failing
|
|
|
|
useradd -m $test_user
|
|
|
|
chown root:root /home/$test_user
|
2020-10-26 10:55:12 +01:00
|
|
|
register_test retvalshouldbe 1
|
2020-11-05 14:24:57 +01:00
|
|
|
register_test contain "[ KO ] The home directory (/home/$test_user) of user testhomeuser is owned by root"
|
|
|
|
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
|
|
|
|
|
|
|
describe correcting situation
|
|
|
|
echo "EXCEPTIONS=\"/:systemd-coredump:root /home/$test_user:$test_user:root\"" > /opt/debian-cis/etc/conf.d/"${script}".cfg
|
2020-10-26 10:55:12 +01:00
|
|
|
|
|
|
|
|
2020-11-05 14:24:57 +01:00
|
|
|
describe Checking resolved state
|
2020-10-26 10:55:12 +01:00
|
|
|
register_test retvalshouldbe 0
|
2020-11-05 14:24:57 +01:00
|
|
|
run resolved /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
2020-10-26 10:55:12 +01:00
|
|
|
|
|
|
|
# Cleanup
|
2020-11-05 14:24:57 +01:00
|
|
|
rm -rf "/home/${test_user:?}"
|
|
|
|
userdel -r $test_user
|
2019-02-14 18:10:46 +01:00
|
|
|
}
|