-
Notifications
You must be signed in to change notification settings - Fork 761
OPENSCAP-4949, OPENSCAP-4950 - Change audit watches in rule audit_rules_sudoers and audit_rules_sudoers_d #13218
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
OPENSCAP-4949, OPENSCAP-4950 - Change audit watches in rule audit_rules_sudoers and audit_rules_sudoers_d #13218
Conversation
|
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_audit_rules_networkconfig_modification_network_scripts'.
--- xccdf_org.ssgproject.content_rule_audit_rules_networkconfig_modification_network_scripts
+++ xccdf_org.ssgproject.content_rule_audit_rules_networkconfig_modification_network_scripts
@@ -3,14 +3,17 @@
Record Events that Modify the System's Network Environment
[description]:
-If the auditd daemon is configured to use the
-augenrules program to read audit rules during daemon startup (the
-default), add the following line to a file with suffix .rules in the
+If the auditd daemon is configured to use the augenrules
+program to read audit rules during daemon startup (the default), add the
+following lines to a file with suffix .rules in the
directory /etc/audit/rules.d:
+
-w /etc/sysconfig/network-scripts -p wa -k audit_rules_networkconfig_modification_network_scripts
+
If the auditd daemon is configured to use the auditctl
-utility to read audit rules during daemon startup, add the following line to
-/etc/audit/audit.rules file:
+utility to read audit rules during daemon startup, add the following lines to
+/etc/audit/audit.rules:
+
-w /etc/sysconfig/network-scripts -p wa -k audit_rules_networkconfig_modification_network_scripts
[reference]:
New content has different text for rule 'xccdf_org.ssgproject.content_rule_audit_rules_sudoers'.
--- xccdf_org.ssgproject.content_rule_audit_rules_sudoers
+++ xccdf_org.ssgproject.content_rule_audit_rules_sudoers
@@ -4,14 +4,22 @@
[description]:
At a minimum, the audit system should collect administrator actions
-for all users and root. If the auditd daemon is configured to use the
-augenrules program to read audit rules during daemon startup (the default),
-add the following line to a file with suffix .rules in the directory
-/etc/audit/rules.d:
+for all users and root.
+
+
+
+
+If the auditd daemon is configured to use the augenrules
+program to read audit rules during daemon startup (the default), add the
+following lines to a file with suffix .rules in the
+directory /etc/audit/rules.d:
+
-w /etc/sudoers -p wa -k actions
+
If the auditd daemon is configured to use the auditctl
-utility to read audit rules during daemon startup, add the following line to
-/etc/audit/audit.rules file:
+utility to read audit rules during daemon startup, add the following lines to
+/etc/audit/audit.rules:
+
-w /etc/sudoers -p wa -k actions
[reference]:
OCIL for rule 'xccdf_org.ssgproject.content_rule_audit_rules_sudoers' differs.
--- ocil:ssg-audit_rules_sudoers_ocil:questionnaire:1
+++ ocil:ssg-audit_rules_sudoers_ocil:questionnaire:1
@@ -1,7 +1,8 @@
-Verify Red Hat Enterprise Linux 8 generates audit records for all account creations, modifications, disabling, and termination events that affect "/etc/sudoers" with the following command:
+
+Verify Red Hat Enterprise Linux 8 generates audit records for all events that affect "/etc/sudoers" with the following command:
$ sudo auditctl -l | grep /etc/sudoers
--w /etc/sudoers -p wa -k identity
+-w /etc/sudoers -p wa -k actions
Is it the case that the command does not return a line, or the line is commented out?
bash remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_sudoers' differs.
--- xccdf_org.ssgproject.content_rule_audit_rules_sudoers
+++ xccdf_org.ssgproject.content_rule_audit_rules_sudoers
@@ -2,6 +2,12 @@
if rpm --quiet -q audit && rpm --quiet -q kernel; then
# Perform the remediation for both possible tools: 'auditctl' and 'augenrules'
+
+
+
+
+
+
# Create a list of audit *.rules files that should be inspected for presence and correctness
# of a particular audit rule. The scheme is as follows:
#
New content has different text for rule 'xccdf_org.ssgproject.content_rule_audit_rules_sudoers_d'.
--- xccdf_org.ssgproject.content_rule_audit_rules_sudoers_d
+++ xccdf_org.ssgproject.content_rule_audit_rules_sudoers_d
@@ -4,14 +4,22 @@
[description]:
At a minimum, the audit system should collect administrator actions
-for all users and root. If the auditd daemon is configured to use the
-augenrules program to read audit rules during daemon startup (the default),
-add the following line to a file with suffix .rules in the directory
-/etc/audit/rules.d:
+for all users and root.
+
+
+
+
+If the auditd daemon is configured to use the augenrules
+program to read audit rules during daemon startup (the default), add the
+following lines to a file with suffix .rules in the
+directory /etc/audit/rules.d:
+
-w /etc/sudoers.d/ -p wa -k actions
+
If the auditd daemon is configured to use the auditctl
-utility to read audit rules during daemon startup, add the following line to
-/etc/audit/audit.rules file:
+utility to read audit rules during daemon startup, add the following lines to
+/etc/audit/audit.rules:
+
-w /etc/sudoers.d/ -p wa -k actions
[reference]:
OCIL for rule 'xccdf_org.ssgproject.content_rule_audit_rules_sudoers_d' differs.
--- ocil:ssg-audit_rules_sudoers_d_ocil:questionnaire:1
+++ ocil:ssg-audit_rules_sudoers_d_ocil:questionnaire:1
@@ -1,7 +1,8 @@
-Verify Red Hat Enterprise Linux 8 generates audit records for all account creations, modifications, disabling, and termination events that affect "/etc/sudoers.d/" with the following command:
-$ sudo auditctl -l | grep/etc/sudoers.d
+Verify Red Hat Enterprise Linux 8 generates audit records for all events that affect "/etc/sudoers" with the following command:
--w /etc/sudoers.d/ -p wa -k identity
+$ sudo auditctl -l | grep /etc/sudoers
+
+-w /etc/sudoers -p wa -k actions
Is it the case that the command does not return a line, or the line is commented out?
bash remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_sudoers_d' differs.
--- xccdf_org.ssgproject.content_rule_audit_rules_sudoers_d
+++ xccdf_org.ssgproject.content_rule_audit_rules_sudoers_d
@@ -2,6 +2,12 @@
if rpm --quiet -q audit && rpm --quiet -q kernel; then
# Perform the remediation for both possible tools: 'auditctl' and 'augenrules'
+
+
+
+
+
+
# Create a list of audit *.rules files that should be inspected for presence and correctness
# of a particular audit rule. The scheme is as follows:
#
New content has different text for rule 'xccdf_org.ssgproject.content_rule_audit_sudo_log_events'.
--- xccdf_org.ssgproject.content_rule_audit_sudo_log_events
+++ xccdf_org.ssgproject.content_rule_audit_sudo_log_events
@@ -10,6 +10,23 @@
Verify the operating system audits activities performed during nonlocal
maintenance and diagnostic sessions. Run the following command:
$ sudo auditctl -l | grep sudo.log
+-w /var/log/sudo.log -p wa -k maintenance
+
+
+
+
+
+If the auditd daemon is configured to use the augenrules
+program to read audit rules during daemon startup (the default), add the
+following lines to a file with suffix .rules in the
+directory /etc/audit/rules.d:
+
+-w /var/log/sudo.log -p wa -k maintenance
+
+If the auditd daemon is configured to use the auditctl
+utility to read audit rules during daemon startup, add the following lines to
+/etc/audit/audit.rules:
+
-w /var/log/sudo.log -p wa -k maintenance
[reference]:
OCIL for rule 'xccdf_org.ssgproject.content_rule_audit_sudo_log_events' differs.
--- ocil:ssg-audit_sudo_log_events_ocil:questionnaire:1
+++ ocil:ssg-audit_sudo_log_events_ocil:questionnaire:1
@@ -1,7 +1,8 @@
-Verify the operating system audits activities performed during nonlocal
-maintenance and diagnostic sessions. Run the following command:
-$ sudo auditctl -l | grep sudo.log
+
+Verify Red Hat Enterprise Linux 8 generates audit records for all events that affect "/var/log/sudo.log" with the following command:
+
+$ sudo auditctl -l | grep /var/log/sudo.log
+
-w /var/log/sudo.log -p wa -k maintenance
-
Is it the case that Audit rule is not present?
New content has different text for rule 'xccdf_org.ssgproject.content_rule_audit_rules_login_events_faillock'.
--- xccdf_org.ssgproject.content_rule_audit_rules_login_events_faillock
+++ xccdf_org.ssgproject.content_rule_audit_rules_login_events_faillock
@@ -4,18 +4,21 @@
[description]:
The audit system already collects login information for all users
-and root. If the auditd daemon is configured to use the
-augenrules program to read audit rules during daemon startup (the
-default), add the following lines to a file with suffix .rules in the
-directory /etc/audit/rules.d in order to watch for attempted manual
-edits of files involved in storing logon events:
+and root.
+
+
+
+
+If the auditd daemon is configured to use the augenrules
+program to read audit rules during daemon startup (the default), add the
+following lines to a file with suffix .rules in the
+directory /etc/audit/rules.d:
-w 'xccdf_org.ssgproject.content_value_var_accounts_passwords_pam_faillock_dir' -p wa -k logins
If the auditd daemon is configured to use the auditctl
utility to read audit rules during daemon startup, add the following lines to
-/etc/audit/audit.rules file in order to watch for unattempted manual
-edits of files involved in storing logon events:
+/etc/audit/audit.rules:
-w 'xccdf_org.ssgproject.content_value_var_accounts_passwords_pam_faillock_dir' -p wa -k logins
OCIL for rule 'xccdf_org.ssgproject.content_rule_audit_rules_login_events_faillock' differs.
--- ocil:ssg-audit_rules_login_events_faillock_ocil:questionnaire:1
+++ ocil:ssg-audit_rules_login_events_faillock_ocil:questionnaire:1
@@ -1,4 +1,5 @@
-Verify Red Hat Enterprise Linux 8 generates audit records for all account creations, modifications, disabling, and termination events that affect "/etc/security/opasswd" with the following command:
+
+Verify Red Hat Enterprise Linux 8 generates audit records for all events that affect "" with the following command:
$ sudo auditctl -l | grep
New content has different text for rule 'xccdf_org.ssgproject.content_rule_audit_rules_login_events_lastlog'.
--- xccdf_org.ssgproject.content_rule_audit_rules_login_events_lastlog
+++ xccdf_org.ssgproject.content_rule_audit_rules_login_events_lastlog
@@ -4,18 +4,21 @@
[description]:
The audit system already collects login information for all users
-and root. If the auditd daemon is configured to use the
-augenrules program to read audit rules during daemon startup (the
-default), add the following lines to a file with suffix .rules in the
-directory /etc/audit/rules.d in order to watch for attempted manual
-edits of files involved in storing logon events:
+and root.
+
+
+
+
+If the auditd daemon is configured to use the augenrules
+program to read audit rules during daemon startup (the default), add the
+following lines to a file with suffix .rules in the
+directory /etc/audit/rules.d:
-w /var/log/lastlog -p wa -k logins
If the auditd daemon is configured to use the auditctl
utility to read audit rules during daemon startup, add the following lines to
-/etc/audit/audit.rules file in order to watch for unattempted manual
-edits of files involved in storing logon events:
+/etc/audit/audit.rules:
-w /var/log/lastlog -p wa -k logins
OCIL for rule 'xccdf_org.ssgproject.content_rule_audit_rules_login_events_lastlog' differs.
--- ocil:ssg-audit_rules_login_events_lastlog_ocil:questionnaire:1
+++ ocil:ssg-audit_rules_login_events_lastlog_ocil:questionnaire:1
@@ -1,4 +1,5 @@
-Verify Red Hat Enterprise Linux 8 generates audit records for all account creations, modifications, disabling, and termination events that affect "/var/log/lastlog" with the following command:
+
+Verify Red Hat Enterprise Linux 8 generates audit records for all events that affect "/var/log/lastlog" with the following command:
$ sudo auditctl -l | grep /var/log/lastlog
New content has different text for rule 'xccdf_org.ssgproject.content_rule_audit_rules_login_events_tallylog'.
--- xccdf_org.ssgproject.content_rule_audit_rules_login_events_tallylog
+++ xccdf_org.ssgproject.content_rule_audit_rules_login_events_tallylog
@@ -4,18 +4,21 @@
[description]:
The audit system already collects login information for all users
-and root. If the auditd daemon is configured to use the
-augenrules program to read audit rules during daemon startup (the
-default), add the following lines to a file with suffix .rules in the
-directory /etc/audit/rules.d in order to watch for attempted manual
-edits of files involved in storing logon events:
+and root.
+
+
+
+
+If the auditd daemon is configured to use the augenrules
+program to read audit rules during daemon startup (the default), add the
+following lines to a file with suffix .rules in the
+directory /etc/audit/rules.d:
-w /var/log/tallylog -p wa -k logins
If the auditd daemon is configured to use the auditctl
utility to read audit rules during daemon startup, add the following lines to
-/etc/audit/audit.rules file in order to watch for unattempted manual
-edits of files involved in storing logon events:
+/etc/audit/audit.rules:
-w /var/log/tallylog -p wa -k logins
OCIL for rule 'xccdf_org.ssgproject.content_rule_audit_rules_login_events_tallylog' differs.
--- ocil:ssg-audit_rules_login_events_tallylog_ocil:questionnaire:1
+++ ocil:ssg-audit_rules_login_events_tallylog_ocil:questionnaire:1
@@ -1,7 +1,7 @@
-Verify Red Hat Enterprise Linux 8 generates audit records for all account creations, modifications, disabling, and termination events that affect "/var/log/tallylog" with the following command:
+
+Verify Red Hat Enterprise Linux 8 generates audit records for all events that affect "/var/log/tallylog" with the following command:
$ sudo auditctl -l | grep /var/log/tallylog
-
-w /var/log/tallylog -p wa -k logins
Is it the case that the command does not return a line, or the line is commented out? |
|
This PR is ready for a rebase @jan-cerny. |
teacup-on-rockingchair
left a comment
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 stuff 🙇
Unify rule descriptions of rules using the `audit_rules_watch` template. This reduces code duplication.
The rule audit_rules_sudoers will now use template audit_rules_watch instead of static checks and remediations. This change has 3 advantages: 1. reduces code duplication 2. adds support for modern style of audit watches to the rule 3. removes inconsistencies inside the rule
Create a Jinja macro for OCIL text for rules using the `audit_login_events` platform. This unifies code and reduces code duplication. The OCIL code will suppport the modern style watches.
This commit adds support for directories in the audit_rules_watch template if using the modern style of watches. In modern style, the "-F" option needs to be "path" for individual files and "dir" for directories.
The rule audit_rules_mac_modification_etc_selinux configures an audit watch for the "/etc/selinux" directory. If modern style watches are used, we need to pass the "path" parameter in a directory format because the template needs to generate a different audit watch for directories. They need to contain "-F dir" instead of "-F path".
We can use template audit_rules_watch to generate checks, remediations and tests for rule audit_rules_sudoers_d. This will reduce code duplication. Additionally, this will add support for modern style watches on RHEL 10 for this rule because the template already implements them.
f38bff9 to
299099f
Compare
|
I have rebased this PR on the top of the latest upstream master branch. |
|
Code Climate has analyzed commit 299099f 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 62.0% (0.0% change). View more on Code Climate. |
|
Automatus tests pass locally |
This PR updates rule
audit_rules_sudoersandaudit_rules_sudoers_d. Instead of static checks and remediations it will now use the templateaudit_rules_watch. This change has 3 advantages:For more information, please read commit messages of all commits.