{{% set audisp_config_file_path = audisp_conf_path + "/audisp-remote.conf" %}}
{{% set auremoteconfig = audisp_conf_path + "/plugins.d/au-remote.conf" %}}
<def-group>
  <definition class="compliance" id="auditd_audispd_configure_remote_server" version="1">
    {{{ oval_metadata("remote_server setting in " + audisp_config_file_path + " is set to a certain IP address or hostname") }}}
    <criteria>
        <criterion comment="remote_server setting in audisp-remote.conf" test_ref="test_auditd_audispd_configure_remote_server" />
        {{% if 'ubuntu' in product %}}
        <criterion comment="active setting in au-remote.conf" test_ref="test_auremote_config" />
        {{% endif %}}
    </criteria>
  </definition>

  <ind:textfilecontent54_test check="all" comment="remote server to send audit records" id="test_auditd_audispd_configure_remote_server" version="1">
    <ind:object object_ref="object_auditd_audispd_configure_remote_server" />
    <ind:state state_ref="state_auditd_audispd_configure_remote_server" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_auditd_audispd_configure_remote_server" version="1">
    <ind:filepath>{{{ audisp_config_file_path }}}</ind:filepath>
    <!-- Allow only space (exactly) as delimiter -->
    <!-- Require at least one space before and after the equal sign -->
    <ind:pattern operation="pattern match">^[ ]*(?i)remote_server(?-i)[ ]+=[ ]+(\S+)[ ]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_state id="state_auditd_audispd_configure_remote_server" version="1">
    <ind:subexpression operation="equals" var_ref="var_audispd_remote_server" />
  </ind:textfilecontent54_state>

  <external_variable comment="audispd remote_server setting" datatype="string" id="var_audispd_remote_server" version="1" />

  {{% if 'ubuntu' in product %}}
  <ind:textfilecontent54_test check="all" comment="Check that records are offloaded to a remote server" id="test_auremote_config" version="1">
    <ind:object object_ref="object_au_remote_config" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_au_remote_config" version="1">
    <ind:filepath>{{{ auremoteconfig }}}</ind:filepath>
    <ind:pattern operation="pattern match">^[ ]*(?i)active(?-i)[ ]+=[ ]+(yes)[ ]*$</ind:pattern>
    <ind:instance datatype="int">1</ind:instance>
  </ind:textfilecontent54_object>
  {{% endif %}}

</def-group>
