2020-11-27 09:22:47 +01:00
|
|
|
# shellcheck shell=bash
|
2019-02-14 18:10:46 +01:00
|
|
|
# run-shellcheck
|
|
|
|
test_audit() {
|
|
|
|
describe Running on blank host
|
|
|
|
register_test retvalshouldbe 0
|
|
|
|
# shellcheck disable=2154
|
2023-09-25 14:24:01 +02:00
|
|
|
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
2019-02-14 18:10:46 +01:00
|
|
|
|
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
|
2020-11-30 13:05:41 +01:00
|
|
|
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"
|
2023-09-25 14:24:01 +02:00
|
|
|
run noncompliant "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
2020-11-05 14:24:57 +01:00
|
|
|
|
|
|
|
describe correcting situation
|
2023-09-25 14:24:01 +02:00
|
|
|
echo "EXCEPTIONS=\"/home/$test_user:$test_user:root\"" >"${CIS_CONF_DIR}/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
|
2023-09-25 14:24:01 +02:00
|
|
|
run resolved "${CIS_CHECKS_DIR}/${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:?}"
|
2020-11-30 13:05:41 +01:00
|
|
|
userdel -r "$test_user"
|
2019-02-14 18:10:46 +01:00
|
|
|
}
|