8000 Update Ansible find task to report on broken symbolic links, matching STIG vulnerability scanning behavior by ev-not-eve · Pull Request #13386 · ComplianceAsCode/content · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update Ansible find task to report on broken symbolic links, matching STIG vulnerability scanning behavior #13386

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

Merged
merged 3 commits into from
Apr 25, 2025

Conversation

ev-not-eve
Copy link
Contributor

Description:

Changed Ansible task to allow the find command to follow symbolic links as per STIG rule V-230257

Rationale:

In the STIG baseline and in vulnerability scans such as the one used within Nessus/Tenable Security Center, this check uses "find -L ... ( -type l -o -type f )" instead of "find -type f". When a symbolic link targets a nonexistent file, the methodology used in the STIG benchmark and within vulnerability scans reports on the dangling symbolic link as a finding. The methodology used within this Ansible task will not report on the dangling symbolic link, nor will it fail or attempt to correct the permissions. Changing the Ansible task to match the text in the STIG check allows the task to fail upon encountering dangling symbolic links. Specifying "-L" as well as "-type l -o -type f" implements behavior in find where "-L" will follow symbolic links, and only report on them when they're broken. The end result is that both files and broken symbolic links will be reported on.

Some considerations: implementing behavior that causes a task to fail instead of correcting the finding is not preferred, but I personally think that a failed task is preferred over a pseudo-false-negative. A dangling symbolic link doesn't truly register as a finding in the spirit of the STIG rule, but as long as the body text of the rule and vulnerability scans follow their current logic, the symbolic links will register as a finding regardless. A failure, while not ideal, will at least alert implementers of something that will eventually register as a finding and allow them to correct for the missing link target.

Review Hints:

Testing behavior against a dangling symbolic link vs a correctly targeted one will show whether it fails on encountering the dangling link properly; comparing against the old methodology and against the text within the STIG rule itself will show that this methodology more closely aligns with the STIG text and with methodologies used in commercial vulnerability scans.

Copy link
openshift-ci bot commented Apr 23, 2025

Hi @ev-not-eve. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Apr 23, 2025
@jan-cerny jan-cerny self-assigned this Apr 24, 2025
@jan-cerny jan-cerny added this to the 0.1.77 milestone Apr 24, 2025
@jan-cerny jan-cerny added the Ansible Ansible remediation update. label Apr 24, 2025
…ortant_dirs/file_permissions_binary_dirs/ansible/shared.yml

Co-authored-by: Jan Černý <jcerny@redhat.com>
@ev-not-eve
Copy link
Contributor Author

Apologies for the unescaped characters; not familiar with the build process.

I'm working through the setup guide for a build/dev environment to test my changes against, so hopefully I can catch these issues myself in the future.

Copy link

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_file_permissions_binary_dirs' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_binary_dirs
+++ xccdf_org.ssgproject.content_rule_file_permissions_binary_dirs
@@ -1,6 +1,6 @@
 - name: Read list of world and group writable system executables
-  ansible.builtin.command: find /bin /usr/bin /usr/local/bin /sbin /usr/sbin /usr/local/sbin
-    /usr/libexec -perm /022 -type f
+  ansible.builtin.command: find -L /bin /usr/bin /usr/local/bin /sbin /usr/sbin /usr/local/sbin
+    /usr/libexec -perm /022 \( -type l -o -type f \)
   register: world_writable_library_files
   changed_when: false
   failed_when: false

Copy link

Change in Ansible shell module found.

Please consider using more suitable Ansible module than shell if possible.

Copy link
codeclimate bot commented Apr 24, 2025

Code Climate has analyzed commit a2b01c9 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.9%.

View more on Code Climate.

@ev-not-eve ev-not-eve requested a review from jan-cerny April 24, 2025 18:03
@jan-cerny jan-cerny merged commit f68ead5 into ComplianceAsCode:master Apr 25, 2025
93 of 98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. needs-ok-to-test Used by openshift-ci bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0