Skip to content

Change path of rule to realpath as per stig - #15101

Open
alanmcanonical wants to merge 1 commit into
ComplianceAsCode:masterfrom
alanmcanonical:audit_path
Open

Change path of rule to realpath as per stig#15101
alanmcanonical wants to merge 1 commit into
ComplianceAsCode:masterfrom
alanmcanonical:audit_path

Conversation

@alanmcanonical

Copy link
Copy Markdown
Contributor

Description:

  • Change path of rule to realpath as per stig

Rationale:

  • auditctl skips symlink's real target
  • stig benchmark says:
$ sudo auditctl -l | grep fdisk
-w /usr/sbin/fdisk -p x -k fdisk

Signed-off-by: Alan Moore <alan.moore@canonical.com>
@openshift-ci openshift-ci Bot added the needs-ok-to-test Used by openshift-ci bot. label Sep 8, 2026
@openshift-ci

openshift-ci Bot commented Sep 8, 2026

Copy link
Copy Markdown

Hi @alanmcanonical. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands_fdisk' differs.
--- xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands_fdisk
+++ xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands_fdisk
@@ -26,7 +26,7 @@
 do
     # Check if audit watch file system object rule for given path already present
 
-    if grep -q -P -- "^[\s]*-w[\s]+/sbin/fdisk" "$audit_rules_file"
+    if grep -q -P -- "^[\s]*-w[\s]+/usr/sbin/fdisk" "$audit_rules_file"
 
     then
         # Rule is found => verify yet if existing rule definition contains
@@ -36,7 +36,7 @@
         sp="[[:space:]]"
         # Extract current permission access types (e.g. -p [r|w|x|a] values) from audit rule
 
-        current_access_bits=$(sed -ne "s#$sp*-w$sp\+/sbin/fdisk $sp\+-p$sp\+\([rxwa]\{1,4\}\).*#\1#p" "$audit_rules_file")
+        current_access_bits=$(sed -ne "s#$sp*-w$sp\+/usr/sbin/fdisk $sp\+-p$sp\+\([rxwa]\{1,4\}\).*#\1#p" "$audit_rules_file")
 
         # Split required access bits string into characters array
         # (to check bit's presence for one bit at a time)
@@ -54,14 +54,14 @@
         # Propagate the updated rule's access bits (original + the required
         # ones) back into the /etc/audit/audit.rules file for that rule
 
-        sed -i "s#\($sp*-w$sp\+/sbin/fdisk$sp\+-p$sp\+\)\([rxwa]\{1,4\}\)\(.*\)#\1$current_access_bits\3#" "$audit_rules_file"
+        sed -i "s#\($sp*-w$sp\+/usr/sbin/fdisk$sp\+-p$sp\+\)\([rxwa]\{1,4\}\)\(.*\)#\1$current_access_bits\3#" "$audit_rules_file"
 
     else
         # Rule isn't present yet. Append it at the end of $audit_rules_file file
         # with proper key
 
 
-        echo "-w /sbin/fdisk -p x -k modules" >> "$audit_rules_file"
+        echo "-w /usr/sbin/fdisk -p x -k modules" >> "$audit_rules_file"
 
     fi
 done
@@ -82,7 +82,7 @@
 # If rule is defined, add '/etc/audit/rules.d/*.rules' to list of files for inspection.
 # If rule isn't defined, add '/etc/audit/rules.d/modules.rules' to list of files for inspection.
 
