-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Rsyslog rules to support RainerScript syntax #12010
Improve Rsyslog rules to support RainerScript syntax #12010
Conversation
We extend the OVAL check so that it will also pass if the Rsyslog's modern syntax, so-called Rainer script, is used to configure cron logging. We will allow both forms. We will use the current form in the remediation. Resolves: RHEL-1816
…driverauthmode We extend the OVAL check so that it will also pass if the Rsyslog's modern syntax Rainer script has been used. Resolves: RHEL-1816
…drivermode We extend the OVAL check so that it will also pass if the Rsyslog's modern syntax Rainer script has been used. Resolves: RHEL-1816
…driver We extend the OVAL check so that it will also pass if the Rsyslog's modern syntax Rainer script has been used. Resolves: RHEL-1816
This datastream diff is auto generated by the check Click here to see the full diffNew content has different text for rule 'xccdf_org.ssgproject.content_rule_rsyslog_cron_logging'.
--- xccdf_org.ssgproject.content_rule_rsyslog_cron_logging
+++ xccdf_org.ssgproject.content_rule_rsyslog_cron_logging
@@ -7,7 +7,10 @@
cron job status. If cron is not logging to rsyslog, it
can be implemented by adding the following to the RULES section of
/etc/rsyslog.conf:
+If the legacy syntax is used:
cron.* /var/log/cron
+If the modern syntax (RainerScript) is used:
+cron.* action(type="omfile" file="/var/log/cron")
[reference]:
1
OVAL for rule 'xccdf_org.ssgproject.content_rule_rsyslog_cron_logging' differs.
--- oval:ssg-rsyslog_cron_logging:def:1
+++ oval:ssg-rsyslog_cron_logging:def:1
@@ -1,3 +1,5 @@
criteria OR
criterion oval:ssg-test_cron_logging_rsyslog:tst:1
+criterion oval:ssg-test_cron_logging_rsyslog_rainer:tst:1
criterion oval:ssg-test_cron_logging_rsyslog_dir:tst:1
+criterion oval:ssg-test_cron_logging_rsyslog_dir_rainer:tst:1
OCIL for rule 'xccdf_org.ssgproject.content_rule_rsyslog_cron_logging' differs.
--- ocil:ssg-rsyslog_cron_logging_ocil:questionnaire:1
+++ ocil:ssg-rsyslog_cron_logging_ocil:questionnaire:1
@@ -2,5 +2,7 @@
run the following command:
grep -rni "cron\.\*" /etc/rsyslog.*
cron.* /var/log/cron
+or
+cron.* action(type="omfile" file="/var/log/cron")
Is it the case that cron is not logging to rsyslog?
New content has different text for rule 'xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdriverauthmode'.
--- xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdriverauthmode
+++ xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdriverauthmode
@@ -10,6 +10,11 @@
encrypt and off-load auditing.
When using rsyslogd to off-load logs the remote system must be authenticated.
+
+Set the following configuration option in /etc/rsyslog.conf or in a file in /etc/rsyslog.d (using legacy syntax):
+$ActionSendStreamDriverAuthMode x509/name
+Alternatively, use the RainerScript syntax:
+action(type="omfwd" Target="some.example.com" StreamDriverAuthMode="x509/name")
[reference]:
CCI-001851
OVAL for rule 'xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdriverauthmode' differs.
--- oval:ssg-rsyslog_encrypt_offload_actionsendstreamdriverauthmode:def:1
+++ oval:ssg-rsyslog_encrypt_offload_actionsendstreamdriverauthmode:def:1
@@ -1,4 +1,6 @@
criteria AND
criteria OR
criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdriverauthmode_action_send_stream_driver_auth_mode:tst:1
+criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdriverauthmode_action_send_stream_driver_auth_mode_rainer:tst:1
criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdriverauthmode_action_send_stream_driver_auth_mode_dir:tst:1
+criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdriverauthmode_action_send_stream_driver_auth_mode_dir_rainer:tst:1
New content has different text for rule 'xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdrivermode'.
--- xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdrivermode
+++ xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdrivermode
@@ -10,6 +10,12 @@
encrypt and off-load auditing.
When using rsyslogd to off-load logs off a encrpytion system must be used.
+
+Set the following configuration option in /etc/rsyslog.conf or in a file in /etc/rsyslog.d (using legacy syntax):
+$ActionSendStreamDriverMode 1
+
+Alternatively, use the RainerScript syntax:
+action(type="omfwd" ... StreamDriverMode="1")
[reference]:
CCI-001851
OVAL for rule 'xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_actionsendstreamdrivermode' differs.
--- oval:ssg-rsyslog_encrypt_offload_actionsendstreamdrivermode:def:1
+++ oval:ssg-rsyslog_encrypt_offload_actionsendstreamdrivermode:def:1
@@ -1,4 +1,6 @@
criteria AND
criteria OR
criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdrivermode_action_send_stream_driver_mode_rsyslog:tst:1
+criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdrivermode_action_send_stream_driver_mode_rsyslog_rainer:tst:1
criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdrivermode_action_send_stream_driver_mode_rsyslog_dir:tst:1
+criterion oval:ssg-test_rsyslog_encrypt_offload_actionsendstreamdrivermode_action_send_stream_driver_mode_rsyslog_dir_rainer:tst:1
New content has different text for rule 'xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_defaultnetstreamdriver'.
--- xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_defaultnetstreamdriver
+++ xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_defaultnetstreamdriver
@@ -10,6 +10,12 @@
encrypt and off-load auditing.
When using rsyslogd to off-load logs off an encryption system must be used.
+
+Set the following configuration option in /etc/rsyslog.conf or in a file in /etc/rsyslog.d (using legacy syntax):
+$DefaultNetstreamDriver gtls
+
+Alternatively, use the RainerScript syntax:
+global(DefaultNetstreamDriver="gtls")
[reference]:
CCI-001851
OVAL for rule 'xccdf_org.ssgproject.content_rule_rsyslog_encrypt_offload_defaultnetstreamdriver' differs.
--- oval:ssg-rsyslog_encrypt_offload_defaultnetstreamdriver:def:1
+++ oval:ssg-rsyslog_encrypt_offload_defaultnetstreamdriver:def:1
@@ -1,4 +1,6 @@
criteria AND
criteria OR
criterion oval:ssg-test_rsyslog_encrypt_offload_defaultnetstreamdriver_default_netstream_rsyslog:tst:1
+criterion oval:ssg-test_rsyslog_encrypt_offload_defaultnetstreamdriver_default_netstream_rsyslog_rainer:tst:1
criterion oval:ssg-test_rsyslog_encrypt_offload_defaultnetstreamdriver_default_netstream_rsyslog_dir:tst:1
+criterion oval:ssg-test_rsyslog_encrypt_offload_defaultnetstreamdriver_default_netstream_rsyslog_dir_rainer:tst:1 |
🤖 A k8s content image for this PR is available at: Click here to see how to deploy itIf you alread have Compliance Operator deployed: Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the comments in specific files, the remediation for rule rsyslog_cron_logging
is not working when the /etc/rsyslog.conf
file is deleted, more specifically in the test scenario no_rsyslog_file.fail.sh
. After the remediation, the rsyslog service can't be started. This issue was not introduced by this PR, but was revealed now. Could you take a look on it, please?
...de/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/oval/shared.xml
Outdated
Show resolved
Hide resolved
..._rsyslog_log_file_configuration/rsyslog_cron_logging/tests/cron_set_rainer_rsyslog_d.pass.sh
Outdated
Show resolved
Hide resolved
...og_file_configuration/rsyslog_encrypt_offload_actionsendstreamdriverauthmode/oval/shared.xml
Outdated
Show resolved
Hide resolved
...og_file_configuration/rsyslog_encrypt_offload_actionsendstreamdriverauthmode/oval/shared.xml
Outdated
Show resolved
Hide resolved
...og_log_file_configuration/rsyslog_encrypt_offload_actionsendstreamdrivermode/oval/shared.xml
Outdated
Show resolved
Hide resolved
...syslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/oval/shared.xml
Outdated
Show resolved
Hide resolved
...syslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/oval/shared.xml
Outdated
Show resolved
Hide resolved
Files in /etc/rsyslog.d should have the .conf extension: From rsyslog.conf: \# Include all config files in /etc/rsyslog.d/ include(file="/etc/rsyslog.d/*.conf" mode="optional")
Isn't the test scenario |
Yes, I agree this test scenario is very weak. It is fine to remove the files in Perhaps, just to keep a test without rsyslog.d files, we could just rename the
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jan-cerny . It is much better after using variables for regex. Nice!!
I only suggested some comments to align the name of this rsyslog syntax to the official documentation: RainerScript
Once we solve the test scenario issue I believe we are good to merge.
...de/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/oval/shared.xml
Outdated
Show resolved
Hide resolved
...de/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/oval/shared.xml
Outdated
Show resolved
Hide resolved
...de/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/oval/shared.xml
Outdated
Show resolved
Hide resolved
...de/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/oval/shared.xml
Outdated
Show resolved
Hide resolved
..._os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_cron_logging/rule.yml
Outdated
Show resolved
Hide resolved
...syslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/oval/shared.xml
Outdated
Show resolved
Hide resolved
...syslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/oval/shared.xml
Outdated
Show resolved
Hide resolved
...syslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/oval/shared.xml
Outdated
Show resolved
Hide resolved
...syslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/oval/shared.xml
Outdated
Show resolved
Hide resolved
...syslog_log_file_configuration/rsyslog_encrypt_offload_defaultnetstreamdriver/oval/shared.xml
Outdated
Show resolved
Hide resolved
The test scenario deleted the configuration file and that caused the service to not start. We can't expect that the remediation of a single rule will restore all other configuration option. Instead, the test scenario will be changed to only remove the configuration option but keep the configuration file.
/retest |
I have changed and renamed the test scenario no_rsyslog_file.fail.sh. I have changed occurrences to RainerScript. |
Rsyslog isn't installed by default. Missing header caused all test scenarios evaluated as notapplicable on some test back ends.
Code Climate has analyzed commit e5bfb40 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 59.4% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Thanks
4718919
into
ComplianceAsCode:master
Description:
Improve OVAL checks so that the rule will pass if the modern Rainer script syntax is used. Up until now these rules passed only when the legacy configuration is used.
This changes OVAL in the following rules:
For more details, please read commit messages of all commits.
Rationale:
Fixes: https://issues.redhat.com/browse/RHEL-1816