-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4743 from iokomin/add_rule_syslog_files_tests
Add syslog_files rules test scenarios
- Loading branch information
Showing
28 changed files
with
1,128 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...oup_system/group_logging/group_ensure_rsyslog_log_file_configuration/rsyslog_log_utils.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
RSYSLOG_CONF='/etc/rsyslog.conf' | ||
LOG_FILE_PREFIX=test | ||
RSYSLOG_TEST_DIR=/tmp | ||
declare -a RSYSLOG_TEST_LOGS | ||
|
||
# This function creates test rsyslog log files | ||
# Parameters: $1 - number of log files to be created | ||
function create_rsyslog_test_logs { | ||
local count=$1 | ||
|
||
RSYSLOG_TEST_DIR=$(mktemp -d) | ||
RSYSLOG_TEST_LOGS=() | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Failed to create RSYSLOG_TEST_DIR" | ||
exit 1 | ||
fi | ||
|
||
if ! [[ "$count" =~ ^[0-9]+$ ]] || [ $count -eq 0 ]; then | ||
echo "Argument 'count' is not a positive number: $count" | ||
exit 1 | ||
fi | ||
|
||
for ind in $(seq 1 $count); do | ||
local testlog=${RSYSLOG_TEST_DIR}/${LOG_FILE_PREFIX}${ind}.log | ||
touch ${testlog} | ||
RSYSLOG_TEST_LOGS+=("${testlog}") | ||
done; | ||
} |
43 changes: 43 additions & 0 deletions
43
...g_log_file_configuration/rule_rsyslog_files_groupownership/IncludeConfig_is_other.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol | ||
|
||
# Check rsyslog.conf with root group-owner log from rules and | ||
# non root group-owner log from $IncludeConfig fails. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP_TEST=testssg | ||
groupadd $GROUP_TEST | ||
|
||
GROUP_ROOT=root | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 2 | ||
|
||
# setup test log files ownership | ||
chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[0]} | ||
chgrp $GROUP_TEST ${RSYSLOG_TEST_LOGS[1]} | ||
|
||
# create test configuration file | ||
test_conf=${RSYSLOG_TEST_DIR}/test1.conf | ||
cat << EOF > ${test_conf} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[1]} | ||
EOF | ||
|
||
# create rsyslog.conf configuration file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
#### MODULES #### | ||
\$IncludeConfig ${test_conf} | ||
EOF |
40 changes: 40 additions & 0 deletions
40
...og_log_file_configuration/rule_rsyslog_files_groupownership/IncludeConfig_is_root.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol | ||
|
||
# Check rsyslog.conf with root group-owner log from rules and | ||
# root group-owner log from $IncludeConfig passes. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP=root | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 2 | ||
|
||
# setup test log files ownership | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]} | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]} | ||
|
||
# create test configuration file | ||
test_conf=${RSYSLOG_TEST_DIR}/test1.conf | ||
cat << EOF > ${test_conf} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[1]} | ||
EOF | ||
|
||
# create rsyslog.conf configuration file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
#### MODULES #### | ||
\$IncludeConfig ${test_conf} | ||
EOF |
43 changes: 43 additions & 0 deletions
43
...rsyslog_log_file_configuration/rule_rsyslog_files_groupownership/include_is_other.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8 | ||
|
||
# Check rsyslog.conf with root group-owner log from rules and | ||
# non root group-owner log from include() fails. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP_TEST=testssg | ||
groupadd $GROUP_TEST | ||
|
||
GROUP_ROOT=root | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 2 | ||
|
||
# setup test log files ownership | ||
chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[0]} | ||
chgrp $GROUP_TEST ${RSYSLOG_TEST_LOGS[1]} | ||
|
||
# create test configuration file | ||
test_conf=${RSYSLOG_TEST_DIR}/test1.conf | ||
cat << EOF > ${test_conf} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[1]} | ||
EOF | ||
|
||
# create rsyslog.conf configuration file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
#### MODULES #### | ||
include(file="${test_conf}") | ||
EOF |
40 changes: 40 additions & 0 deletions
40
..._rsyslog_log_file_configuration/rule_rsyslog_files_groupownership/include_is_root.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8 | ||
|
||
# Check rsyslog.conf with root group-owner log from rules and | ||
# root group-owner log from include() passes. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP=root | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 2 | ||
|
||
# setup test log files ownership | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]} | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]} | ||
|
||
# create test configuration file | ||
test_conf=${RSYSLOG_TEST_DIR}/test1.conf | ||
cat << EOF > ${test_conf} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[1]} | ||
EOF | ||
|
||
# create rsyslog.conf configuration file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
#### MODULES #### | ||
include(file="${test_conf}") | ||
EOF |
56 changes: 56 additions & 0 deletions
56
...guration/rule_rsyslog_files_groupownership/include_is_root_IncludeConfig_is_other.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8 | ||
|
||
# Check rsyslog.conf with root group-owner log from rules and | ||
# non root group-owner log from include() fails. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP_ROOT=root | ||
|
||
GROUP_TEST=testssg | ||
groupadd $GROUP_TEST | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 3 | ||
|
||
# setup test log files ownership | ||
chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[0]} | ||
chgrp $GROUP_ROOT ${RSYSLOG_TEST_LOGS[1]} | ||
chgrp $GROUP_TEST ${RSYSLOG_TEST_LOGS[2]} | ||
|
||
# create test configuration file | ||
test_conf=${RSYSLOG_TEST_DIR}/test1.conf | ||
cat << EOF > ${test_conf} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[1]} | ||
EOF | ||
|
||
# create test2 configuration file | ||
test_conf2=${RSYSLOG_TEST_DIR}/test2.conf | ||
cat << EOF > ${test_conf2} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[2]} | ||
EOF | ||
|
||
# create rsyslog.conf configuration file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
#### MODULES #### | ||
include(file="${test_conf}") | ||
\$IncludeConfig ${test_conf2} | ||
EOF |
53 changes: 53 additions & 0 deletions
53
...iguration/rule_rsyslog_files_groupownership/include_is_root_IncludeConfig_is_root.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8 | ||
|
||
# Check rsyslog.conf with root group-owner log from rules and | ||
# root group-owner log from include() passes. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP=root | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 3 | ||
|
||
# setup test log files ownership | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]} | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]} | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[2]} | ||
|
||
# create test configuration file | ||
test_conf=${RSYSLOG_TEST_DIR}/test1.conf | ||
cat << EOF > ${test_conf} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[1]} | ||
EOF | ||
|
||
# create test2 configuration file | ||
test_conf2=${RSYSLOG_TEST_DIR}/test2.conf | ||
cat << EOF > ${test_conf2} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[2]} | ||
EOF | ||
|
||
# create rsyslog.conf configuration file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
#### MODULES #### | ||
include(file="${test_conf}") | ||
\$IncludeConfig ${test_conf2} | ||
EOF |
42 changes: 42 additions & 0 deletions
42
...og_file_configuration/rule_rsyslog_files_groupownership/include_multiline_is_root.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = Red Hat Enterprise Linux 8,multi_platform_fedora,Oracle Linux 8 | ||
|
||
# Check rsyslog.conf with root group-owner log from rules and | ||
# root group-owner log from multiline include() passes. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP=root | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 2 | ||
|
||
# setup test log files ownership | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]} | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[1]} | ||
|
||
# create test configuration file | ||
test_conf=${RSYSLOG_TEST_DIR}/test1.conf | ||
cat << EOF > ${test_conf} | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[1]} | ||
EOF | ||
|
||
# create rsyslog.conf configuration file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
#### MODULES #### | ||
include( | ||
file="${test_conf}" | ||
) | ||
EOF |
26 changes: 26 additions & 0 deletions
26
..._ensure_rsyslog_log_file_configuration/rule_rsyslog_files_groupownership/is_other.fail.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# profiles = xccdf_org.ssgproject.content_profile_pci-dss | ||
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol | ||
|
||
# Check if log file with non root group-owner in rsyslog.conf fails. | ||
|
||
source ../rsyslog_log_utils.sh | ||
|
||
GROUP=testssg | ||
|
||
groupadd $GROUP | ||
|
||
# setup test data | ||
create_rsyslog_test_logs 1 | ||
|
||
# setup test log file ownership | ||
chgrp $GROUP ${RSYSLOG_TEST_LOGS[0]} | ||
|
||
# add rule with non-root group owned log file | ||
cat << EOF > $RSYSLOG_CONF | ||
# rsyslog configuration file | ||
#### RULES #### | ||
*.* ${RSYSLOG_TEST_LOGS[0]} | ||
EOF |
Oops, something went wrong.