Replace CIS_ROOT_DIR by a more flexible system (#204)

* Replace CIS_ROOT_DIR by a more flexible system

* Try to adapt the logic change to the functional tests
This commit is contained in:
P-EB
2023-09-25 14:24:01 +02:00
committed by GitHub
parent 5370ec2ef6
commit 32886d3a3d
493 changed files with 2060 additions and 2056 deletions

View File

@ -5,34 +5,34 @@ test_audit() {
register_test retvalshouldbe 0
register_test contain "ENCRYPT_METHOD SHA512 is present in /etc/login.defs"
# shellcheck disable=2154
run blank /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
cp /etc/login.defs /tmp/login.defs.bak
describe Line as comment
sed -i 's/\(ENCRYPT_METHOD SHA512\)/# \1/' /etc/login.defs
register_test retvalshouldbe 1
register_test contain "SHA512 is not present"
run commented /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
run commented "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
rm /etc/login.defs
describe Fail: missing conf file
register_test retvalshouldbe 1
register_test contain "/etc/login.defs is not readable"
run missconffile /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
run missconffile "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
cp /tmp/login.defs.bak /etc/login.defs
sed -ir 's/ENCRYPT_METHOD[[:space:]]\+SHA512/ENCRYPT_METHOD MD5/' /etc/login.defs
describe Fail: wrong hash function configuration
register_test retvalshouldbe 1
register_test contain "SHA512 is not present"
run wrongconf /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
run wrongconf "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
describe Correcting situation
sed -i 's/disabled/enabled/' /opt/debian-cis/etc/conf.d/"${script}".cfg
/opt/debian-cis/bin/hardening/"${script}".sh || true
sed -i 's/disabled/enabled/' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
"${CIS_CHECKS_DIR}/${script}.sh" || true
describe Checking resolved state
mv /tmp/login.defs.bak /etc/login.defs
register_test retvalshouldbe 0
run sha512pass /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
run sha512pass "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
}