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

Recollect facts in mount_option_nodev_nonroot_local_partitions #11941

Merged
merged 1 commit into from May 6, 2024

Conversation

jan-cerny
Copy link
Collaborator

@jan-cerny jan-cerny commented May 3, 2024

This patch changes the Ansible code for rule
mount_option_nodev_nonroot_local_partitions so that Ansible is forced to refresh facts about mount points right before running the Ansible Task for this rule. The data in facts that were collected at the beginning of the play can be outdated at point when this Ansible Task is executed if there is some other Ansible Task that changes mount points, for example if the Ansible Tasks for rule mount_option_boot_nosuid is before the Ansible Task for rule mount_option_nodev_nonroot_local_partitions.

Fixes: #11933

This patch changes the Ansible code for rule
mount_option_nodev_nonroot_local_partitions so that Ansible id forced to
refresh facts about mount points right before running the Ansible Task
for this rule.  The data in facts that were collected at the beginning
of the play can be outdated at point when this Ansible Task is executed
if there is some other Ansible Task that changes mount points, for
example if the Ansible Tasks for rule mount_option_boot_nosuid is before
the Ansible Task for rule mount_option_nodev_nonroot_local_partitions.

Fixes: ComplianceAsCode#11933
@jan-cerny jan-cerny added the productization-issue Issue found in upstream stabilization process. label May 3, 2024
Copy link

github-actions bot commented May 3, 2024

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 May 3, 2024

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

Click here to see the full diff
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
@@ -1,3 +1,23 @@
+- name: 'Add nodev Option to Non-Root Local Partitions: Refresh facts'
+  setup:
+    gather_subset: mounts
+  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
+
 - name: Ensure non-root local partitions are mounted with nodev option
   mount:
     path: '{{ item.mount }}'

Copy link

github-actions bot commented May 3, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11941
This image was built from commit: c5235f4

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:11941

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11941 make deploy-local

Copy link

codeclimate bot commented May 3, 2024

Code Climate has analyzed commit c5235f4 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.

@jan-cerny
Copy link
Collaborator Author

Hi, I think that Automatus CI fails jobs because it's using the container back end. They pass locally if I run them on a virtual machine back end.

@Mab879 Mab879 self-assigned this May 6, 2024
Copy link
Member

@Mab879 Mab879 left a comment

Choose a reason for hiding this comment

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

Automatus passes locally.

Thanks for the PR!

@Mab879 Mab879 added this to the 0.1.74 milestone May 6, 2024
@Mab879 Mab879 added the bugfix Fixes to reported bugs. label May 6, 2024
@Mab879 Mab879 merged commit 3d040e9 into ComplianceAsCode:master May 6, 2024
109 of 113 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes to reported bugs. productization-issue Issue found in upstream stabilization process.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mount_option_boot_nosuid fails to remediate with Ansible
2 participants