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

Fix regular expression in Ansible remediation #9063

Merged
merged 1 commit into from
Jun 29, 2022

Conversation

jan-cerny
Copy link
Collaborator

Ansible remediation of accounts_umask_etc_profile breaks the
/etc/profile syntax because the regex in task "Replace user umask in
/etc/profile" is wrong. The regex in ansible.builtin.replace
module is considered multiline, it matches everything except hash sign
but including newlines, so it "eats" all the lines before the "umask"
string if these lines don't contain the hash sign.

Fixes: #9053

Ansible remediation of accounts_umask_etc_profile breaks the
/etc/profile syntax because the regex in task "Replace user umask in
/etc/profile" is wrong. The regex in ansible.builtin.replace
module is considered multiline, it matches everything except hash sign
but including newlines, so it "eats" all the lines before the "umask"
string if these lines don't contain the hash sign.

Fixes: ComplianceAsCode#9053
@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

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
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_umask_etc_profile' differs:
--- old datastream
+++ new datastream
@@ -27,8 +27,8 @@
 - name: Replace user umask in /etc/profile
 ansible.builtin.replace:
 path: /etc/profile
- regexp: ^[^#]*umask
- replace: umask {{ var_accounts_user_umask }}
+ regexp: ^(\s*)umask\s+\d+
+ replace: \1umask {{ var_accounts_user_umask }}
 tags:
 - CCE-81035-8
 - DISA-STIG-RHEL-08-020353

@codeclimate
Copy link

codeclimate bot commented Jun 29, 2022

Code Climate has analyzed commit d735420 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 42.7% (0.0% change).

View more on Code Climate.

@Mab879 Mab879 self-assigned this Jun 29, 2022
@Mab879 Mab879 added bugfix Fixes to reported bugs. Ansible Ansible remediation update. labels Jun 29, 2022
@Mab879 Mab879 merged commit da55c76 into ComplianceAsCode:master Jun 29, 2022
@Mab879 Mab879 added this to the 0.1.63 milestone Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. bugfix Fixes to reported bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ansible remediation of accounts_umask_etc_profile breaks the /etc/profile syntax
2 participants