-
Notifications
You must be signed in to change notification settings - Fork 698
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
Extend mount_option_nodev_nonroot_local_partitions #12270
Conversation
Skipping CI for Draft Pull Request. |
This datastream diff is auto generated by the check Click here to see the full diffOVAL for rule 'xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions' differs.
--- oval:ssg-mount_option_nodev_nonroot_local_partitions:def:1
+++ oval:ssg-mount_option_nodev_nonroot_local_partitions:def:1
@@ -1,2 +1,3 @@
criteria AND
criterion oval:ssg-test_nodev_nonroot_local_partitions:tst:1
+criterion oval:ssg-test_nodev_nonroot_local_partitions_in_fstab:tst:1
bash remediation for rule 'xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions' differs.
--- xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions
+++ xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions
@@ -45,6 +45,9 @@
fi
done
+# Remediate unmounted /etc/fstab entries
+sed -i -E '/nodev/! s;^\s*(/dev/\S+|UUID=\S+)\s+(/\w\S*)\s+(\S+)\s+(\S+)(.*)$;\1 \2 \3 \4,nodev \5;' /etc/fstab
+
else
>&2 echo 'Remediation is not applicable, nothing was done'
fi
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions' differs.
--- xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions
+++ xccdf_org.ssgproject.content_rule_mount_option_nodev_nonroot_local_partitions
@@ -18,7 +18,8 @@
- mount_option_nodev_nonroot_local_partitions
- no_reboot_needed
-- name: Ensure non-root local partitions are mounted with nodev option
+- name: 'Add nodev Option to Non-Root Local Partitions: Ensure non-root local partitions
+ are mounted with nodev option'
mount:
path: '{{ item.mount }}'
src: '{{ item.device }}'
@@ -46,3 +47,26 @@
- medium_severity
- mount_option_nodev_nonroot_local_partitions
- no_reboot_needed
+
+- name: 'Add nodev Option to Non-Root Local Partitions: Ensure non-root local partitions
+ are present with nodev option in /etc/fstab'
+ ansible.builtin.replace:
+ path: /etc/fstab
+ regexp: ^\s*(?!#)(/dev/\S+|UUID=\S+)\s+(/\w\S*)\s+(\S+)\s+(?!nodev)(\S+)(.*)$
+ replace: \1 \2 \3 \4,nodev \5
+ when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
+ tags:
+ - CCE-82069-6
+ - DISA-STIG-RHEL-08-010580
+ - NIST-800-53-AC-6
+ - NIST-800-53-AC-6(1)
+ - NIST-800-53-CM-6(a)
+ - NIST-800-53-CM-7(a)
+ - NIST-800-53-CM-7(b)
+ - NIST-800-53-MP-7
+ - configure_strategy
+ - high_disruption
+ - low_complexity
+ - medium_severity
+ - mount_option_nodev_nonroot_local_partitions
+ - no_reboot_needed |
🤖 A k8s content image for this PR is available at: Click here to see how to deploy itIf you alread have Compliance Operator deployed: Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and: |
We are currently facing a problem that even though after this change the remediation fixes all items in There are possible solutions. Systemd generators will obey to whatever is written in |
f713e95
to
1c52e1b
Compare
The OVAL check is extended to read also data directly from the `/etc/fstab` file. This is useful in environments where the mount points are not mounted and OVAL partition objects don't matech. For example, this happens in the Image Builder environment. Similar to: ComplianceAsCode#10200 Resolves: RHEL-45018
I have improved the check so that it ignores the problematic special parts |
Code Climate has analyzed commit 3361f8c 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 59.4% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I tested the rule on a local VM and I also ran the test mentioned in the "Hints" section and I confirm that the problem is fixed when compared with the master branch.
I am waiving the CI because it seems there is no /etc/fstab in containers which are used for testing.
Description:
The OVAL check is extended to read also data directly from the
/etc/fstab
file. This is useful in environments where the mount points are not mounted and OVAL partition objects don't match. For example, this happens in the Image Builder environment.Similar to: #10200
Fixes: https://issues.redhat.com/browse/RHEL-45018
Review hints: