-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11319 from marcusburghardt/probe_file_system_rules
Improve Performance on rules probing the whole file system
- Loading branch information
Showing
17 changed files
with
495 additions
and
305 deletions.
There are no files selected for viewing
43 changes: 30 additions & 13 deletions
43
linux_os/guide/system/permissions/files/dir_perms_world_writable_sticky_bits/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
<def-group> | ||
<definition class="compliance" id="dir_perms_world_writable_sticky_bits" version="1"> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="2"> | ||
{{{ oval_metadata("The sticky bit should be set for all world-writable directories.") }}} | ||
<criteria> | ||
<criterion comment="all local world writable directories have sticky bit set" test_ref="test_dir_perms_world_writable_sticky_bits" negate="true" /> | ||
<criterion test_ref="test_dir_perms_world_writable_sticky_bits" | ||
comment="All local world-writable directories have sticky bit set"/> | ||
</criteria> | ||
</definition> | ||
<unix:file_test check="all" check_existence="all_exist" comment="all local world-writable directories have sticky bit set" id="test_dir_perms_world_writable_sticky_bits" version="1"> | ||
<unix:object object_ref="object_only_local_directories" /> | ||
<unix:state state_ref="state_world_writable_and_not_sticky" /> | ||
</unix:file_test> | ||
<unix:file_object comment="only local directories" id="object_only_local_directories" version="1"> | ||
<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_world_writable_and_not_sticky</filter> | ||
</unix:file_object> | ||
<unix:file_state id="state_world_writable_and_not_sticky" version="1"> | ||
|
||
<unix:file_state id="state_dir_perms_world_writable_sticky_bits" version="1"> | ||
<unix:sticky datatype="boolean">false</unix:sticky> | ||
<unix:owrite datatype="boolean">true</unix:owrite> | ||
</unix:file_state> | ||
|
||
{{%- set var_local_mount_points = "var_" ~ rule_id ~ "_local_mountpoints" -%}} | ||
{{{ create_local_mount_points_list(var_local_mount_points) }}} | ||
|
||
<!-- | ||
This file_object will only find files located in local and not special file systems. The | ||
recurse_file_system parameter is set to defined in order to make sure the probe doesn't | ||
leave the scope of that mount point. For example, when probing "/", the probe will ignore | ||
any child directory which is a mount point for any other partition. This will ensure | ||
considerable performance improvement. --> | ||
<unix:file_object id="object_dir_perms_world_writable_sticky_bits" version="1" | ||
comment="All world-writable directories without sticky bits"> | ||
<unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" | ||
recurse_file_system="defined"/> | ||
<unix:path operation="equals" var_check="at least one" | ||
var_ref="{{{ var_local_mount_points }}}"/> | ||
<unix:filename xsi:nil="true"/> | ||
<filter action="include">state_dir_perms_world_writable_sticky_bits</filter> | ||
</unix:file_object> | ||
|
||
<unix:file_test id="test_dir_perms_world_writable_sticky_bits" version="2" | ||
check="all" check_existence="none_exist" | ||
comment="Check the existence of world-writable directories without sticky bits"> | ||
<unix:object object_ref="object_dir_perms_world_writable_sticky_bits"/> | ||
</unix:file_test> | ||
</def-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 34 additions & 16 deletions
50
...x_os/guide/system/permissions/files/dir_perms_world_writable_system_owned/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
<def-group> | ||
<definition class="compliance" id="dir_perms_world_writable_system_owned" version="1"> | ||
{{{ oval_metadata("All world writable directories should be owned by a system user.") }}} | ||
<criteria comment="check for local directories that are world writable and have uid greater than or equal to {{{ auid }}}" negate="true"> | ||
<criterion comment="check for local directories that are world writable and have uid greater than or equal to {{{ auid }}}" test_ref="test_dir_world_writable_uid_gt_value" /> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="2"> | ||
{{{ oval_metadata("All world writable directories should be owned by a system account.") }}} | ||
<criteria> | ||
<criterion test_ref="test_dir_perms_world_writable_system_owned" | ||
comment="Check world-writable directories with uid greater than or equal to {{{ uid_min }}}"/> | ||
</criteria> | ||
</definition> | ||
<unix:file_test check="all" comment="check for local directories that are world writable and have uid greater than or equal to {{{ auid }}}" id="test_dir_world_writable_uid_gt_value" version="1"> | ||
<unix:object object_ref="all_local_directories_uid" /> | ||
<unix:state state_ref="state_uid_is_user_and_world_writable" /> | ||
</unix:file_test> | ||
<unix:file_object comment="all local directories" id="all_local_directories_uid" version="1"> | ||
<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_user_and_world_writable</filter> | ||
</unix:file_object> | ||
<unix:file_state comment="uid greater than or equal to {{{ auid }}} and world writable" id="state_uid_is_user_and_world_writable" version="1"> | ||
<unix:user_id datatype="int" operation="greater than or equal">{{{ auid }}}</unix:user_id> | ||
|
||
<unix:file_state id="state_dir_perms_world_writable_system_owned" version="1" | ||
comment="uid greater than or equal to {{{ uid_min }}} and world writable"> | ||
<unix:user_id datatype="int" operation="greater than or equal">{{{ uid_min }}}</unix:user_id> | ||
<unix:owrite datatype="boolean">true</unix:owrite> | ||
</unix:file_state> | ||
|
||
{{%- set var_local_mount_points = "var_" ~ rule_id ~ "_local_mountpoints" -%}} | ||
{{{ create_local_mount_points_list(var_local_mount_points) }}} | ||
|
||
<!-- | ||
This file_object will only find files located in local and not special file systems. The | ||
recurse_file_system parameter is set to defined in order to make sure the probe doesn't | ||
leave the scope of that mount point. For example, when probing "/", the probe will ignore | ||
any child directory which is a mount point for any other partition. This will ensure | ||
considerable performance improvement. --> | ||
<unix:file_object id="object_dir_perms_world_writable_system_owned" version="1" | ||
comment="All world-writable directories."> | ||
<unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" | ||
recurse_file_system="defined"/> | ||
<unix:path operation="equals" var_check="at least one" | ||
var_ref="{{{ var_local_mount_points }}}"/> | ||
<unix:filename xsi:nil="true"/> | ||
<filter action="include">state_dir_perms_world_writable_system_owned</filter> | ||
</unix:file_object> | ||
|
||
<unix:file_test id="test_dir_perms_world_writable_system_owned" version="2" | ||
check="all" check_existence="none_exist" | ||
comment="Check the existence of world-writable directories not owned by system accounts."> | ||
<unix:object object_ref="object_dir_perms_world_writable_system_owned"/> | ||
</unix:file_test> | ||
</def-group> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 56 additions & 32 deletions
88
linux_os/guide/system/permissions/files/file_permissions_unauthorized_sgid/oval/shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,77 @@ | ||
<def-group> | ||
<definition id="file_permissions_unauthorized_sgid" version="1" class="compliance"> | ||
<definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
{{{ oval_metadata("Evaluates to true if all files with SGID set are owned by RPM packages.") }}} | ||
<criteria> | ||
<criterion comment="Check all sgid files" test_ref="test_file_permissions_unauthorized_sgid"/> | ||
<criterion test_ref="test_file_permissions_unauthorized_sgid" | ||
comment="Check if all sgid files present in the system are authorized"/> | ||
</criteria> | ||
</definition> | ||
|
||
<unix:file_test check="all" check_existence="none_exist" comment="sgid files outside system RPMs" id="test_file_permissions_unauthorized_sgid" version="1"> | ||
<unix:object object_ref="obj_file_permissions_unauthorized_sgid_unowned" /> | ||
</unix:file_test> | ||
<!-- Collect all sgid files in the system. --> | ||
<unix:file_state id="state_file_permissions_unauthorized_sgid_set" version="1"> | ||
<unix:sgid datatype="boolean">true</unix:sgid> | ||
</unix:file_state> | ||
|
||
<unix:file_object comment="files with sgid set which are not owned by any RPM package" id="obj_file_permissions_unauthorized_sgid_unowned" version="1"> | ||
<unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" recurse_file_system="local" /> | ||
<unix:path operation="equals">/</unix:path> | ||
{{%- set var_local_mount_points = "var_" ~ rule_id ~ "_local_mountpoints" -%}} | ||
{{{ create_local_mount_points_list(var_local_mount_points) }}} | ||
|
||
<!-- This file_object will only find files located in local and not special file systems. The | ||
recurse_file_system parameter is set to defined in order to make sure the probe doesn't | ||
leave the scope of that mount point. For example, when probing "/", the probe will ignore | ||
any child directory which is a mount point for any other partition. This will ensure | ||
considerable performance improvement. --> | ||
<unix:file_object id="object_file_permissions_unauthorized_sgid_all_sgid_files" version="1" | ||
comment="all files with sgid set"> | ||
<unix:behaviors recurse="directories" recurse_direction="down" max_depth="-1" | ||
recurse_file_system="defined"/> | ||
<unix:path operation="equals" var_check="at least one" | ||
var_ref="{{{ var_local_mount_points }}}"/> | ||
<unix:filename operation="pattern match">^.*$</unix:filename> | ||
<filter action="include">state_file_permissions_unauthorized_sgid_sgid_set</filter> | ||
<filter action="exclude">state_file_permissions_unauthorized_sgid_filepaths</filter> | ||
<filter action="include">state_file_permissions_unauthorized_sgid_set</filter> | ||
</unix:file_object> | ||
|
||
<linux:rpmverifyfile_object id="obj_file_permissions_unauthorized_sgid_rpms" version="1" comment="all files with sgid set that come from a RPM package"> | ||
<linux:behaviors nolinkto="true" nomd5="true" nosize="true" nouser="true" nogroup="true" nomtime="true" nomode="true" nordev="true" /> | ||
<local_variable id="var_file_permissions_unauthorized_sgid_all_sgid_files" version="1" | ||
datatype="string" comment="all files with sgid set"> | ||
<object_component item_field="filepath" | ||
object_ref="object_file_permissions_unauthorized_sgid_all_sgid_files"/> | ||
</local_variable> | ||
|
||
<!-- Locate all rpm packages including located system sgid files. --> | ||
<linux:rpmverifyfile_object id="object_file_permissions_unauthorized_sgid_rpms" version="1" | ||
comment="all files with sgid set that come from a RPM package"> | ||
<linux:behaviors nolinkto="true" nomd5="true" nosize="true" nouser="true" nogroup="true" | ||
nomtime="true" nomode="true" nordev="true"/> | ||
<linux:name operation="pattern match">.*</linux:name> | ||
<linux:epoch operation="pattern match">.*</linux:epoch> | ||
<linux:version operation="pattern match">.*</linux:version> | ||
<linux:release operation="pattern match">.*</linux:release> | ||
<linux:arch operation="pattern match">.*</linux:arch> | ||
<linux:filepath var_ref="var_file_permissions_unauthorized_sgid_all" operation="equals" var_check="all" /> | ||
<linux:filepath operation="equals" var_check="all" | ||
var_ref="var_file_permissions_unauthorized_sgid_all_sgid_files"/> | ||
</linux:rpmverifyfile_object> | ||
|
||
<unix:file_object comment="all files with sgid set" id="obj_file_permissions_unauthorized_sgid_files" 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_sgid_sgid_set</filter> | ||
</unix:file_object> | ||
|
||
<unix:file_state id="state_file_permissions_unauthorized_sgid_sgid_set" version="1"> | ||
<unix:sgid datatype="boolean">true</unix:sgid> | ||
</unix:file_state> | ||
<!-- Extract the filepaths of rpm packages containing system sgid files. --> | ||
<local_variable id="var_file_permissions_unauthorized_sgid_rpms" version="1" | ||
datatype="string" comment="all files with sgid set that are managed by a RPM package"> | ||
<object_component item_field="filepath" | ||
object_ref="object_file_permissions_unauthorized_sgid_rpms"/> | ||
</local_variable> | ||
|
||
<unix:file_state id="state_file_permissions_unauthorized_sgid_filepaths" version="1"> | ||
<unix:filepath var_ref="var_file_permissions_unauthorized_sgid_rpms" var_check="at least one" /> | ||
</unix:file_state> | ||
<!-- Convert the local variable to a variable state which will be used below as a filter. --> | ||
<ind:variable_state id="state_file_permissions_unauthorized_sgid_rpm_filepaths" version="1"> | ||
<ind:value datatype="string" operation="equals" var_check="at least one" | ||
var_ref="var_file_permissions_unauthorized_sgid_rpms"/> | ||
</ind:variable_state> | ||
|
||
<local_variable id="var_file_permissions_unauthorized_sgid_rpms" datatype="string" version="1" comment="all files with sgid set that come from a RPM package"> | ||
<object_component item_field="filepath" object_ref="obj_file_permissions_unauthorized_sgid_rpms" /> | ||
</local_variable> | ||
<!-- Variable object containing only system sgid files not include in rpm packages. --> | ||
<ind:variable_object id="object_file_permissions_unauthorized_sgid_no_rpm_files" version="1"> | ||
<ind:var_ref>var_file_permissions_unauthorized_sgid_all_sgid_files</ind:var_ref> | ||
<filter action="exclude">state_file_permissions_unauthorized_sgid_rpm_filepaths</filter> | ||
</ind:variable_object> | ||
|
||
<local_variable id="var_file_permissions_unauthorized_sgid_all" datatype="string" version="1" comment="all files with sgid set"> | ||
<object_component item_field="filepath" object_ref="obj_file_permissions_unauthorized_sgid_files" /> | ||
</local_variable> | ||
<ind:variable_test id="test_file_permissions_unauthorized_sgid" version="1" | ||
check="all" check_existence="none_exist" | ||
comment="Check the existence of sgid files not included in rpm packages."> | ||
<ind:object object_ref="object_file_permissions_unauthorized_sgid_no_rpm_files"/> | ||
</ind:variable_test> | ||
</def-group> |
Oops, something went wrong.