-
Notifications
You must be signed in to change notification settings - Fork 745
Fix set_password_hashing_min_rounds_logindefs #13004
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 set_password_hashing_min_rounds_logindefs #13004
Conversation
in RHEL 8 STIG, there was a wrong variable used for the rule set_password_hashing_min_rounds_logindefs. The variable was actually not included in the profile at all and therefore its default value of 5000 was used. However, stig requires values of 100000. Also, the variable var_password_pam_unix_rounds was used in the file, but in fact it is not used by any rule in the profile.It got removed to reduce confusion.
the regex was overly complicated and it did not match values as expected. Also conditionals were enhanced so that they check if variables containing values slurped from the file actually exist at all.
This datastream diff is auto generated by the check Click here to see the full diffansible remediation for rule 'xccdf_org.ssgproject.content_rule_set_password_hashing_min_rounds_logindefs' differs.
--- xccdf_org.ssgproject.content_rule_set_password_hashing_min_rounds_logindefs
+++ xccdf_org.ssgproject.content_rule_set_password_hashing_min_rounds_logindefs
@@ -55,11 +55,12 @@
has Minimum Value of 5000
ansible.builtin.replace:
path: /etc/login.defs
- regexp: (^\s*SHA_CRYPT_MIN_ROUNDS\s+)(?!(?:[5-9]\d{3,}|\d{5,}))\S*(\s*$)
+ regexp: (^\s*SHA_CRYPT_MIN_ROUNDS\s+)(?:\d+)(.*$)
replace: \g<1>{{ var_password_hashing_min_rounds_login_defs }}\g<2>
backup: false
- when: etc_login_defs_sha_crypt_min_rounds | length > 0 and etc_login_defs_sha_crypt_min_rounds
- | first | int < var_password_hashing_min_rounds_login_defs | int
+ when: etc_login_defs_sha_crypt_min_rounds is defined and etc_login_defs_sha_crypt_min_rounds
+ | length > 0 and etc_login_defs_sha_crypt_min_rounds | first | int < var_password_hashing_min_rounds_login_defs
+ | int
tags:
- CCE-89707-4
- DISA-STIG-RHEL-08-010130
@@ -74,11 +75,12 @@
has Minimum Value of 5000
ansible.builtin.replace:
path: /etc/login.defs
- regexp: (^\s*SHA_CRYPT_MAX_ROUNDS\s+)(?!(?:[5-9]\d{3,}|\d{5,}))\S*(\s*$)
+ regexp: (^\s*SHA_CRYPT_MAX_ROUNDS\s+)(?:\d+)(.*$)
replace: \g<1>{{ var_password_hashing_min_rounds_login_defs }}\g<2>
backup: false
- when: etc_login_defs_sha_crypt_max_rounds | length > 0 and etc_login_defs_sha_crypt_max_rounds
- | first | int < var_password_hashing_min_rounds_login_defs | int
+ when: etc_login_defs_sha_crypt_max_rounds is defined and etc_login_defs_sha_crypt_max_rounds
+ | length > 0 and etc_login_defs_sha_crypt_max_rounds | first | int < var_password_hashing_min_rounds_login_defs
+ | int
tags:
- CCE-89707-4
- DISA-STIG-RHEL-08-010130
@@ -89,7 +91,8 @@
- restrict_strategy
- set_password_hashing_min_rounds_logindefs
-- name: '{{ rule_title }} - SHA_CRYPT_MIN_ROUNDS add configuration if not found'
+- name: Set Password Hashing Rounds in /etc/login.defs - SHA_CRYPT_MIN_ROUNDS add
+ configuration if not found
ansible.builtin.lineinfile:
line: SHA_CRYPT_MIN_ROUNDS {{ var_password_hashing_min_rounds_login_defs }}
path: /etc/login.defs
@@ -105,7 +108,8 @@
- restrict_strategy
- set_password_hashing_min_rounds_logindefs
-- name: '{{ rule_title }} - SHA_CRYPT_MAX_ROUNDS add configuration if not found'
+- name: Set Password Hashing Rounds in /etc/login.defs - SHA_CRYPT_MAX_ROUNDS add
+ configuration if not found
ansible.builtin.lineinfile:
line: SHA_CRYPT_MAX_ROUNDS {{ var_password_hashing_min_rounds_login_defs }}
path: /etc/login.defs |
Code Climate has analyzed commit a633231 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. |
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.
I checked the #12998 is the same content.
Thanks!
Port of #12998 to master branch.