Skip to content

Commit 1576ed5

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.
1 parent 78f5b67 commit 1576ed5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/hardening/find_ungrouped_files.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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
89
echo 'EXCLUDED="$EXCLUDED ^/home/secaudit/6.1.12/.*"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
910
mkdir /home/secaudit/6.1.12/
@@ -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/
4145
}

tests/hardening/find_unowned_files.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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
89
echo 'EXCLUDED="$EXCLUDED ^/home/secaudit/6.1.11/.*"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
910
mkdir /home/secaudit/6.1.11/
@@ -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
4145
}

0 commit comments

Comments
 (0)