Adapt all scripts to yescrypt (#216)

* Revert "fix: clean obsolete check 99.5.4.5.1, now handled by 5.3.4 (#215)"

This reverts commit 670c8c62f5.

We still want to verify the preexisting hashes in /etc/shadow,
even if the PAM configuration is correct for new passwords (5.3.4).

* Adapt 5.3.4, 99.5.4.5.1 and 99.5.4.5.2 to yescrypt
This commit is contained in:
Stéphane Lesimple
2023-11-21 17:43:31 +01:00
committed by GitHub
parent 693487c3a5
commit de295b3a77
7 changed files with 182 additions and 17 deletions

View File

@ -3,7 +3,7 @@
test_audit() {
describe Running on blank host
register_test retvalshouldbe 0
register_test contain REGEX "[ OK ] .*(sha512|yescrypt) is present in /etc/pam.d/common-password"
register_test contain "is present in /etc/pam.d/common-password"
# shellcheck disable=2154
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
}

View File

@ -3,7 +3,7 @@
test_audit() {
describe Running on blank host
register_test retvalshouldbe 0
register_test contain "ENCRYPT_METHOD SHA512 is present in /etc/login.defs"
register_test contain "is present in /etc/login.defs"
# shellcheck disable=2154
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
@ -11,7 +11,7 @@ test_audit() {
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"
register_test contain "is not present in /etc/login.defs"
run commented "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
rm /etc/login.defs
@ -24,7 +24,7 @@ test_audit() {
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"
register_test contain "is not present in /etc/login.defs"
run wrongconf "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
describe Correcting situation

View File

@ -0,0 +1,40 @@
# shellcheck shell=bash
# run-shellcheck
test_audit() {
describe Running on blank host
register_test retvalshouldbe 0
register_test contain "There is no password in /etc/shadow"
dismiss_count_for_test
# shellcheck disable=2154
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
cp -a /etc/shadow /tmp/shadow.bak
sed -i 's/secaudit:!/secaudit:mypassword/' /etc/shadow
describe Fail: Found unsecure password
register_test retvalshouldbe 1
register_test contain "User secaudit has a password that is not"
run unsecpasswd "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
sed -i 's/secaudit:mypassword/secaudit:!!/' /etc/shadow
describe Fail: Found disabled password
register_test retvalshouldbe 0
register_test contain "User secaudit has a disabled password"
run lockedpasswd "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
mv /tmp/shadow.bak /etc/shadow
chpasswd -c SHA512 <<EOF
secaudit:mypassword
EOF
describe Pass: Found properly hashed password
register_test retvalshouldbe 0
register_test contain "User secaudit has suitable"
run sha512pass "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
chpasswd -c SHA512 -s 1000 <<EOF
secaudit:mypassword
EOF
describe Pass: Found properly hashed password with custom round number
register_test retvalshouldbe 0
register_test contain "User secaudit has suitable"
run sha512pass "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
}

View File

@ -140,6 +140,11 @@ _run() {
echo $? >"$outdir/$usecase_name.retval"
ret=$(<"$outdir"/"$usecase_name".retval)
get_stdout
if [ -s "$outdir/${usecase_name}_err.log" ]; then
echo ">>> stderr follows"
cat "$outdir/${usecase_name}_err.log"
echo "<<< end of stderr"
fi
}
# Load assertion functions for functionnal tests