8000 Fix set_password_hashing_min_rounds_logindefs by vojtapolasek · Pull Request #13004 · ComplianceAsCode/content · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged

Conversation

vojtapolasek
Copy link
Collaborator

Port of #12998 to master branch.

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.
@vojtapolasek vojtapolasek added bugfix Fixes to reported bugs. Ansible Ansible remediation update. Update Rule Issues or pull requests related to Rules updates. RHEL8 Red Hat Enterprise Linux 8 product related. STIG STIG Benchmark related. labels Feb 10, 2025
@vojtapolasek vojtapolasek added this to the 0.1.77 milestone Feb 10, 2025
@vojtapolasek vojtapolasek requested a review from a team as a code owner February 10, 2025 09:24
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_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

Copy link
codeclimate bot commented Feb 10, 2025

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.

@Mab879 Mab879 self-assigned this Feb 10, 2025
@Mab879 Mab879 modified the milestones: 0.1.77, 0.1.76 Feb 10, 2025
Copy link
Member
@Mab879 Mab879 left a 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!

@Mab879 Mab879 merged commit 0bb87a7 into ComplianceAsCode:master Feb 10, 2025
108 of 111 checks passed
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. RHEL8 Red Hat Enterprise Linux 8 product related. STIG STIG Benchmark related. Update Rule Issues or pull requests related to Rules updates.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0