-
Notifications
You must be signed in to change notification settings - Fork 717
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
[Ubuntu2404] Fix remediation of rule accounts_user_dot_user_ownership #13026
[Ubuntu2404] Fix remediation of rule accounts_user_dot_user_ownership #13026
Conversation
Hi @alanmcanonical. 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-sigs/prow repository. |
@dodys Please have a look. |
This datastream diff is auto generated by the check Click here to see the full diffbash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_user_dot_user_ownership' differs.
--- xccdf_org.ssgproject.content_rule_accounts_user_dot_user_ownership
+++ xccdf_org.ssgproject.content_rule_accounts_user_dot_user_ownership
@@ -1,2 +1,2 @@
-awk -F':' '{ if ($3 >= 1000 && $3 != 65534) system("chown -f " $3" "$6"/.[^\.]?*") }' /etc/passwd
+awk -F: '{if ($3 >= 1000 && $3 != 65534) print $3":"$6}' /etc/passwd | while IFS=: read -r uid home; do find "$home" -maxdepth 1 -name "\.[^.]*" -exec chown -f $uid "{}" \;; done
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_user_dot_user_ownership' differs.
--- xccdf_org.ssgproject.content_rule_accounts_user_dot_user_ownership
+++ xccdf_org.ssgproject.content_rule_accounts_user_dot_user_ownership
@@ -1,8 +1,9 @@
- name: Ensure interactive local users are the owners of their respective initialization
files
- ansible.builtin.command:
- cmd: awk -F':' '{ if ($3 >= 1000 && $3 != 65534) system("chown -f " $3" "$6"/.[^\.]?*")
- }' /etc/passwd
+ ansible.builtin.shell:
+ cmd: 'awk -F: ''{if ($3 >= 1000 && $3 != 65534) print $3":"$6}'' /etc/passwd |
+ while IFS=: read -r uid home; do find "$home" -maxdepth 1 -name "\.[^.]*" -exec
+ chown -f $uid "{}" \;; done'
tags:
- CCE-86316-7
- accounts_user_dot_user_ownership |
Change in Ansible Please consider using more suitable Ansible module than |
@@ -4,4 +4,4 @@ | |||
# complexity = low | |||
# disruption = low | |||
|
|||
awk -F':' '{ if ($3 >= {{{ uid_min }}} && $3 != {{{ nobody_uid }}}) system("chown -f " $3" "$6"/.[^\.]?*") }' /etc/passwd | |||
awk -F':' '{ if ($3 >= {{{ uid_min }}} && $3 != {{{ nobody_uid }}}) system("find "$6" -maxdepth 1 -name \.[^.]?* -exec chown -f "$3" {} \;") }' /etc/passwd |
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.
Is there any reason for the ?
in the regex? I think it should be \.[^.]*
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.
Maybe a mistake made by previous author
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.
If we want to exclude double dot files we should use \.[^.]*
Change in Ansible Please consider using more suitable Ansible module than |
c2289bd
to
a1eb65f
Compare
a1eb65f
to
a993c12
Compare
Change in Ansible Please consider using more suitable Ansible module than |
@mpurg Please review the latest changes |
Change in Ansible Please consider using more suitable Ansible module than |
Change in Ansible Please consider using more suitable Ansible module than |
ansible.builtin.(shell|command) is /bin/sh under the hood and it's soft link to dash in Ubuntu which doesn't support process substitution syntax. Step to prove:
|
Code Climate has analyzed commit bc7b620 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% (0.0% change). View more on Code Climate. |
@Mab879 @vojtapolasek could you take a look on this PR as it will also affect you, specifically the ansible. |
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.
lgtm, thanks!
Description:
Rationale:
man chown
, -f only suppress error msg. So replace the -f with -v (verbose) to debugawk -F':' '{ if ($3 >= 1000 && $3 != 65534) system("chown -v " $3" "$6"/.[^\.]?*") }' /etc/passwd
is: