Skip to content

Commit 89d00d8

Browse files
author
Damien Cavagnini
committed
fix: some tests are failing
find_ungrouped_files.sh and find_unowned_files.sh tests can not be executed multiple times: - test repository is not cleaned - configuration is updated multiple times Those tests are also failing, because: - the sed to change the status in the configuration was also changing the test folder path. - missing /proc in EXCLUDED paths - the EXCLUDED configuration doesn't have the correct format for egrep
1 parent 78f5b67 commit 89d00d8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

tests/hardening/find_ungrouped_files.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ test_audit() {
44
describe Running void to generate the conf file that will later be edited
55
# shellcheck disable=2154
66
"${CIS_CHECKS_DIR}/${script}.sh" || true
7+
sed -i '/^EXCLUDED/d' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
78
# shellcheck disable=2016
8-
echo 'EXCLUDED="$EXCLUDED ^/home/secaudit/6.1.12/.*"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
9+
echo 'EXCLUDED="^/proc|^/home/secaudit/6.1.12/.*"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
910
mkdir /home/secaudit/6.1.12/
1011
touch /home/secaudit/6.1.12/test
1112
chown 1200:1200 /home/secaudit/6.1.12/test
@@ -25,17 +26,20 @@ test_audit() {
2526
run noncompliant "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
2627

2728
describe Tests failing with find ignore flag
29+
sed -i '/^FIND_IGNORE_NOSUCHFILE_ERR/d' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
2830
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
2931
register_test retvalshouldbe 1
3032
register_test contain "Some ungrouped files are present"
3133
run noncompliant "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
3234

3335
describe correcting situation
34-
sed -i 's/audit/enabled/' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
36+
sed -i '/^status/s/audit/enabled/' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
3537
"${CIS_CHECKS_DIR}/${script}.sh" --apply || true
3638

3739
describe Checking resolved state
3840
register_test retvalshouldbe 0
3941
register_test contain "No ungrouped files found"
4042
run resolved "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
43+
44+
rm -rf /home/secaudit/6.1.12/ /home/secaudit/ungrouped
4145
}

tests/hardening/find_unowned_files.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ test_audit() {
44
describe Running void to generate the conf file that will later be edited
55
# shellcheck disable=2154
66
"${CIS_CHECKS_DIR}/${script}.sh" || true
7+
sed -i '/^EXCLUDED/d' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
78
# shellcheck disable=2016
8-
echo 'EXCLUDED="$EXCLUDED ^/home/secaudit/6.1.11/.*"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
9+
echo 'EXCLUDED="/proc|^/home/secaudit/6.1.11/.*"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
910
mkdir /home/secaudit/6.1.11/
1011
touch /home/secaudit/6.1.11/test
1112
chown 1200 /home/secaudit/6.1.11/test
@@ -25,17 +26,20 @@ test_audit() {
2526
run noncompliant "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
2627

2728
describe Tests failing with find ignore flag
29+
sed -i '/^FIND_IGNORE_NOSUCHFILE_ERR/d' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
2830
echo 'FIND_IGNORE_NOSUCHFILE_ERR=true' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
2931
register_test retvalshouldbe 1
3032
register_test contain "Some unowned files are present"
3133
run noncompliant "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
3234

3335
describe correcting situation
34-
sed -i 's/audit/enabled/' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
36+
sed -i '/^status/s/audit/enabled/' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
3537
"${CIS_CHECKS_DIR}/${script}.sh" || true
3638

3739
describe Checking resolved state
3840
register_test retvalshouldbe 0
3941
register_test contain "No unowned files found"
4042
run resolved "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
43+
44+
rm -rf /home/secaudit/6.1.11 /home/secaudit/unowned
4145
}

0 commit comments

Comments
 (0)