



<def-group>
  <definition class="compliance" id="coreos_audit_option" version="2">
    <metadata>
        <title>Enable Auditing for Processes Which Start Prior to the Audit Daemon</title>
        
    <affected family="unix">
    <platform>Ubuntu 22.04</platform>
    </affected>
        <description>Ensure audit=1 argument is present in the 'options' line of /boot/loader/entries/ostree-2-*.conf (or ostree-1-*.conf if there is no ostree-2-*.conf as ostree has only two enries at the most, with *-2-*.conf entry always being the most recent). Also, ensure that kernel is currently running with this argument by checking /proc/cmdline.</description>
    </metadata>
    <criteria operator="AND">
      <criteria operator="OR">
        <criteria operator="AND"><criterion comment="Pass if there are no files matching pattern '/boot/loader/entries/ostree-2.*.conf' exist in the system" test_ref="test_coreos_audit_option_file_boot_loader_entries_ostree_2_conf_absent" /><criterion comment="Check if argument audit=1 for Linux kernel is present in /boot/loader/entries/ostree-1.*.conf"
  test_ref="test_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_1_conf" />
        </criteria>
        <criteria operator="AND"><criterion comment="Check if argument audit=1 for Linux kernel is present in /boot/loader/entries/ostree-2.*.conf"
  test_ref="test_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_2_conf" />
        </criteria>
      </criteria>
      <criteria operator="AND"><criterion comment="Check if argument audit=1 for Linux kernel is present in /proc/cmdline"
  test_ref="test_coreos_audit_option_audit_1_argument_in_proc_cmdline" />
      </criteria>
    </criteria>
  </definition><unix:file_test check="all" check_existence="none_exist" id="test_coreos_audit_option_file_boot_loader_entries_ostree_2_conf_absent"
  comment="Check if /boot/loader/entries/ostree-2.*.conf does not exist" version="1">
    <unix:object object_ref="object_coreos_audit_option_file_boot_loader_entries_ostree_2_conf_absent" />
  </unix:file_test>
  <unix:file_object id="object_coreos_audit_option_file_boot_loader_entries_ostree_2_conf_absent" version="1">
    <unix:filepath operation="pattern match">^/boot/loader/entries/ostree-2.*.conf</unix:filepath>
  </unix:file_object><ind:textfilecontent54_test id="test_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_1_conf"
  comment="Check if argument audit=1 is present in the line starting with 'options ' in /boot/loader/entries/ostree-1.*.conf"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_1_conf" />
    <ind:state state_ref="state_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_1_conf" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_1_conf" version="1">
    <ind:filepath operation="pattern match">^/boot/loader/entries/ostree-1.*.conf</ind:filepath>
    <ind:pattern operation="pattern match">^options (.*)$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
  <ind:textfilecontent54_state id="state_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_1_conf" version="1">
    <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?audit=1(?:\s.*)?$</ind:subexpression>
  </ind:textfilecontent54_state><ind:textfilecontent54_test id="test_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_2_conf"
  comment="Check if argument audit=1 is present in the line starting with 'options ' in /boot/loader/entries/ostree-2.*.conf"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_2_conf" />
    <ind:state state_ref="state_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_2_conf" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_2_conf" version="1">
    <ind:filepath operation="pattern match">^/boot/loader/entries/ostree-2.*.conf</ind:filepath>
    <ind:pattern operation="pattern match">^options (.*)$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
  <ind:textfilecontent54_state id="state_coreos_audit_option_audit_1_argument_in_boot_loader_entries_ostree_2_conf" version="1">
    <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?audit=1(?:\s.*)?$</ind:subexpression>
  </ind:textfilecontent54_state><ind:textfilecontent54_test id="test_coreos_audit_option_audit_1_argument_in_proc_cmdline"
  comment="Check if argument audit=1 is present in the line starting with 'BOOT_IMAGE' in /proc/cmdline"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_coreos_audit_option_audit_1_argument_in_proc_cmdline" />
    <ind:state state_ref="state_coreos_audit_option_audit_1_argument_in_proc_cmdline" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_coreos_audit_option_audit_1_argument_in_proc_cmdline" version="1">
    <ind:filepath operation="pattern match">^/proc/cmdline</ind:filepath>
    <ind:pattern operation="pattern match">^BOOT_IMAGE(.*)$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
  <ind:textfilecontent54_state id="state_coreos_audit_option_audit_1_argument_in_proc_cmdline" version="1">
    <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?audit=1(?:\s.*)?$</ind:subexpression>
  </ind:textfilecontent54_state>
</def-group>