<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 (Apparmor) 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 apparmor changes augenrules" test_ref="test_armm_apparmor_watch_augenrules" />
        <criterion comment="audit apparmor.d changes augenrules" test_ref="test_armm_apparmord_watch_augenrules" />
      </criteria>

      <!-- Test the auditctl case -->
      <criteria operator="AND">
        <extend_definition comment="audit auditctl" definition_ref="audit_rules_auditctl" />
        <criterion comment="audit apparmor changes auditctl" test_ref="test_armm_apparmor_watch_auditctl" />
        <criterion comment="audit apparmor.d changes auditctl" test_ref="test_armm_apparmord_watch_auditctl" />
      </criteria>

    </criteria>
  </definition>

  <ind:textfilecontent54_test check="all" comment="audit apparmor changes augenrules" id="test_armm_apparmor_watch_augenrules" version="1">
    <ind:object object_ref="object_armm_apparmor_watch_augenrules" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_armm_apparmor_watch_augenrules" version="1">
    <ind:filepath operation="pattern match">^/etc/audit/rules\.d/.*\.rules$</ind:filepath>
    <ind:pattern operation="pattern match">^\-w[\s]+/etc/apparmor/[\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 apparmor changes auditctl" id="test_armm_apparmor_watch_auditctl" version="1">
    <ind:object object_ref="object_armm_apparmor_watch_auditctl" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_armm_apparmor_watch_auditctl" version="1">
    <ind:filepath>/etc/audit/audit.rules</ind:filepath>
    <ind:pattern operation="pattern match">^\-w[\s]+/etc/apparmor/[\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 apparmor.d changes augenrules" id="test_armm_apparmord_watch_augenrules" version="1">
    <ind:object object_ref="object_armm_apparmord_watch_augenrules" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_armm_apparmord_watch_augenrules" version="1">
    <ind:filepath operation="pattern match">^/etc/audit/rules\.d/.*\.rules$</ind:filepath>
    <ind:pattern operation="pattern match">^\-w[\s]+/etc/apparmor\.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 apparmor.d changes auditctl" id="test_armm_apparmord_watch_auditctl" version="1">
    <ind:object object_ref="object_armm_apparmord_watch_auditctl" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_armm_apparmord_watch_auditctl" version="1">
    <ind:filepath>/etc/audit/audit.rules</ind:filepath>
    <ind:pattern operation="pattern match">^\-w[\s]+/etc/apparmor\.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>

</def-group>
