<def-group>
  <definition class="compliance" id="file_permissions_unauthorized_world_writable" version="1">
    {{{ oval_metadata("The world-write permission should be disabled for all files.") }}}
    <criteria>
      <criterion test_ref="test_file_permissions_unauthorized_world_write" />
    </criteria>
  </definition>
  <!-- NOTE: It is impossible for an OVAL check to determine which world writable files are authorized or not. -->
  <!-- This checks basically fails if any world writable files exist on the system. A default RHEL install -->
  <!-- does not have any world writable files but this many not be the case for other systems. It will be up to -->
  <!-- the system administrator to determine which world writable files are approved for use. -->
  <unix:file_test check="all" check_existence="none_exist" comment="world writable files" id="test_file_permissions_unauthorized_world_write" version="1">
    <unix:object object_ref="object_file_permissions_unauthorized_world_write" />
  </unix:file_test>
  <unix:file_object comment="world writable" id="object_file_permissions_unauthorized_world_write" version="1">
    <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" />
    <unix:path operation="equals">/</unix:path>
    <unix:filename operation="pattern match">^.*$</unix:filename>
    <filter action="include">state_file_permissions_unauthorized_world_write</filter>
    <!-- don't search /proc, /sys, and some special files from /selinux -->
    <filter action="exclude">state_file_permissions_unauthorized_world_write_exclude_special_selinux_files</filter>
    <filter action="exclude">state_file_permissions_unauthorized_world_write_exclude_proc</filter>
    <filter action="exclude">state_file_permissions_unauthorized_world_write_exclude_sys</filter>
  </unix:file_object>
  <unix:file_state id="state_file_permissions_unauthorized_world_write" version="1">
    <unix:type operation="equals">regular</unix:type>
    <unix:owrite datatype="boolean">true</unix:owrite>
  </unix:file_state>
  <unix:file_state id="state_file_permissions_unauthorized_world_write_exclude_special_selinux_files" version="1">
    <unix:filepath operation="pattern match">^/selinux/(?:(?:member)|(?:user)|(?:relabel)|(?:create)|(?:access)|(?:context))$</unix:filepath>
  </unix:file_state>
  <unix:file_state id="state_file_permissions_unauthorized_world_write_exclude_proc" version="1">
    <unix:filepath operation="pattern match">^/proc/.*$</unix:filepath>
  </unix:file_state>
  <unix:file_state id="state_file_permissions_unauthorized_world_write_exclude_sys" version="1">
    <unix:filepath operation="pattern match">^/sys/.*$</unix:filepath>
  </unix:file_state>
</def-group>
