Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update file_permissions_unauthorized_world_writable #12791

Merged

Conversation

matusmarhefka
Copy link
Member

Update file_permissions_unauthorized_world_writable for bootable containers. Filter out the /sysroot directory from results because it contains only the physical read-only root and not the real file system, see https://containers.github.io/bootc/filesystem-sysroot.html#sysroot-mount.

Update file_permissions_unauthorized_world_writable for bootable containers.
Filter out the `/sysroot` directory from results because it contains only
the physical read-only root and not the real file system, see
https://containers.github.io/bootc/filesystem-sysroot.html#sysroot-mount.
@matusmarhefka matusmarhefka added the Image Mode Bootable containers and Image Mode RHEL label Jan 8, 2025
@matusmarhefka matusmarhefka added this to the 0.1.76 milestone Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

Copy link

github-actions bot commented Jan 8, 2025

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_unauthorized_world_writable' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_unauthorized_world_writable
+++ xccdf_org.ssgproject.content_rule_file_permissions_unauthorized_world_writable
@@ -1,11 +1,15 @@
 
 FILTER_NODEV=$(awk '/nodev/ { print $2 }' /proc/filesystems | paste -sd,)
-PARTITIONS=$(findmnt -n -l -k -it $FILTER_NODEV | awk '{ print $1 }')
+
+# Do not consider /sysroot partition because it contains only the physical
+# read-only root on bootable containers.
+PARTITIONS=$(findmnt -n -l -k -it $FILTER_NODEV | awk '{ print $1 }' | grep -v "/sysroot")
+
 for PARTITION in $PARTITIONS; do
   find "${PARTITION}" -xdev -type f -perm -002 -exec chmod o-w {} \; 2>/dev/null
 done
 
-# Ensure /tmp is also fixed whem tmpfs is used.
+# Ensure /tmp is also fixed when tmpfs is used.
 if grep "^tmpfs /tmp" /proc/mounts; then
   find /tmp -xdev -type f -perm -002 -exec chmod o-w {} \; 2>/dev/null
 fi

Copy link

codeclimate bot commented Jan 8, 2025

Code Climate has analyzed commit b7679cd and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 61.6% (0.0% change).

View more on Code Climate.

@jan-cerny jan-cerny self-assigned this Jan 8, 2025
Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have built a CS 9 data stream from this pull request branch. I have used this data stream to build a hardened bootable container image based on CS 9 using the CIS profile. I have booted the image using podman-bootc. I have run a scan of that machine. The rule xccdf_org.ssgproject.content_rule_file_permissions_unauthorized_world_writable has passed in the scan.

@jan-cerny jan-cerny merged commit 4f3a557 into ComplianceAsCode:master Jan 8, 2025
97 of 107 checks passed
@matusmarhefka matusmarhefka deleted the unauthorized_world_writable branch January 8, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Image Mode Bootable containers and Image Mode RHEL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants