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

accounts_umask_etc_bashrc: depend on bash being installed #10915

Conversation

candrews
Copy link
Contributor

Description:

accounts_umask_etc_bashrc: depend on bash being installed

Rationale:

/etc/bashrc is only used if bash is installed.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Jul 27, 2023
@openshift-ci
Copy link

openshift-ci bot commented Jul 27, 2023

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 /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/test-infra repository.

@github-actions
Copy link

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

@github-actions
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_accounts_umask_etc_bashrc' differs.
--- xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc
+++ xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc
@@ -1,3 +1,5 @@
+# Remediation is applicable only in certain platforms
+if rpm --quiet -q bash; then
 
 var_accounts_user_umask=''
 
@@ -11,3 +13,7 @@
 if ! [ $? -eq 0 ]; then
     echo "umask $var_accounts_user_umask" >> /etc/bashrc
 fi
+
+else
+    >&2 echo 'Remediation is not applicable, nothing was done'
+fi

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc' differs.
--- xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc
+++ xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc
@@ -1,3 +1,18 @@
+- name: Gather the package facts
+  package_facts:
+    manager: auto
+  tags:
+  - CCE-81036-6
+  - DISA-STIG-RHEL-08-020353
+  - NIST-800-53-AC-6(1)
+  - NIST-800-53-CM-6(a)
+  - PCI-DSSv4-8.6.1
+  - accounts_umask_etc_bashrc
+  - low_complexity
+  - low_disruption
+  - medium_severity
+  - no_reboot_needed
+  - restrict_strategy
 - name: XCCDF Value var_accounts_user_umask # promote to variable
   set_fact:
     var_accounts_user_umask: !!str 
@@ -12,6 +27,7 @@
   check_mode: true
   changed_when: false
   register: umask_replace
+  when: '"bash" in ansible_facts.packages'
   tags:
   - CCE-81036-6
   - DISA-STIG-RHEL-08-020353
@@ -30,7 +46,9 @@
     path: /etc/bashrc
     regexp: ^(\s*)umask(\s+).*
     replace: \g<1>umask\g<2>{{ var_accounts_user_umask }}
-  when: umask_replace.found > 0
+  when:
+  - '"bash" in ansible_facts.packages'
+  - umask_replace.found > 0
   tags:
   - CCE-81036-6
   - DISA-STIG-RHEL-08-020353
@@ -49,7 +67,9 @@
     create: true
     path: /etc/bashrc
     line: umask {{ var_accounts_user_umask }}
-  when: umask_replace.found == 0
+  when:
+  - '"bash" in ansible_facts.packages'
+  - umask_replace.found == 0
   tags:
   - CCE-81036-6
   - DISA-STIG-RHEL-08-020353

Platform has been changed for rule 'xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc'
--- xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc
+++ xccdf_org.ssgproject.content_rule_accounts_umask_etc_bashrc
@@ -1 +1 @@
-
+oval:ssg-package_bash:def:1

Mab879
Mab879 previously requested changes Jul 27, 2023
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.

Thanks for the PR! Please take look at the CI failures as they do appear to be valid (at least the GitHub Actions, save Fedora rawhide). Let me know any help.

/etc/bashrc is only used if bash is installed.

Signed-off-by: Craig Andrews <candrews@integralblue.com>
@candrews candrews force-pushed the content_rule_accounts_umask_etc_bashrc branch from 6330a77 to 25652b2 Compare July 27, 2023 22:08
@codeclimate
Copy link

codeclimate bot commented Jul 27, 2023

Code Climate has analyzed commit 25652b2 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 53.2% (0.0% change).

View more on Code Climate.

@candrews
Copy link
Contributor Author

Thanks for the PR! Please take look at the CI failures as they do appear to be valid (at least the GitHub Actions, save Fedora rawhide). Let me know any help.

I believe I have addressed that problem. Thank you for pointing it out!

@mildas
Copy link
Contributor

mildas commented Jul 28, 2023

/packit retest-failed

3 similar comments
@mildas
Copy link
Contributor

mildas commented Jul 28, 2023

/packit retest-failed

@jan-cerny
Copy link
Collaborator

/packit retest-failed

@jan-cerny
Copy link
Collaborator

/packit retest-failed

@jan-cerny jan-cerny self-assigned this Jul 31, 2023
@jan-cerny jan-cerny added this to the 0.1.70 milestone Jul 31, 2023
@jan-cerny jan-cerny dismissed Mab879’s stale review August 1, 2023 12:37

review addressed, the CI passes

@jan-cerny jan-cerny merged commit e46282a into ComplianceAsCode:master Aug 1, 2023
32 of 33 checks passed
@Mab879 Mab879 added the Update Rule Issues or pull requests related to Rules updates. label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ok-to-test Used by openshift-ci bot. Update Rule Issues or pull requests related to Rules updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants