Skip to content

Allow file_ownership_var_log_audit_stig to check effective log files - #15114

Open
alanmcanonical wants to merge 4 commits into
ComplianceAsCode:masterfrom
alanmcanonical:log_audit_stig
Open

Allow file_ownership_var_log_audit_stig to check effective log files#15114
alanmcanonical wants to merge 4 commits into
ComplianceAsCode:masterfrom
alanmcanonical:log_audit_stig

Conversation

@alanmcanonical

Copy link
Copy Markdown
Contributor

Description:

  • Allow space-starting entries in audit.conf
  • Check effective log file in oval for Ubuntu
  • Simplfy test scripts
  • Enable test scripts for ubuntu

Rationale:

  • Test result on Ubuntu
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/alan.moore@canonical.com/dev/cac/content/logs/rule-custom-2026-09-10-1652/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_file_ownership_var_log_audit_stig
INFO - Script correct_value_default_file.pass.sh using profile (all) OK
INFO - Script wrong_value_default_file.fail.sh using profile (all) OK
INFO - Script correct_value.pass.sh using profile (all) OK
INFO - Script wrong_value.fail.sh using profile (all) OK

Signed-off-by: Alan Moore <alan.moore@canonical.com>
Signed-off-by: Alan Moore <alan.moore@canonical.com>
Signed-off-by: Alan Moore <alan.moore@canonical.com>
Signed-off-by: Alan Moore <alan.moore@canonical.com>
@openshift-ci

openshift-ci Bot commented Sep 10, 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

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_file_ownership_var_log_audit_stig' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_var_log_audit_stig
+++ xccdf_org.ssgproject.content_rule_file_ownership_var_log_audit_stig
@@ -1,12 +1,12 @@
 # Remediation is applicable only in certain platforms
 if rpm --quiet -q audit && rpm --quiet -q kernel; then
 
-if LC_ALL=C grep -iw log_file /etc/audit/auditd.conf; then
-    FILE=$(awk -F "=" '/^log_file/ {print $2}' /etc/audit/auditd.conf | tr -d ' ')
-    chown root $FILE*
-else
-    chown root /var/log/audit/audit.log*
+if LC_ALL=C grep -iqE '^[[:space:]]*log_file\b' /etc/audit/auditd.conf; then
+    FILE=$(awk -F "=" '/^[[:space:]]*log_file[[:space:]]*=/ {print $2}' /etc/audit/auditd.conf | tr -d ' ')
 fi
+
+FILE=${FILE:-/var/log/audit/audit.log}
+chown root "$(dirname "$FILE")"/*
 
 else
     >&2 echo 'Remediation is not applicable, nothing was done'

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