<def-group>
  <definition class="compliance" id="audit_rules_mac_modification" version="1">
    <metadata>
      <title>Record Events that Modify the System's Mandatory Access Controls</title>
      <affected family="unix">
        <platform>Red Hat Enterprise Linux 7</platform>
        <platform>multi_platform_fedora</platform>
      </affected>
      <description>Audit rules that detect changes to the system's mandatory access controls (SELinux) are enabled.</description>
      <reference source="JL" ref_id="RHEL7_20150424" ref_url="test_attestation" />
      <reference source="JL" ref_id="FEDORA20_20150424" ref_url="test_attestation" />
    </metadata>

    <criteria operator="OR">

      <!-- Test the augenrules case -->
      <criteria operator="AND">
        <criterion comment="audit augenrules" test_ref="test_armm_augenrules" />
        <criterion comment="audit selinux changes augenrules" test_ref="test_armm_selinux_watch_augenrules" />
      </criteria>

      <!-- Test the auditctl case -->
      <criteria operator="AND">
        <criterion comment="audit auditctl" test_ref="test_armm_auditctl" />
        <criterion comment="audit selinux changes auditctl" test_ref="test_armm_selinux_watch_auditctl" />
      </criteria>

    </criteria>
  </definition>

  <!-- Test the augenrules case -->
  <ind:textfilecontent54_test check="all" comment="audit augenrules" id="test_armm_augenrules" version="1">
    <ind:object object_ref="object_armm_augenrules" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_armm_augenrules" version="1">
    <ind:filepath>/usr/lib/systemd/system/auditd.service</ind:filepath>
    <ind:pattern operation="pattern match">^ExecStartPost=\-\/sbin\/augenrules.*$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

  <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>
  <ind:textfilecontent54_object id="object_armm_selinux_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[\s]+\-k[\s]+[-\w]+[\s]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

  <!-- Test the auditctl case -->
  <ind:textfilecontent54_test check="all" comment="audit auditctl" id="test_armm_auditctl" version="1">
    <ind:object object_ref="object_armm_auditctl" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_armm_auditctl" version="1">
    <ind:filepath>/usr/lib/systemd/system/auditd.service</ind:filepath>
    <ind:pattern operation="pattern match">^ExecStartPost=\-\/sbin\/auditctl.*$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">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>
  <ind:textfilecontent54_object id="object_armm_selinux_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[\s]+\-k[\s]+[-\w]+[\s]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

</def-group>
