-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix auditd rule to watch apparmor instead of selinux on Ubuntu
- Loading branch information
Showing
7 changed files
with
87 additions
and
12 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
linux_os/guide/auditing/auditd_configure_rules/audit_rules_mac_modification/bash/shared.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
# platform = Red Hat Virtualization 4,multi_platform_fedora,multi_platform_ol,multi_platform_rhel,multi_platform_sle,multi_platform_slmicro,multi_platform_ubuntu | ||
|
||
# Perform the remediation for both possible tools: 'auditctl' and 'augenrules' | ||
{{% if 'ubuntu' not in product %}} | ||
{{{ bash_fix_audit_watch_rule("auditctl", "/etc/selinux/", "wa", "MAC-policy") }}} | ||
{{{ bash_fix_audit_watch_rule("augenrules", "/etc/selinux/", "wa", "MAC-policy") }}} | ||
{{% else %}} | ||
{{{ bash_fix_audit_watch_rule("auditctl", "/etc/apparmor/", "wa", "MAC-policy") }}} | ||
{{{ bash_fix_audit_watch_rule("augenrules", "/etc/apparmor/", "wa", "MAC-policy") }}} | ||
{{{ bash_fix_audit_watch_rule("auditctl", "/etc/apparmor.d/", "wa", "MAC-policy") }}} | ||
{{{ bash_fix_audit_watch_rule("augenrules", "/etc/apparmor.d/", "wa", "MAC-policy") }}} | ||
{{% endif %}} |
59 changes: 48 additions & 11 deletions
59
linux_os/guide/auditing/auditd_configure_rules/audit_rules_mac_modification/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,77 @@ | ||
{{% set mac_name="SELinux" %}} | ||
{{% set mac_used="selinux"%}} | ||
{{% set mac_path="/etc/selinux" %}} | ||
{{% if 'ubuntu' in product %}} | ||
{{% set mac_name="AppArmor" %}} | ||
{{% set mac_used="apparmor"%}} | ||
{{% set mac_path="/etc/apparmor" %}} | ||
{{% endif %}} | ||
|
||
<def-group> | ||
<definition class="compliance" id="audit_rules_mac_modification" version="1"> | ||
{{{ oval_metadata("Audit rules that detect changes to the system's mandatory access controls (SELinux) are enabled.") }}} | ||
{{{ oval_metadata("Audit rules that detect changes to the system's mandatory access controls (" + mac_name + ") are enabled.") }}} | ||
|
||
<criteria operator="OR"> | ||
|
||
<!-- Test the augenrules case --> | ||
<criteria operator="AND"> | ||
<extend_definition comment="audit augenrules" definition_ref="audit_rules_augenrules" /> | ||
<criterion comment="audit selinux changes augenrules" test_ref="test_armm_selinux_watch_augenrules" /> | ||
<criterion comment="audit {{{ mac_used }}} changes augenrules" test_ref="test_armm_{{{ mac_used }}}_watch_augenrules" /> | ||
{{% if 'ubuntu' in product %}} | ||
<criterion comment="audit {{{ mac_used }}}.d changes augenrules" test_ref="test_armm_{{{ mac_used }}}d_watch_augenrules" /> | ||
{{% endif %}} | ||
</criteria> | ||
|
||
<!-- Test the auditctl case --> | ||
<criteria operator="AND"> | ||
<extend_definition comment="audit auditctl" definition_ref="audit_rules_auditctl" /> | ||
<criterion comment="audit selinux changes auditctl" test_ref="test_armm_selinux_watch_auditctl" /> | ||
<criterion comment="audit {{{ mac_used }}} changes auditctl" test_ref="test_armm_{{{ mac_used }}}_watch_auditctl" /> | ||
{{% if 'ubuntu' in product %}} | ||
<criterion comment="audit {{{ mac_used }}}.d changes auditctl" test_ref="test_armm_{{{ mac_used }}}d_watch_auditctl" /> | ||
{{% endif %}} | ||
</criteria> | ||
|
||
</criteria> | ||
</definition> | ||
|
||
<ind:textfilecontent54_test check="all" comment="audit selinux changes augenrules" id="test_armm_selinux_watch_augenrules" version="1"> | ||
<ind:object object_ref="object_armm_selinux_watch_augenrules" /> | ||
<ind:textfilecontent54_test check="all" comment="audit {{{ mac_used }}} changes augenrules" id="test_armm_{{{ mac_used }}}_watch_augenrules" version="1"> | ||
<ind:object object_ref="object_armm_{{{ mac_used }}}_watch_augenrules" /> | ||
</ind:textfilecontent54_test> | ||
<ind:textfilecontent54_object id="object_armm_selinux_watch_augenrules" version="1"> | ||
<ind:textfilecontent54_object id="object_armm_{{{ mac_used }}}_watch_augenrules" version="1"> | ||
<ind:filepath operation="pattern match">^/etc/audit/rules\.d/.*\.rules$</ind:filepath> | ||
<ind:pattern operation="pattern match">^\-w[\s]+/etc/selinux/[\s]+\-p[\s]+\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</ind:pattern> | ||
<ind:pattern operation="pattern match">^\-w[\s]+{{{ mac_path }}}/[\s]+\-p[\s]+\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</ind:pattern> | ||
<ind:instance datatype="int">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_test check="all" comment="audit selinux changes auditctl" id="test_armm_selinux_watch_auditctl" version="1"> | ||
<ind:object object_ref="object_armm_selinux_watch_auditctl" /> | ||
<ind:textfilecontent54_test check="all" comment="audit {{{ mac_used }}} changes auditctl" id="test_armm_{{{ mac_used }}}_watch_auditctl" version="1"> | ||
<ind:object object_ref="object_armm_{{{ mac_used }}}_watch_auditctl" /> | ||
</ind:textfilecontent54_test> | ||
<ind:textfilecontent54_object id="object_armm_selinux_watch_auditctl" version="1"> | ||
<ind:textfilecontent54_object id="object_armm_{{{ mac_used }}}_watch_auditctl" version="1"> | ||
<ind:filepath>/etc/audit/audit.rules</ind:filepath> | ||
<ind:pattern operation="pattern match">^\-w[\s]+{{{ mac_path }}}/[\s]+\-p[\s]+\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</ind:pattern> | ||
<ind:instance datatype="int">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
{{% if 'ubuntu' in product %}} | ||
<ind:textfilecontent54_test check="all" comment="audit {{{ mac_used }}}.d changes augenrules" id="test_armm_{{{ mac_used }}}d_watch_augenrules" version="1"> | ||
<ind:object object_ref="object_armm_{{{ mac_used }}}d_watch_augenrules" /> | ||
</ind:textfilecontent54_test> | ||
|
||
<ind:textfilecontent54_object id="object_armm_{{{ mac_used }}}d_watch_augenrules" version="1"> | ||
<ind:filepath operation="pattern match">^/etc/audit/rules\.d/.*\.rules$</ind:filepath> | ||
<ind:pattern operation="pattern match">^\-w[\s]+{{{ mac_path }}}\.d/[\s]+\-p[\s]+\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</ind:pattern> | ||
<ind:instance datatype="int">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
|
||
<ind:textfilecontent54_test check="all" comment="audit {{{ mac_used }}}.d changes auditctl" id="test_armm_{{{ mac_used }}}d_watch_auditctl" version="1"> | ||
<ind:object object_ref="object_armm_{{{ mac_used }}}d_watch_auditctl" /> | ||
</ind:textfilecontent54_test> | ||
|
||
<ind:textfilecontent54_object id="object_armm_{{{ mac_used }}}d_watch_auditctl" version="1"> | ||
<ind:filepath>/etc/audit/audit.rules</ind:filepath> | ||
<ind:pattern operation="pattern match">^\-w[\s]+/etc/selinux/[\s]+\-p[\s]+\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</ind:pattern> | ||
<ind:pattern operation="pattern match">^\-w[\s]+{{{ mac_path }}}\.d/[\s]+\-p[\s]+\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</ind:pattern> | ||
<ind:instance datatype="int">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
{{% endif %}} | ||
|
||
</def-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
.../auditing/auditd_configure_rules/audit_rules_mac_modification/tests/augen_correct.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
#!/bin/bash | ||
# packages = audit | ||
|
||
{{% if 'ubuntu' in product %}} | ||
echo "-w /etc/apparmor/ -p wa -k MAC-policy" > /etc/audit/rules.d/MAC-policy.rules | ||
echo "-w /etc/apparmor.d/ -p wa -k MAC-policy" >> /etc/audit/rules.d/MAC-policy.rules | ||
{{% else %}} | ||
echo "-w /etc/selinux/ -p wa -k MAC-policy" > /etc/audit/rules.d/MAC-policy.rules | ||
{{% endif %}} | ||
|
5 changes: 5 additions & 0 deletions
5
...ditd_configure_rules/audit_rules_mac_modification/tests/augen_correct_without_key.pass.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
#!/bin/bash | ||
# packages = audit | ||
|
||
{{% if 'ubuntu' in product %}} | ||
echo "-w /etc/apparmor/ -p wa" > /etc/audit/rules.d/MAC-policy.rules | ||
echo "-w /etc/apparmor.d/ -p wa" >> /etc/audit/rules.d/MAC-policy.rules | ||
{{% else %}} | ||
echo "-w /etc/selinux/ -p wa" > /etc/audit/rules.d/MAC-policy.rules | ||
{{% endif %}} |