Skip to content
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

fix: aide_string: drop nl at end #10578

Merged
merged 1 commit into from
May 17, 2023

Conversation

maage
Copy link
Contributor

@maage maage commented May 16, 2023

Description:

aide_string got \n at end and it messed up later bash remediation.

Rationale:

Simple fix issue seen. #10557 (comment)

But bash remediations should use bash_replace_or_accept after it handles situation like aide regexp paths. Also I wonder why aide_check_audit_tools does not use aide_files. And why there autrace twice for rhel9.

Review Hints:

This could fix aide_check_audit_tools. Only very lightly tested by me.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label May 16, 2023
@openshift-ci
Copy link

openshift-ci bot commented May 16, 2023

Hi @maage. 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. Regular contributors should join the org to skip this step.

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.

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/test-infra repository.

@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@github-actions
Copy link

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

Click here to see the full diff
OCIL for rule 'xccdf_org.ssgproject.content_rule_aide_check_audit_tools' differs.
--- ocil:ssg-aide_check_audit_tools_ocil:questionnaire:1
+++ ocil:ssg-aide_check_audit_tools_ocil:questionnaire:1
@@ -4,20 +4,14 @@
 # sudo cat /etc/aide.conf | grep /usr/sbin/au
 
 /usr/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
-
 /usr/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
-
 /usr/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
-
 /usr/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
-
 /usr/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
 
 
 
-
 /usr/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
-
 
 
 If AIDE is configured properly to protect the integrity of the audit tools,

bash remediation for rule 'xccdf_org.ssgproject.content_rule_aide_check_audit_tools' differs.
--- xccdf_org.ssgproject.content_rule_aide_check_audit_tools
+++ xccdf_org.ssgproject.content_rule_aide_check_audit_tools
@@ -15,59 +15,45 @@
 
 
 if grep -i '^.*/usr/sbin/auditctl.*$' /etc/aide.conf; then
-sed -i "s#.*/usr/sbin/auditctl.*#/usr/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
-#" /etc/aide.conf
+sed -i "s#.*/usr/sbin/auditctl.*#/usr/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512#" /etc/aide.conf
 else
-echo "/usr/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512
-" >> /etc/aide.conf
+echo "/usr/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512" >> /etc/aide.conf
 fi
 
 if grep -i '^.*/usr/sbin/auditd.*$' /etc/aide.conf; then
-sed -i "s#.*/usr/sbin/auditd.*#/usr/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
-#" /etc/aide.conf
+sed -i "s#.*/usr/sbin/auditd.*#/usr/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512#" /etc/aide.conf
 else
-echo "/usr/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512
-" >> /etc/aide.conf
+echo "/usr/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512" >> /etc/aide.conf
 fi
 
 if grep -i '^.*/usr/sbin/ausearch.*$' /etc/aide.conf; then
-sed -i "s#.*/usr/sbin/ausearch.*#/usr/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
-#" /etc/aide.conf
+sed -i "s#.*/usr/sbin/ausearch.*#/usr/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512#" /etc/aide.conf
 else
-echo "/usr/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512
-" >> /etc/aide.conf
+echo "/usr/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512" >> /etc/aide.conf
 fi
 
 if grep -i '^.*/usr/sbin/aureport.*$' /etc/aide.conf; then
-sed -i "s#.*/usr/sbin/aureport.*#/usr/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
-#" /etc/aide.conf
+sed -i "s#.*/usr/sbin/aureport.*#/usr/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512#" /etc/aide.conf
 else
-echo "/usr/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512
-" >> /etc/aide.conf
+echo "/usr/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512" >> /etc/aide.conf
 fi
 
 if grep -i '^.*/usr/sbin/autrace.*$' /etc/aide.conf; then
-sed -i "s#.*/usr/sbin/autrace.*#/usr/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
-#" /etc/aide.conf
+sed -i "s#.*/usr/sbin/autrace.*#/usr/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512#" /etc/aide.conf
 else
