Change path of rule to realpath as per stig - #15101
Conversation
Signed-off-by: Alan Moore <alan.moore@canonical.com>
|
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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
This datastream diff is auto generated by the check Click here to see the full diffbash 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 |
Description:
Rationale: