-
Notifications
You must be signed in to change notification settings - Fork 706
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
Changes in bash remediation for accounts_password_set_max_life_existi… #10268
Changes in bash remediation for accounts_password_set_max_life_existi… #10268
Conversation
…ng and accounts_password_set_min_life_existing
Hi @rumch-se. 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. |
Code Climate has analyzed commit 155c51b 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 51.7% (0.0% change). View more on Code Climate. |
Hello @marcusburghardt |
do | ||
passwd -q -x $((var_accounts_maximum_age_login_defs)) $i | ||
done | ||
while IFS= read -r line; do |
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.
@rumch-se , the only difference between the approach used by sle
and other products (jinja else
) is the command used to update the password policy. SUSE prefers passwd
while other products would use chage
. However, the approach to collect these accounts should be the same.
So, I propose to simplify this remediation by collecting the accounts just once and using the jinja conditional only for the passwd
and chage
command. In that case, I would personally prefer the approach used in else
. The awk
can be extended if necessary to test more conditions.
This would make the remediation simpler to maintain and read. Could you consider that, please?
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.
Hello @marcusburghardt
1/
I tried to use chage - but I had issues related to PAM (i.e. PAM blocked me to apply this change). With passwd I did not have these issues. I think that RedHat is not protected from this issue also.
2/
The second issue which I had was to apply the change via awk. When I did cat /etc/shadow - I had an account which had to be changed, but it remained unchanged i.e. awk did not take it in consideration. Now with the current approach I was able to apply changes for all accounts.
Have a nice day
Rumen
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.
Hello @marcusburghardt 1/ I tried to use chage - but I had issues related to PAM (i.e. PAM blocked me to apply this change). With passwd I did not have these issues. I think that RedHat is not protected from this issue also.
It is fine to use passwd
for sle
products. My point was to put only this inside jinja conditionals since the list of users can be shared among other distros.
2/ The second issue which I had was to apply the change via awk. When I did cat /etc/shadow - I had an account which had to be changed, but it remained unchanged i.e. awk did not take it in consideration. Now with the current approach I was able to apply changes for all accounts. Have a nice day Rumen
Could you provide an example, please? I believe the awk
command can be easily extended to cover more cases.
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.
Hello @marcusburghardt
The awk approach is not working correctly. Please see my message with attached files. The test_max_with_passwd.txt cover the case where we have a loop based on awk, and we do change with passwd. Only two accounts were changed!
With my approach I scan /etc/shadow ones (I do not collect accounts) and if during the scan there is a need of a change I do it.
...unts-restrictions/password_expiration/accounts_password_set_min_life_existing/bash/shared.sh
Outdated
Show resolved
Hide resolved
@rumch-se , could you also take a look in the Project Style Guide related to commit messages, please? |
Hello @marcusburghardt
With my version I change ALL accounts and I did not have the message about PAM. Have a nice day test_max_with_passwd.txt |
@rumch-se , it is intentional to not change |
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_password_set_max_life_existing' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_set_max_life_existing
+++ xccdf_org.ssgproject.content_rule_accounts_password_set_max_life_existing
@@ -2,7 +2,8 @@
var_accounts_maximum_age_login_defs=''
+while IFS= read -r i; do
+
+ chage -M $var_accounts_maximum_age_login_defs $i
-while IFS= read -r i; do
- chage -M $var_accounts_maximum_age_login_defs $i
done < <(awk -v var="$var_accounts_maximum_age_login_defs" -F: '(/^[^:]+:[^!*]/ && ($5 > var || $5 == "")) {print $1}' /etc/shadow)
bash remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_set_min_life_existing' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_set_min_life_existing
+++ xccdf_org.ssgproject.content_rule_accounts_password_set_min_life_existing
@@ -2,7 +2,8 @@
var_accounts_minimum_age_login_defs=''
+while IFS= read -r i; do
+
+ chage -m $var_accounts_minimum_age_login_defs $i
-while IFS= read -r i; do
- chage -m $var_accounts_minimum_age_login_defs $i
done < <(awk -v var="$var_accounts_minimum_age_login_defs" -F: '(/^[^:]+:[^!*]/ && ($4 < var || $4 == "")) {print $1}' /etc/shadow) |
Hello @marcusburghardt In my last commit I kept the usage of awk, but for SLE product I used passwd instead of chage. |
Correct @rumch-se . I am glad the it was helpful. I will do a final review, but it seems ready to be merged. Thanks. |
…ng and accounts_password_set_min_life_existing
Description:
Rationale:
Notes: Please address my message to Marcus Burghardt as developer of OVAL and Ansible parts for both rules.
1/
I think that both parts (Ansible and OVAL for both rules) need corrections, because ansible parts do not apply min/max age for all users.
On my test host they changed parameters for root and vagrant users, but not for users which have empty definitions for the age of their accounts.
When I applied ansible remediation for min_life - audit check had status pass - despite of the fact that only of two users min_age parameter was changed - i.e. OVAL part is not correct
When I applied ansible remediation for max_life - audit check had status fail
2/
The usage of awk - makes the code shorter, but in some cases I had issue to find users which have min_age 0 and to correct this value to the new one.