From fb9b86927a46e507976ab65e3bf0eee291751338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= Date: Wed, 6 Nov 2024 14:48:48 +0100 Subject: [PATCH] Add new test scenarios Add new Automatus test scenarios for rule file_permissions_ungroupowned that cover recent changes - exclusion of /sysroot and addition of /usr/lib/group as second source of group data. --- .../tests/group_in_usr_lib.pass.sh | 12 ++++++++++++ .../tests/unowned_in_sysroot.pass.sh | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/group_in_usr_lib.pass.sh create mode 100644 linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/unowned_in_sysroot.pass.sh diff --git a/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/group_in_usr_lib.pass.sh b/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/group_in_usr_lib.pass.sh new file mode 100644 index 00000000000..2dba98f1f26 --- /dev/null +++ b/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/group_in_usr_lib.pass.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# +UNOWNED_FILES=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup) + +IFS=$"\n" +for f in $UNOWNED_FILES; do + rm -f "$f" +done + +touch /root/test +chown 9999:9999 /root/test +echo "testgroup:x:9999:" >> /usr/lib/group diff --git a/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/unowned_in_sysroot.pass.sh b/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/unowned_in_sysroot.pass.sh new file mode 100644 index 00000000000..a65499c6a64 --- /dev/null +++ b/linux_os/guide/system/permissions/files/file_permissions_ungroupowned/tests/unowned_in_sysroot.pass.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# remediation = none + +UNOWNED_FILES=$(df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup) + +IFS=$"\n" +for f in $UNOWNED_FILES; do + rm -f "$f" +done + +mkdir /sysroot +touch /sysroot/test +chown 9999:9999 /sysroot/test