-
Notifications
You must be signed in to change notification settings - Fork 685
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 umask bash and Ansible #11108
Fix umask bash and Ansible #11108
Conversation
The sed regex doesn't find correctly blanck spaces at the beginning of the configuration line Signed-off-by: Edgar Aguilar <edgar.aguilar@oracle.com>
This ensures bash handles correctly spaces at the beginning of the line Signed-off-by: Edgar Aguilar <edgar.aguilar@oracle.com>
The existing one is toot intrusive and could modify commented lines Signed-off-by: Edgar Aguilar <edgar.aguilar@oracle.com>
Hi @Xeicker. 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_accounts_umask_etc_profile' differs.
--- xccdf_org.ssgproject.content_rule_accounts_umask_etc_profile
+++ xccdf_org.ssgproject.content_rule_accounts_umask_etc_profile
@@ -5,7 +5,7 @@
readarray -t profile_files < <(find /etc/profile.d/ -type f -name '*.sh' -or -name 'sh.local')
for file in "${profile_files[@]}" /etc/profile; do
- grep -qE '^[^#]*umask' "$file" && sed -i "s/umask.*/umask $var_accounts_user_umask/g" "$file"
+ grep -qE '^[^#]*umask' "$file" && sed -i -E "s/^(\s*umask\s*)[0-7]+/\1$var_accounts_user_umask/g" "$file"
done
if ! grep -qrE '^[^#]*umask' /etc/profile*; then
bash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_umask_interactive_users' differs.
--- xccdf_org.ssgproject.content_rule_accounts_umask_interactive_users
+++ xccdf_org.ssgproject.content_rule_accounts_umask_interactive_users
@@ -2,7 +2,7 @@
while IFS= read -r dir; do
while IFS= read -r -d '' file; do
if [ "$(basename $file)" != ".bash_history" ]; then
- sed -i 's/^\([\s]*umask\s*\)/#\1/g' "$file"
+ sed -i 's/^\(\s*umask\s*\)/#\1/g' "$file"
fi
done < <(find $dir -maxdepth 1 -type f -name ".*" -print0)
done < <(awk -F':' '{ if ($3 >= 1000 && $3 != 65534) print $6}' /etc/passwd)
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_umask_interactive_users' differs.
--- xccdf_org.ssgproject.content_rule_accounts_umask_interactive_users
+++ xccdf_org.ssgproject.content_rule_accounts_umask_interactive_users
@@ -5,7 +5,7 @@
for dir in $(awk -F':' '{ if ($3 >= 1000 && $3 != 65534) print $6}' /etc/passwd); do
for file in $(find $dir -maxdepth 1 -type f -name ".*"); do
if [ "$(basename $file)" != ".bash_history" ]; then
- sed -i 's/^\([\s]*umask\s*\)/#\1/g' $file
+ sed -i 's/^\(\s*umask\s*\)/#\1/g' $file
fi
done
done |
.../system/accounts/accounts-session/user_umask/accounts_umask_interactive_users/bash/shared.sh
Show resolved
Hide resolved
Ansible uses a bash command, and the sed regex doesn't find correctly blanck spaces at the beginning of the configuration line Signed-off-by: Edgar Aguilar <edgar.aguilar@oracle.com>
Code Climate has analyzed commit cb18170 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.8% (0.0% change). View more on Code Climate. |
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.
Thanks
aa6f2f0
into
ComplianceAsCode:master
Description:
accounts_umask_etc_profile
&accounts_umask_interactive_users
Rationale:
accounts_umask_etc_profile
the sed command would modify also commented linesaccounts_umask_interactive_users
theumask
ocurrences that have leading spaces were being ignoredReview Hints:
accounts_umask_interactive_users
I added a automatus testaccounts_umask_etc_profile
I tested in this way:Whith existing regex:
Whith new regex: