<def-group>
  <definition class="compliance" id="{{{ rule_id }}}" version="2">
    {{{ oval_metadata("All world writable directories should be owned by root.") }}}
    <criteria negate="true">
      <criterion test_ref="test_dir_world_writable_uid_gt_zero"
        comment="check for local directories that are world writable and owner is not root"/>
    </criteria>
  </definition>

  <unix:file_test id="test_dir_world_writable_uid_gt_zero" check="all" version="1"
    comment="check for local directories that are world writable and have uid greater than 0">
    <unix:object object_ref="all_local_directories_uid_zero"/>
  </unix:file_test>

  <unix:file_object id="all_local_directories_uid_zero" version="1"
    comment="collect all local directories and filter them by uid and others write permission">
    <unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1"
      recurse_file_system="local"/>
    <unix:path operation="equals">/</unix:path>
    <unix:filename xsi:nil="true" />
    <filter action="include">state_uid_is_not_root_and_world_writable</filter>
  </unix:file_object>

  <unix:file_state id="state_uid_is_not_root_and_world_writable" version="1"
    comment="uid greater than 0 and world writable">
    <unix:user_id datatype="int" operation="greater than">0</unix:user_id>
    <unix:owrite datatype="boolean">true</unix:owrite>
  </unix:file_state>
</def-group>
