8000 Update bash_sudo_remove_config macro by mrkanon · Pull Request #13122 · ComplianceAsCode/content · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update bash_sudo_remove_config macro #13122

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 2 commits into from
Mar 3, 2025

Conversation

mrkanon
Copy link
Contributor
@mrkanon mrkanon commented Feb 27, 2025

Description:

Update bash_sudo_remove_config macro

Add new test for sudo_remove_nopasswd

Rationale:

This update modifies the command delimiter in bash_sudo_remove_config to handle cases where the user's commands in the file include the "/" character.

This update modifies the command delimiter to handle cases where the user's commands in the file include the / character

Signed-off-by: Armando Acosta <armando.acosta@oracle.com>
Signed-off-by: Armando Acosta <armando.acosta@oracle.com>
@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Feb 27, 2025
Copy link
openshift-ci bot commented Feb 27, 2025

Hi @mrkanon. 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.

Copy link

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_sudo_remove_no_authenticate' differs.
--- xccdf_org.ssgproject.content_rule_sudo_remove_no_authenticate
+++ xccdf_org.ssgproject.content_rule_sudo_remove_no_authenticate
@@ -7,7 +7,7 @@
   if ! test -z "$matching_list"; then
     while IFS= read -r entry; do
       # comment out "!authenticate" matches to preserve user data
-      sed -i "s/^${entry}$/# &/g" $f
+      sed -i "s|^${entry}$|# &|g" $f
     done <<< "$matching_list"
 
     /usr/sbin/visudo -cf $f &> /dev/null || echo "Fail to validate $f with visudo"

bash remediation for rule 'xccdf_org.ssgproject.content_rule_sudo_remove_nopasswd' differs.
--- xccdf_org.ssgproject.content_rule_sudo_remove_nopasswd
+++ xccdf_org.ssgproject.content_rule_sudo_remove_nopasswd
@@ -7,7 +7,7 @@
   if ! test -z "$matching_list"; then
     while IFS= read -r entry; do
       # comment out "NOPASSWD" matches to preserve user data
-      sed -i "s/^${entry}$/# &/g" $f
+      sed -i "s|^${entry}$|# &|g" $f
     done <<< "$matching_list"
 
     /usr/sbin/visudo -cf $f &> /dev/null || echo "Fail to validate $f with visudo"

bash remediation for rule 'xccdf_org.ssgproject.content_rule_sudo_require_authentication' differs.
--- xccdf_org.ssgproject.content_rule_sudo_require_authentication
+++ xccdf_org.ssgproject.content_rule_sudo_require_authentication
@@ -7,7 +7,7 @@
   if ! test -z "$matching_list"; then
     while IFS= read -r entry; do
       # comment out "NOPASSWD" matches to preserve user data
-      sed -i "s/^${entry}$/# &/g" $f
+      sed -i "s|^${entry}$|# &|g" $f
     done <<< "$matching_list"
 
     /usr/sbin/visudo -cf $f &> /dev/null || echo "Fail to validate $f with visudo"
@@ -22,7 +22,7 @@
   if ! test -z "$matching_list"; then
     while IFS= read -r entry; do
       # comment out "!authenticate" matches to preserve user data
-      sed -i "s/^${entry}$/# &/g" $f
+      sed -i "s|^${entry}$|# &|g" $f
     done <<< "$matching_list"
 
     /usr/sbin/visudo -cf $f &> /dev/null || echo "Fail to validate $f with visudo"

Copy link
codeclimate bot commented Feb 27, 2025

Code Climate has analyzed commit 330fa59 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 62.0% (0.0% change).

View more on Code Climate.

@jan-cerny jan-cerny added this to the 0.1.77 milestone Mar 3, 2025
@jan-cerny jan-cerny added the Bash Bash remediation update. label Mar 3, 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.

jcerny@fedora:~/work/git/scap-security-guide (pr/13122)$  python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 sudo_remove_nopasswd
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2025-03-03-1005/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_sudo_remove_nopasswd
INFO - Script correct_value.pass.sh using profile (all) OK
INFO - Script wrong_value.fail.sh using profile (all) OK
INFO - Script wrong_value_specific_commands.fail.sh using profile (all) OK
jcerny@fedora:~/work/git/scap-security-guide (pr/13122)$  python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --remediate-using ansible sudo_remove_nopasswd
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2025-03-03-1007/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_sudo_remove_nopasswd
INFO - Script correct_value.pass.sh using profile (all) OK
INFO - Script wrong_value.fail.sh using profile (all) OK
INFO - Script wrong_value_specific_commands.fail.sh using profile (all) OK

@jan-cerny jan-cerny self-assigned this Mar 3, 2025
@jan-cerny jan-cerny merged commit 5185c00 into ComplianceAsCode:master Mar 3, 2025
94 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bash Bash 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