-readarray -t matches < <(grep -HP "[\s]*-w[\s]+/sbin/fdisk" /etc/audit/rules.d/*.rules)
+readarray -t matches < <(grep -HP "[\s]*-w[\s]+/usr/sbin/fdisk" /etc/audit/rules.d/*.rules)
 
 
 # For each of the matched entries
@@ -113,7 +113,7 @@
 do
     # Check if audit watch file system object rule for given path already present
 
-    if grep -q -P -- "^[\s]*-w[\s]+/sbin/fdisk" "$audit_rules_file"
+    if grep -q -P -- "^[\s]*-w[\s]+/usr/sbin/fdisk" "$audit_rules_file"
 
     then
         # Rule is found => verify yet if existing rule definition contains
@@ -123,7 +123,7 @@
         sp="[[:space:]]"
         # Extract current permission access types (e.g. -p [r|w|x|a] values) from audit rule
 
-        current_access_bits=$(sed -ne "s#$sp*-w$sp\+/sbin/fdisk $sp\+-p$sp\+\([rxwa]\{1,4\}\).*#\1#p" "$audit_rules_file")
+        current_access_bits=$(sed -ne "s#$sp*-w$sp\+/usr/sbin/fdisk $sp\+-p$sp\+\([rxwa]\{1,4\}\).*#\1#p" "$audit_rules_file")
 
         # Split required access bits string into characters array
         # (to check bit's presence for one bit at a time)
@@ -141,14 +141,14 @@
         # Propagate the updated rule's access bits (original + the required
         # ones) back into the /etc/audit/audit.rules file for that rule
 
-        sed -i "s#\($sp*-w$sp\+/sbin/fdisk$sp\+-p$sp\+\)\([rxwa]\{1,4\}\)\(.*\)#\1$current_access_bits\3#" "$audit_rules_file"
+        sed -i "s#\($sp*-w$sp\+/usr/sbin/fdisk$sp\+-p$sp\+\)\([rxwa]\{1,4\}\)\(.*\)#\1$current_access_bits\3#" "$audit_rules_file"
 
     else
         # Rule isn't present yet. Append it at the end of $audit_rules_file file
         # with proper key
 
 
-        echo "-w /sbin/fdisk -p x -k modules" >> "$audit_rules_file"
+        echo "-w /usr/sbin/fdisk -p x -k modules" >> "$audit_rules_file"
 
     fi
 done

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands_fdisk' differs.
--- xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands_fdisk
+++ xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands_fdisk
@@ -11,10 +11,10 @@
   - restrict_strategy
 
 - name: Ensure auditd Collects Information on the Use of Privileged Commands - fdisk
-    - Check if watch rule for /sbin/fdisk already exists in /etc/audit/rules.d/
+    - Check if watch rule for /usr/sbin/fdisk already exists in /etc/audit/rules.d/
   ansible.builtin.find:
     paths: /etc/audit/rules.d
-    contains: ^\s*-w\s+/sbin/fdisk\s+-p\s+x(\s|$)+
+    contains: ^\s*-w\s+/usr/sbin/fdisk\s+-p\s+x(\s|$)+
     patterns: '*.rules'
   register: find_existing_watch_rules_d
   when:
@@ -89,10 +89,10 @@
   - restrict_strategy
 
 - name: Ensure auditd Collects Information on the Use of Privileged Commands - fdisk
-    - Add watch rule for /sbin/fdisk in /etc/audit/rules.d/
+    - Add watch rule for /usr/sbin/fdisk in /etc/audit/rules.d/
   ansible.builtin.lineinfile:
     path: '{{ all_files[0] }}'
-    line: -w /sbin/fdisk -p x -k modules
+    line: -w /usr/sbin/fdisk -p x -k modules
     create: true
     mode: '0600'
   when:
@@ -110,10 +110,10 @@
   - restrict_strategy
 
 - name: Ensure auditd Collects Information on the Use of Privileged Commands - fdisk
-    - Check if watch rule for /sbin/fdisk already exists in /etc/audit/audit.rules
+    - Check if watch rule for /usr/sbin/fdisk already exists in /etc/audit/audit.rules
   ansible.builtin.find:
     paths: /etc/audit/
-    contains: ^\s*-w\s+/sbin/fdisk\s+-p\s+x(\s|$)+
+    contains: ^\s*-w\s+/usr/sbin/fdisk\s+-p\s+x(\s|$)+
     patterns: audit.rules
   register: find_existing_watch_audit_rules
   when:
@@ -129,9 +129,9 @@
   - restrict_strategy
 
 - name: Ensure auditd Collects Information on the Use of Privileged Commands - fdisk
-    - Add watch rule for /sbin/fdisk in /etc/audit/audit.rules
+    - Add watch rule for /usr/sbin/fdisk in /etc/audit/audit.rules
   ansible.builtin.lineinfile:
-    line: -w /sbin/fdisk -p x -k modules
+    line: -w /usr/sbin/fdisk -p x -k modules
     state: present
     dest: /etc/audit/audit.rules
     create: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant