{{% macro audit_file_compare_criterion(file_id) %}}
      <criterion comment="check {{{ file_id }}}.rules file" test_ref="test_compare_{{{ file_id }}}_old" />
{{% endmacro %}}

{{% macro audit_file_compare_test(file_id) %}}
  <ind:textfilecontent54_test check="all" check_existence="all_exist"
  comment="Compare {{{ file_id }}}.rules file in /etc/audit/rules.d against file in /usr/share/doc/audit/"
  id="test_compare_{{{ file_id }}}_old" version="1">
    <ind:object object_ref="object_etc_{{{ file_id }}}_old" />
    <ind:state state_ref="state_doc_{{{ file_id }}}" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_etc_{{{ file_id }}}_old" version="1">
    <ind:filepath>/etc/audit/rules.d/{{{ file_id }}}.rules</ind:filepath>
    <ind:pattern operation="pattern match">(?:.*\n)*</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
  <ind:textfilecontent54_state id="state_doc_{{{ file_id }}}" version="1">
    <ind:text operation="equals" var_check="all"
    var_ref="var_doc_{{{ file_id }}}" />
  </ind:textfilecontent54_state>
  <local_variable datatype="string"
  comment="Contents of reference file in /usr/share/doc/{{{ file_id }}}.rules"
  id="var_doc_{{{ file_id }}}" version="1">
    <object_component item_field="text" object_ref="object_doc_{{{ file_id }}}" />
  </local_variable>
  <ind:textfilecontent54_object id="object_doc_{{{ file_id }}}" version="1">
    <ind:filepath operation="pattern match">^/usr/share/doc/audit(?:-\d.\d.\d)?/rules/{{{ file_id }}}.rules</ind:filepath>
    <ind:pattern operation="pattern match">(?:.*\n)*</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
{{% endmacro %}}

<def-group>
  <definition class="compliance" id="audit_rules_for_ospp" version="1">
    {{{ oval_metadata("Compare configure audit rules against the recommended pre-configured files.") }}}

    <criteria operator="AND">
      {{{- audit_file_compare_criterion("10-base-config") -}}}
      {{{- audit_file_compare_criterion("11-loginuid") -}}}
      {{{- audit_file_compare_criterion("30-ospp-v42") -}}}
      {{{- audit_file_compare_criterion("43-module-load") -}}}
    </criteria>
  </definition>

    {{{ audit_file_compare_test("10-base-config") }}}
    {{{ audit_file_compare_test("11-loginuid") }}}
    {{{ audit_file_compare_test("30-ospp-v42") }}}
    {{{ audit_file_compare_test("43-module-load") }}}

</def-group>
