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
sudo_custom_logfile: depend on sudo being installed #10316
sudo_custom_logfile: depend on sudo being installed #10316
Conversation
Hi @candrews. 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 Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
This datastream diff is auto generated by the check Click here to see the full diffbash remediation for rule 'xccdf_org.ssgproject.content_rule_sudo_custom_logfile' differs.
--- xccdf_org.ssgproject.content_rule_sudo_custom_logfile
+++ xccdf_org.ssgproject.content_rule_sudo_custom_logfile
@@ -1,4 +1,5 @@
-
+# Remediation is applicable only in certain platforms
+if rpm --quiet -q sudo; then
var_sudo_logfile=''
@@ -29,3 +30,7 @@
echo "Skipping remediation, /etc/sudoers failed to validate"
false
fi
+
+else
+ >&2 echo 'Remediation is not applicable, nothing was done'
+fi
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_sudo_custom_logfile' differs.
--- xccdf_org.ssgproject.content_rule_sudo_custom_logfile
+++ xccdf_org.ssgproject.content_rule_sudo_custom_logfile
@@ -1,3 +1,15 @@
+- name: Gather the package facts
+ package_facts:
+ manager: auto
+ tags:
+ - CCE-83601-5
+ - PCI-DSS-Req-10.2.1.5
+ - low_complexity
+ - low_disruption
+ - low_severity
+ - no_reboot_needed
+ - restrict_strategy
+ - sudo_custom_logfile
- name: XCCDF Value var_sudo_logfile # promote to variable
set_fact:
var_sudo_logfile: !!str
@@ -12,6 +24,7 @@
validate: /usr/sbin/visudo -cf %s
backrefs: true
register: edit_sudoers_logfile_option
+ when: '"sudo" in ansible_facts.packages'
tags:
- CCE-83601-5
- PCI-DSS-Req-10.2.1.5
@@ -27,7 +40,9 @@
path: /etc/sudoers
line: Defaults logfile={{ var_sudo_logfile }}
validate: /usr/sbin/visudo -cf %s
- when: edit_sudoers_logfile_option is defined and not edit_sudoers_logfile_option.changed
+ when:
+ - '"sudo" in ansible_facts.packages'
+ - edit_sudoers_logfile_option is defined and not edit_sudoers_logfile_option.changed
tags:
- CCE-83601-5
- PCI-DSS-Req-10.2.1.5
Platform has been changed for rule 'xccdf_org.ssgproject.content_rule_sudo_custom_logfile'
--- xccdf_org.ssgproject.content_rule_sudo_custom_logfile
+++ xccdf_org.ssgproject.content_rule_sudo_custom_logfile
@@ -1 +1 @@
-
+cpe:/a:sudo: |
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.
You need to put
# packages = sudo
to headers of all test scenarios files in this rule
sudo_custom_logfile only makes sense if sudo is installed, so it should express that with "platform: package[sudo]" as other rules (such as sudo_add_use_pty) already do. Signed-off-by: Craig Andrews <candrews@integralblue.com>
I didn't know about this, thank you. I've updated this PR accordingly. |
27c7200
to
e7fb3db
Compare
Code Climate has analyzed commit e7fb3db 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 51.7% (0.0% change). View more on Code Climate. |
Description:
sudo_custom_logfile: depend on sudo being installed
Rationale:
sudo_custom_logfile only makes sense if sudo is installed, so it should express that with "platform: package[sudo]" as other rules (such as sudo_add_use_pty) already do.
Review Hints:
With this change applied,
oscap-podman ubuntu:20.04 xccdf eval --report report.html --profile xccdf_org.ssgproject.content_profile_cis_level2_workstation /usr/share/xml/scap/ssg/content/ssg-ubuntu2004-ds.xml
should yield a report indicating that the "Ensure Sudo Logfile Exists - sudo logfile" rule is "Not Applicable"