-echo "/usr/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512
-" >> /etc/aide.conf
+echo "/usr/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512" >> /etc/aide.conf
 fi
 
 if grep -i '^.*/usr/sbin/augenrules.*$' /etc/aide.conf; then
-sed -i "s#.*/usr/sbin/augenrules.*#/usr/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
-#" /etc/aide.conf
+sed -i "s#.*/usr/sbin/augenrules.*#/usr/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512#" /etc/aide.conf
 else
-echo "/usr/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512
-" >> /etc/aide.conf
+echo "/usr/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512" >> /etc/aide.conf
 fi
 
 if grep -i '^.*/usr/sbin/rsyslogd.*$' /etc/aide.conf; then
-sed -i "s#.*/usr/sbin/rsyslogd.*#/usr/sbin/rsyslogd p+i+n+u+g+s+b+acl+xattrs+sha512
-#" /etc/aide.conf
+sed -i "s#.*/usr/sbin/rsyslogd.*#/usr/sbin/rsyslogd p+i+n+u+g+s+b+acl+xattrs+sha512#" /etc/aide.conf
 else
-echo "/usr/sbin/rsyslogd p+i+n+u+g+s+b+acl+xattrs+sha512
-" >> /etc/aide.conf
+echo "/usr/sbin/rsyslogd p+i+n+u+g+s+b+acl+xattrs+sha512" >> /etc/aide.conf
 fi
 
 else

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_aide_check_audit_tools' differs.
--- xccdf_org.ssgproject.content_rule_aide_check_audit_tools
+++ xccdf_org.ssgproject.content_rule_aide_check_audit_tools
@@ -44,7 +44,7 @@
 lineinfile:
 path: /etc/aide.conf
 regexp: ^{{ item }}\s
- line: '{{ item }} p+i+n+u+g+s+b+acl+xattrs+sha512 '
+ line: '{{ item }} p+i+n+u+g+s+b+acl+xattrs+sha512'
 with_items: '{{ audit_tools }}'
 when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
@@ -62,7 +62,7 @@
 - name: Configure AIDE to properly protect audit tools
 lineinfile:
 path: /etc/aide.conf
- line: '{{ item }} p+i+n+u+g+s+b+acl+xattrs+sha512 '
+ line: '{{ item }} p+i+n+u+g+s+b+acl+xattrs+sha512'
 with_items: '{{ audit_tools }}'
 when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:

@maage maage mentioned this pull request May 16, 2023
@codeclimate
Copy link

codeclimate bot commented May 17, 2023

Code Climate has analyzed commit 293bc75 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 52.4% (0.0% change).

View more on Code Climate.

@marcusburghardt marcusburghardt self-assigned this May 17, 2023
@marcusburghardt marcusburghardt added this to the 0.1.68 milestone May 17, 2023
@marcusburghardt marcusburghardt added bugfix Fixes to reported bugs. Bash Bash remediation update. Ansible Ansible remediation update. and removed Bash Bash remediation update. labels May 17, 2023
Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@marcusburghardt marcusburghardt merged commit a8c49cd into ComplianceAsCode:master May 17, 2023
@marcusburghardt
Copy link
Member

Description:

aide_string got \n at end and it messed up later bash remediation.

Rationale:

Simple fix issue seen. #10557 (comment)

But bash remediations should use bash_replace_or_accept after it handles situation like aide regexp paths. Also I wonder why aide_check_audit_tools does not use aide_files. And why there autrace twice for rhel9.

I believe it can use aide_files and remove the duplication for autrace in RHEL9. @Mab879 , could you take a look and confirm this, please? I saw the changes were made here: bb2597f

Review Hints:

This could fix aide_check_audit_tools. Only very lightly tested by me.

@maage maage deleted the aide_string-1 branch May 18, 2023 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. Bash Bash remediation update. bugfix Fixes to reported bugs. needs-ok-to-test Used by openshift-ci bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants