Skip to content
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

ctest lint fixes #10348

Merged
merged 35 commits into from
Mar 30, 2023
Merged

ctest lint fixes #10348

merged 35 commits into from
Mar 30, 2023

Conversation

maage
Copy link
Contributor

@maage maage commented Mar 21, 2023

Description:

When testing with -DANSIBLE_PLAYBOOKS_PER_RULE_ENABLED=ON -DANSIBLE_CHECKS=ON there was regression. This patchset fixes some of regressions and then comments out rest I decided are not worth not fix now.

Rationale:

This allows me to run full ctest run and all tests pass for all products.
Update: Almost. Because of some rules are harded to check I have dropped some patches and there can be some issues.

This should allow to keep reasonable and similar style within all ansible files. And then later it allows to do bigger refactorings with fqcn and jinja spacing for example. I selected most ansible-lint rules to skip based on issue numbers, so only low number cases were fixed. name[template] is added just because I dont't like the rule especially with this kind of sprawling code base with templates and all kinds of cases.

Long lines are not fully fixed because some are ssg template comments and not fixable as is. And also some other points would require not simple fixes. I tried to balance this and then added rule as skipped.

Review Hints:

Somehow different pyyaml versions have different serialization formats. So I implemented generic EOL tidy and then kludge to select implementation based on how it output problematic output. This is only tested on Fedora 37.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Mar 21, 2023
@openshift-ci
Copy link

openshift-ci bot commented Mar 21, 2023

Hi @maage. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@Mab879
Copy link
Member

Mab879 commented Mar 21, 2023

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Used by openshift-ci bot. and removed needs-ok-to-test Used by openshift-ci bot. labels Mar 21, 2023
@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@github-actions
Copy link

github-actions bot commented Mar 21, 2023

This datastream diff is auto generated by the check Compare DS/Generate Diff.
Due to the excessive size of the diff, it has been trimmed to fit the 65535-character limit.

Click here to see the trimmed diff
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_configure_openssl_crypto_policy' differs.
--- xccdf_org.ssgproject.content_rule_configure_openssl_crypto_policy
+++ xccdf_org.ssgproject.content_rule_configure_openssl_crypto_policy
@@ -1,7 +1,7 @@
 - name: Test for crypto_policy group
 command: grep '^\s*\[\s*crypto_policy\s*]' /etc/pki/tls/openssl.cnf
 register: test_crypto_policy_group
- ignore_errors: true
+ failed_when: test_crypto_policy_group.rc not in [0, 1]
 changed_when: false
 check_mode: false
 tags:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_nails_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_nails_enabled
+++ xccdf_org.ssgproject.content_rule_service_nails_enabled
@@ -6,7 +6,7 @@
 manager: auto
 
 - name: Enable service nails
- service:
+ systemd:
 name: nails
 enabled: 'yes'
 state: started

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_ensure_gpgcheck_never_disabled' differs.
--- xccdf_org.ssgproject.content_rule_ensure_gpgcheck_never_disabled
+++ xccdf_org.ssgproject.content_rule_ensure_gpgcheck_never_disabled
@@ -3,7 +3,7 @@
 set -o pipefail
 grep -HEr '^\[.+\]' -r /etc/yum.repos.d/
 register: repo_grep_results
- ignore_errors: true
+ failed_when: repo_grep_results.rc not in [0, 1]
 changed_when: false
 tags:
 - CCE-80792-5

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_enable_authselect' differs.
--- xccdf_org.ssgproject.content_rule_enable_authselect
+++ xccdf_org.ssgproject.content_rule_enable_authselect
@@ -7,8 +7,8 @@
 - name: Select authselect profile
 ansible.builtin.command:
 cmd: authselect select "{{ var_authselect_profile }}"
- ignore_errors: true
 register: result_authselect_select
+ failed_when: result_authselect_select.rc not in [0, 4]
 tags:
 - CCE-88248-0
 - NIST-800-53-AC-3
@@ -24,6 +24,9 @@
 cmd: rpm -qV pam
 register: result_altered_authselect
 ignore_errors: true
+ failed_when: result_altered_authselect.rc not in [0, 1]
+ args:
+ warn: false
 when: result_authselect_select is failed
 tags:
 - CCE-88248-0

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_display_login_attempts' differs.
--- xccdf_org.ssgproject.content_rule_display_login_attempts
+++ xccdf_org.ssgproject.content_rule_display_login_attempts
@@ -60,13 +60,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Ensure PAM Displays Last Logon/Access Notification - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -232,8 +232,12 @@
 changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -266,8 +270,9 @@
 cmd: authselect apply-changes -b
 when:
 - result_authselect_present.stat.exists
- - (result_pam_showfailed_add is defined and result_pam_showfailed_add.changed)
- or (result_pam_showfailed_edit is defined and result_pam_showfailed_edit.changed)
+ - |-
+ (result_pam_showfailed_add is defined and result_pam_showfailed_add.changed)
+ or (result_pam_showfailed_edit is defined and result_pam_showfailed_edit.changed)
 when:
 - '"pam" in ansible_facts.packages'
 - result_pam_file_present.stat.exists
@@ -330,13 +335,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Ensure PAM Displays Last Logon/Access Notification - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_account_passwords_pam_faillock_audit' differs.
--- xccdf_org.ssgproject.content_rule_account_passwords_pam_faillock_audit
+++ xccdf_org.ssgproject.content_rule_account_passwords_pam_faillock_audit
@@ -21,13 +21,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Account Lockouts Must Be Logged - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -202,13 +202,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Account Lockouts Must Be Logged - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -369,13 +369,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Account Lockouts Must Be Logged - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_remember_password_auth' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_remember_password_auth
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_remember_password_auth
@@ -80,13 +80,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: password-auth - Informative message based on the
 authselect integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -165,13 +165,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: password-auth - Informative message based on the
 authselect integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -335,8 +335,12 @@
 - name: 'Limit Password Reuse: password-auth - Ensure authselect changes are applied'
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -427,13 +431,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: password-auth - Informative message based on
 the authselect integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile
@@ -609,13 +613,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: password-auth - Informative message based on the
 authselect integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -776,8 +780,12 @@
 - name: 'Limit Password Reuse: password-auth - Ensure authselect changes are applied'
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_remember_system_auth' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_remember_system_auth
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_remember_system_auth
@@ -80,13 +80,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: system-auth - Informative message based on the authselect
 integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -165,13 +165,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: system-auth - Informative message based on the
 authselect integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -335,8 +335,12 @@
 - name: 'Limit Password Reuse: system-auth - Ensure authselect changes are applied'
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -427,13 +431,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: system-auth - Informative message based on
 the authselect integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile
@@ -608,13 +612,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: 'Limit Password Reuse: system-auth - Informative message based on the
 authselect integrity check result'
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -775,8 +779,12 @@
 - name: 'Limit Password Reuse: system-auth - Ensure authselect changes are applied'
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_remember' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_remember
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_remember
@@ -69,13 +69,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Limit Password Reuse - Informative message based on the authselect integrity
 check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -149,13 +149,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Limit Password Reuse - Informative message based on the authselect integrity
 check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -315,8 +315,12 @@
 - name: Limit Password Reuse - Ensure authselect changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -400,13 +404,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Limit Password Reuse - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile
@@ -573,13 +577,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Limit Password Reuse - Informative message based on the authselect integrity
 check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -738,8 +742,12 @@
 - name: Limit Password Reuse - Ensure authselect changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_audit' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_audit
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_audit
@@ -22,13 +22,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Account Lockouts Must Be Logged - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -207,13 +207,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Account Lockouts Must Be Logged - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -374,13 +374,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Account Lockouts Must Be Logged - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny
@@ -47,13 +47,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Lock Accounts After Failed Password Attempts - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -263,13 +263,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Lock Accounts After Failed Password Attempts - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -435,13 +435,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Lock Accounts After Failed Password Attempts - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny_root' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny_root
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_deny_root
@@ -43,13 +43,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Configure the root Account for Failed Password Attempts - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -247,13 +247,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Configure the root Account for Failed Password Attempts - Informative
 message based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -419,13 +419,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Configure the root Account for Failed Password Attempts - Informative
 message based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
@@ -40,13 +40,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Lock Accounts Must Persist - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -240,13 +240,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Lock Accounts Must Persist - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -404,13 +404,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Lock Accounts Must Persist - Informative message based on the authselect
 integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_enforce_local' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_enforce_local
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_enforce_local
@@ -37,13 +37,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Enforce pam_faillock for Local Accounts Only - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -228,13 +228,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Enforce pam_faillock for Local Accounts Only - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -400,13 +400,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Enforce pam_faillock for Local Accounts Only - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_interval' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_interval
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_interval
@@ -41,13 +41,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set Interval For Counting Failed Password Attempts - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -246,13 +246,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set Interval For Counting Failed Password Attempts - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -418,13 +418,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set Interval For Counting Failed Password Attempts - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_silent' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_silent
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_silent
@@ -37,13 +37,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Do Not Show System Messages When Unsuccessful Logon Attempts Occur - Informative
 message based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_unlock_time' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_unlock_time
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_unlock_time
@@ -47,13 +47,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set Lockout Time for Failed Password Attempts - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not
@@ -263,13 +263,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set Lockout Time for Failed Password Attempts - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -435,13 +435,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set Lockout Time for Failed Password Attempts - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_pwquality_password_auth' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_pwquality_password_auth
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_pwquality_password_auth
@@ -52,13 +52,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Ensure PAM password complexity module is enabled in password-auth - Informative
 message based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -225,8 +225,12 @@
 authselect changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -237,8 +241,9 @@
 cmd: authselect apply-changes -b
 when:
 - result_authselect_present.stat.exists
- - (result_pam__add is defined and result_pam__add.changed) or (result_pam__edit
- is defined and result_pam__edit.changed)
+ - |-
+ (result_pam__add is defined and result_pam__add.changed)
+ or (result_pam__edit is defined and result_pam__edit.changed)
 when:
 - '"pam" in ansible_facts.packages'
 - result_pam_file_present.stat.exists

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_pwquality_system_auth' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_pwquality_system_auth
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_pwquality_system_auth
@@ -52,13 +52,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Ensure PAM password complexity module is enabled in system-auth - Informative
 message based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -225,8 +225,12 @@
 authselect changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -237,8 +241,9 @@
 cmd: authselect apply-changes -b
 when:
 - result_authselect_present.stat.exists
- - (result_pam__add is defined and result_pam__add.changed) or (result_pam__edit
- is defined and result_pam__edit.changed)
+ - |-
+ (result_pam__add is defined and result_pam__add.changed)
+ or (result_pam__edit is defined and result_pam__edit.changed)
 when:
 - '"pam" in ansible_facts.packages'
 - result_pam_file_present.stat.exists

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_retry' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_retry
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_retry
@@ -87,14 +87,14 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Ensure PAM Enforces Password Requirements - Authentication Retry Prompts
 Permitted Per-Session - Informative message based on the authselect integrity
 check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -295,14 +295,14 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Ensure PAM Enforces Password Requirements - Authentication Retry Prompts
 Permitted Per-Session - Informative message based on the authselect integrity
 check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_set_password_hashing_algorithm_passwordauth' differs.
--- xccdf_org.ssgproject.content_rule_set_password_hashing_algorithm_passwordauth
+++ xccdf_org.ssgproject.content_rule_set_password_hashing_algorithm_passwordauth
@@ -64,13 +64,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set PAM's Password Hashing Algorithm - password-auth - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -235,8 +235,12 @@
 changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -269,8 +273,9 @@
 cmd: authselect apply-changes -b
 when:
 - result_authselect_present.stat.exists
- - (result_pam_sha512_add is defined and result_pam_sha512_add.changed) or (result_pam_sha512_edit
- is defined and result_pam_sha512_edit.changed)
+ - |-
+ (result_pam_sha512_add is defined and result_pam_sha512_add.changed)
+ or (result_pam_sha512_edit is defined and result_pam_sha512_edit.changed)
 when:
 - '"pam" in ansible_facts.packages'
 - result_pam_file_present.stat.exists

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_set_password_hashing_algorithm_systemauth' differs.
--- xccdf_org.ssgproject.content_rule_set_password_hashing_algorithm_systemauth
+++ xccdf_org.ssgproject.content_rule_set_password_hashing_algorithm_systemauth
@@ -64,13 +64,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set PAM's Password Hashing Algorithm - Informative message based on the
 authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -231,8 +231,12 @@
 - name: Set PAM's Password Hashing Algorithm - Ensure authselect changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -264,8 +268,9 @@
 cmd: authselect apply-changes -b
 when:
 - result_authselect_present.stat.exists
- - (result_pam_sha512_add is defined and result_pam_sha512_add.changed) or (result_pam_sha512_edit
- is defined and result_pam_sha512_edit.changed)
+ - |-
+ (result_pam_sha512_add is defined and result_pam_sha512_add.changed)
+ or (result_pam_sha512_edit is defined and result_pam_sha512_edit.changed)
 when:
 - '"pam" in ansible_facts.packages'
 - result_pam_file_present.stat.exists

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_debug-shell_disabled' differs.
--- xccdf_org.ssgproject.content_rule_service_debug-shell_disabled
+++ xccdf_org.ssgproject.content_rule_service_debug-shell_disabled
@@ -1,13 +1,20 @@
-- name: Disable service debug-shell
+- name: Block Disable service debug-shell
 block:
 
 - name: Disable service debug-shell
- systemd:
- name: debug-shell.service
- enabled: 'no'
- state: stopped
- masked: 'yes'
- ignore_errors: 'yes'
+ block:
+
+ - name: Disable service debug-shell
+ systemd:
+ name: debug-shell.service
+ enabled: 'no'
+ state: stopped
+ masked: 'yes'
+ rescue:
+
+ - name: Intentionally ignored previous 'Disable service debug-shell' failure,
+ service was already disabled
+ meta: noop
 when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-80876-6
@@ -25,7 +32,7 @@
 command: systemctl list-unit-files debug-shell.socket
 register: socket_file_exists
 changed_when: false
- ignore_errors: true
+ failed_when: socket_file_exists.rc not in [0, 1]
 check_mode: false
 when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_require_emergency_target_auth' differs.
--- xccdf_org.ssgproject.content_rule_require_emergency_target_auth
+++ xccdf_org.ssgproject.content_rule_require_emergency_target_auth
@@ -1,4 +1,4 @@
-- name: require emergency mode password
+- name: Require emergency mode password
 lineinfile:
 create: true
 dest: /usr/lib/systemd/system/emergency.service

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_require_singleuser_auth' differs.
--- xccdf_org.ssgproject.content_rule_require_singleuser_auth
+++ xccdf_org.ssgproject.content_rule_require_singleuser_auth
@@ -1,4 +1,4 @@
-- name: require single user mode password
+- name: Require single user mode password
 lineinfile:
 create: true
 dest: /usr/lib/systemd/system/rescue.service

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_pcscd_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_pcscd_enabled
+++ xccdf_org.ssgproject.content_rule_service_pcscd_enabled
@@ -6,7 +6,7 @@
 manager: auto
 
 - name: Start service pcscd
- service:
+ systemd:
 name: pcscd
 state: started
 masked: 'no'

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_rounds_password_auth' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_rounds_password_auth
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_rounds_password_auth
@@ -55,13 +55,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set number of Password Hashing Rounds - password-auth - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -226,8 +226,12 @@
 changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -271,8 +275,9 @@
 cmd: authselect apply-changes -b
 when:
 - result_authselect_present.stat.exists
- - (result_pam_rounds_add is defined and result_pam_rounds_add.changed) or (result_pam_rounds_edit
- is defined and result_pam_rounds_edit.changed)
+ - |-
+ (result_pam_rounds_add is defined and result_pam_rounds_add.changed)
+ or (result_pam_rounds_edit is defined and result_pam_rounds_edit.changed)
 when:
 - '"pam" in ansible_facts.packages'
 - result_pam_file_present.stat.exists

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_rounds_system_auth' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_rounds_system_auth
+++ xccdf_org.ssgproject.content_rule_accounts_password_pam_unix_rounds_system_auth
@@ -55,13 +55,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Set number of Password Hashing Rounds - system-auth - Informative message
 based on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was
@@ -226,8 +226,12 @@
 changes are applied
 ansible.builtin.command:
 cmd: authselect apply-changes -b
- when: |
- result_authselect_present is defined and result_authselect_present.stat.exists and ((result_pam_module_add is defined and result_pam_module_add.changed) or (result_pam_module_edit is defined and result_pam_module_edit.changed))
+ when:
+ - result_authselect_present is defined
+ - result_authselect_present.stat.exists
+ - |-
+ (result_pam_module_add is defined and result_pam_module_add.changed)
+ or (result_pam_module_edit is defined and result_pam_module_edit.changed)
 when:
 - result_pam_line_present.found is defined
 - result_pam_line_present.found == 0
@@ -271,8 +275,9 @@
 cmd: authselect apply-changes -b
 when:
 - result_authselect_present.stat.exists
- - (result_pam_rounds_add is defined and result_pam_rounds_add.changed) or (result_pam_rounds_edit
- is defined and result_pam_rounds_edit.changed)
+ - |-
+ (result_pam_rounds_add is defined and result_pam_rounds_add.changed)
+ or (result_pam_rounds_edit is defined and result_pam_rounds_edit.changed)
 when:
 - '"pam" in ansible_facts.packages'
 - result_pam_file_present.stat.exists

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_no_empty_passwords' differs.
--- xccdf_org.ssgproject.content_rule_no_empty_passwords
+++ xccdf_org.ssgproject.content_rule_no_empty_passwords
@@ -30,13 +30,13 @@
 cmd: authselect check
 register: result_authselect_check_cmd
 changed_when: false
- ignore_errors: true
+ failed_when: result_authselect_check_cmd.rc not in [0, 3, 4]
 
 - name: Prevent Login to Accounts With Empty Password - Informative message based
 on the authselect integrity check result
 ansible.builtin.assert:
 that:
- - result_authselect_check_cmd is success
+ - result_authselect_check_cmd.rc == 0
 fail_msg:
 - authselect integrity check failed. Remediation aborted!
 - This remediation could not be applied because an authselect profile was not

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_use_pam_wheel_for_su' differs.
--- xccdf_org.ssgproject.content_rule_use_pam_wheel_for_su
+++ xccdf_org.ssgproject.content_rule_use_pam_wheel_for_su
@@ -11,7 +11,7 @@
 - restrict_strategy
 - use_pam_wheel_for_su
 
-- name: restrict usage of su command only to members of wheel group
+- name: Restrict usage of su command only to members of wheel group
 replace:
 path: /etc/pam.d/su
 regexp: ^[\s]*#[\s]*auth[\s]+required[\s]+pam_wheel\.so[\s]+use_uid$

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_root_path_dirs_no_write' differs.
--- xccdf_org.ssgproject.content_rule_accounts_root_path_dirs_no_write
+++ xccdf_org.ssgproject.content_rule_accounts_root_path_dirs_no_write
@@ -1,19 +1,3 @@
-- name: Print error message if user is not root
- fail:
- msg: Root account required to read root $PATH
- when: ansible_env.USER != "root"
- ignore_errors: true
- tags:
- - CCE-80672-9
- - NIST-800-53-CM-6(a)
- - NIST-800-53-CM-6(a)
- - accounts_root_path_dirs_no_write
- - low_complexity
- - medium_disruption
- - medium_severity
- - no_reboot_needed
- - restrict_strategy
-
 - name: Get root paths which are not symbolic links
 stat:
 path: '{{ item }}'
@@ -21,7 +5,6 @@
 failed_when: false
 register: root_paths
 with_items: '{{ ansible_env.PATH.split('':'') }}'
- when: ansible_env.USER == "root"
 tags:
 - CCE-80672-9
 - NIST-800-53-CM-6(a)

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_auditd_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_auditd_enabled
+++ xccdf_org.ssgproject.content_rule_service_auditd_enabled
@@ -33,7 +33,7 @@
 manager: auto
 
 - name: Enable service auditd
- service:
+ systemd:
 name: auditd
 enabled: 'yes'
 state: started

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_auditd_audispd_syslog_plugin_activated' differs.
--- xccdf_org.ssgproject.content_rule_auditd_audispd_syslog_plugin_activated
+++ xccdf_org.ssgproject.content_rule_auditd_audispd_syslog_plugin_activated
@@ -15,7 +15,7 @@
 - medium_severity
 - no_reboot_needed
 
-- name: enable syslog plugin
+- name: Enable syslog plugin
 lineinfile:
 dest: /etc/audit/plugins.d/syslog.conf
 regexp: ^active

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_service_rsyslog_enabled' differs.
--- xccdf_org.ssgproject.content_rule_service_rsyslog_enabled
+++ xccdf_org.ssgproject.content_rule_service_rsyslog_enabled
@@ -6,7 +6,7 @@
 manager: auto
 
 - name: Enable service rsyslog
- service:
+ systemd:
 name: rsyslog
 enabled: 'yes'
 state: started

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_rsyslog_files_groupownership' differs.
--- xccdf_org.ssgproject.content_rule_rsyslog_files_groupownership
+++ xccdf_org.ssgproject.content_rule_rsyslog_files_groupownership
@@ -101,7 +101,9 @@
 - name: Ensure Log Files Are Owned By Appropriate Group - Extract log files old format
 ansible.builtin.shell: |
 set -o pipefail
- grep -oP '^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$' {{ item.1.path }} |awk '{print $NF}'|sed -e 's/^-//' || true
+ grep -oP '^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$' {{ item.1.path }} | \
+ awk '{print $NF}' | \
+ sed -e 's/^-//' || true
 loop: '{{ rsyslog_config_files.results | subelements(''files'') }}'
 register: log_files_old
 changed_when: false
@@ -122,7 +124,10 @@
 - name: Ensure Log Files Are Owned By Appropriate Group - Extract log files new format
 ansible.builtin.shell: |
 set -o pipefail
- grep -ozP "action\s*\(\s*type\s*=\s*\"omfile\"[^\)]*\)" {{ item.1.path }} | grep -aoP "File\s*=\s*\"([/[:alnum:][:punct:]]*)\"\s*\)"|grep -oE "\"([/[:alnum:][:punct:]]*)\"" |tr -d "\""|| true
+ grep -ozP "action\s*\(\s*type\s*=\s*\"omfile\"[^\)]*\)" {{ item.1.path }} | \
+ grep -aoP "File\s*=\s*\"([/[:alnum:][:punct:]]*)\"\s*\)" | \
+ grep -oE "\"([/[:alnum:][:punct:]]*)\"" | \
+ tr -d "\""|| true
 loop: '{{ rsyslog_config_files.results | subelements(''files'') }}'
 register: log_files_new
 changed_when: false
@@ -142,8 +147,9 @@
 
 - name: Ensure Log Files Are Owned By Appropriate Group - Sum all log files found
 ansible.builtin.set_fact:
- log_files: '{{ log_files_new.results|map(attribute=''stdout_lines'')|list|flatten|unique
- + log_files_old.results|map(attribute=''stdout_lines'')|list|flatten|unique }}'
+ log_files: '{{ log_files_new.results | map(attribute=''stdout_lines'') | list
+ | flatten | unique + log_files_old.results | map(attribute=''stdout_lines'')
+ | list | flatten | unique }}'
 when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-80860-0

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_rsyslog_files_ownership' differs.
--- xccdf_org.ssgproject.content_rule_rsyslog_files_ownership
+++ xccdf_org.ssgproject.content_rule_rsyslog_files_ownership
@@ -101,7 +101,9 @@
 - name: Ensure Log Files Are Owned By Appropriate User - Extract log files old format
 ansible.builtin.shell: |
 set -o pipefail
- grep -oP '^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$' {{ item.1.path }} |awk '{print $NF}'|sed -e 's/^-//' || true
+ grep -oP '^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*\.*$' {{ item.1.path }} | \
+ awk '{print $NF}' | \
+ sed -e 's/^-//' || true
 loop: '{{ rsyslog_config_

... The diff is trimmed here ...

@maage
Copy link
Contributor Author

maage commented Mar 22, 2023

https://github.com/ComplianceAsCode/content/pull/10348/checks?check_run_id=12176022135
Seems to be unrelated:

Maximum test time '90m' exceeded.
Adjust the test 'duration' attribute if necessary.
https://tmt.readthedocs.io/en/stable/spec/tests.html#duration

https://github.com/ComplianceAsCode/content/actions/runs/4483351640/jobs/7882683937?pr=10348
Probably is related:

ERROR - Rule 'dir_perms_world_writable_root_owned' test setup script 'world_writable_dir_on_nonlocal_fs.fail.sh' failed with exit code 32
ERROR - Rule 'dir_perms_world_writable_root_owned' test setup script 'all_dirs_ok.pass.sh' failed with exit code 1

https://github.com/ComplianceAsCode/content/actions/runs/4483351637/jobs/7882536322?pr=10348
Probably is related

The following tests FAILED:
	 44 - unique-cces (BAD_COMMAND)

I need to look those.

@jan-cerny
Copy link
Collaborator

Seems to be unrelated:

I have rerun it. In general, it often is an infrastructure problem. It can be related in some PRs where the PR contain changes that would mean a significant growth or performance hit.

cmake/SSGCommon.cmake Outdated Show resolved Hide resolved
ssg/yaml.py Outdated Show resolved Hide resolved
maage added 6 commits March 25, 2023 14:19
As this is test, it is better to fix fixables now and if there is new
regression fail in future, than try to fix everything now.

If you want to fix some other class, just drop line from
tests/ansible-lint_config.yml and go from there.
Because of usage of CDumper identation does not match what yamllint
expects by default. Change values to match current situation and pass
yamllint-check tests.

Because of usage of CDumper indent-sequences is not consistent.
Auditd lines are over 160, especially open related where there is
multiple systemcalls. I guess there is no point somehow artifically
managing auditd config to achieve shorter lines.

`login_banner_text` can be more than 900, so this test still should
be warning.
Without this there is cache lock and 180s timeout.

Error message:
"Timeout waiting for another instance of ansible-lint to release the lock."
maage added 13 commits March 26, 2023 11:21
Implementation uses just one sweep over files.

If no dupes is found about the same speed.
If dupes are found it is faster.

You can compare speed with stigid.

Interface changed from:
	$0 ref
to
	$0 root-directory ref

Still does not actually understand YAML, just uses regexps.
Had numerous issues.

Use arrays instead of variable globexpansion.

Ensure ansible-playbook checks only <product>-playbook-*.yml files.
Fixes yamllint issue at end of file.

yaml too many blank lines (1 > 0) (empty-lines)
…blank_lines

Without this ansible-playbook-per-profile-yamllint-check tests fail as
between rule segments there can be extra lines because of some reason.

Like:
./fedora-playbook-standard.yml
  342:1     warning  too many blank lines (5 > 2)  (empty-lines)
  1124:1    warning  too many blank lines (3 > 2)  (empty-lines)
...
…errors

Commands can fail because of multiple reasons. Even external, so
ignore_errors is not recommended.

For "rpm -V" it is packages with issuers.

man authselect:
       The authselect can return these exit codes:
       •   0: Success.
       •   1: Generic error.
       •   2: Profile or configuration was not found or the system was not configured with authselect.
       •   3: Current configuration is not valid, it was edited without authselect.
       •   4: System configuration must be overwritten to activate an authselect profile, --force parameter is needed.
       •   5: Executed command must be run as root.
       •   6: No configuration was detected.

This fixes ansible-lint issue:
ignore-errors Use failed_when and specify error conditions instead of using ignore_errors
…er podman

Do not delete password-auth,postlogin as removing them breaks test env
access (for examples sshd) and test resolution can not continue normally.
Other files should be enough.
…rrors

Commands can fail because of multiple reasons. Even external, so
ignore_errors is not recommended.

systemctl list-unit-files <unit>

returns:
0 - found
1 - not found
Allow 0 or 1 as valid rc code and fail if there is real error.

EXIT STATUS
       Normally  the  exit status is 0 if a line is selected, 1 if no
       lines were selected, and 2 if an error occurred.  However, if the
       -q or --quiet or --silent is used and a line is selected, the
       exit status is 0 even if an error occurred.
All other ansible assumes code is run as root.
maage added 3 commits March 26, 2023 18:37
…duct is enabled

Other similar have limitation too. When you try to focus on only one
distro not in this list, this poses unnecessary burden as those files
should not be needed.
Only way to resolve test-generate_contributors is to kill git process as
it does not timeout.
@maage
Copy link
Contributor Author

maage commented Mar 26, 2023

Seems enable_authselect remediable.fail.sh breaks automatus podman test env and maybe others, so I needed to modify it.

Also it seems dir_perms_world_writable_root_owned test world_writable_dir_on_nonlocal_fs.fail.sh fails because containerized environment might not have nfsd or maybe has other issues too. But I'm not happy with resolution so I dropped that patch. Also dropped audit_rules_privileged_commands because I was getting remediation errors and my fix is too involved to be added in this patch set.

Added two patches about test-generate_contributors and ssg_controlrefcheck_test to make ctest more smooth and work as I'd expect.

And added simple test suite for assert_reference_unique. There might still be some issues with older distos and python typing.

Centos 7 test env uses now old python v2:

-- Found PythonInterp: /usr/bin/python (found version "2.7.5")

I see no point trying to backtrack code to support py2.

This test is not per product, so in any other distro with py3 it runs
and there is no lost functionality. Only when developing under Centos 7
and py2 you can not run this test.

It still works under Centos 7 and py3:

python3-3.6.8-18.el7.x86_64
python3-pip-9.0.3-8.el7.noarch

After I installed pytest using pip3, also test suite passes.

[root@e8f9b323981c ssg]# PYTHONPATH=. pytest -v tests/unit/ssg_test_suite/test_assert_reference_unique.py
============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-7.0.1, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /ssg
collected 5 items

tests/unit/ssg_test_suite/test_assert_reference_unique.py::test_assert_reference_unique_noop PASSED [ 20%]
tests/unit/ssg_test_suite/test_assert_reference_unique.py::test_assert_reference_unique_help PASSED [ 40%]
tests/unit/ssg_test_suite/test_assert_reference_unique.py::test_assert_reference_unique_nonexisting PASSED [ 60%]
tests/unit/ssg_test_suite/test_assert_reference_unique.py::test_assert_reference_unique_pass PASSED [ 80%]
tests/unit/ssg_test_suite/test_assert_reference_unique.py::test_assert_reference_unique_fail PASSED [100%]

============================== 5 passed in 0.31s ===============================
@maage
Copy link
Contributor Author

maage commented Mar 26, 2023

unique-cces test failed under Centos 7, because it used py2

-- Found PythonInterp: /usr/bin/python (found version "2.7.5") 

added cmake if to guard against py2.

It seems code climate does not gather coverage under tests, something like:

% PYTHONPATH=tests:. python3 -m pytest --cov-report=term-missing --cov --cov-branch tests tests/unit/ssg_test_suite
============================================================= test session starts ==============================================================
platform linux -- Python 3.11.2, pytest-7.1.3, pluggy-1.0.0
rootdir: /ssg
plugins: cov-4.0.0
collected 173 items                                                                                                                            
...
tests/unit/ssg_test_suite/test_assert_reference_unique.py .....                                                                          [ 85%]
...
Name                                                                               Stmts   Miss Branch BrPart  Cover   Missing
------------------------------------------------------------------------------------------------------------------------------
...
tests/assert_reference_unique.py                                                      60      0     28      1    99%   96->exit
...
tests/unit/ssg_test_suite/test_assert_reference_unique.py                             20      0      0      0   100%
...
TOTAL                                                                              11004   4650   3852    266    54%

@maage
Copy link
Contributor Author

maage commented Mar 26, 2023

Forgot tests/unit/ssg_test_suite/test_assert_reference_unique.py, just skip it under py2.

# PYTHONPATH=. pytest -v tests/unit/ssg_test_suite/test_assert_reference_unique.py
========================================================================== test session starts ==========================================================================
platform linux2 -- Python 2.7.18, pytest-4.6.11, py-1.11.0, pluggy-0.13.1 -- /usr/bin/python2
cachedir: .pytest_cache
rootdir: /ssg
collected 0 items / 1 skipped                                                                                                                                           

======================================================================= 1 skipped in 0.05 seconds =======================================================================

@maage
Copy link
Contributor Author

maage commented Mar 26, 2023

Okay, pytest version in centos-7 env is older than 4.6.x from pip. It seems v2.7.0.

platform linux2 -- Python 2.7.5 -- py-1.4.32 -- pytest-2.7.0
# PYTHONPATH=tests:. python -m pytest -v tests/unit/ssg_test_suite
============================================================= test session starts ==============================================================
platform linux2 -- Python 2.7.5 -- py-1.4.32 -- pytest-2.7.0 -- /usr/bin/python
rootdir: /ssg/tests/unit/ssg_test_suite, inifile: 
collected 27 items / 1 skipped 
...
===================================================== 27 passed, 1 skipped in 6.21 seconds =====================================================
# PYTHONPATH=tests:. python -m pytest -v tests/unit/ssg_test_suite
============================================================= test session starts ==============================================================
platform linux2 -- Python 2.7.5, pytest-4.6.11, py-1.11.0, pluggy-0.13.1 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /ssg
collected 27 items / 1 skipped / 26 selected                                                                                                   
...
===================================================== 27 passed, 1 skipped in 6.32 seconds =====================================================
# PYTHONPATH=tests:. python3 -m pytest -v tests/unit/ssg_test_suite
============================================================= test session starts ==============================================================
platform linux -- Python 3.6.8, pytest-7.0.1, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /ssg
collected 32 items                                                                                                                             

...
======================================================= 32 passed, 34 warnings in 8.12s ========================================================

@codeclimate
Copy link

codeclimate bot commented Mar 26, 2023

Code Climate has analyzed commit dbb7579 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 28.5% (50% is the threshold).

This pull request will bring the total coverage in the repository to 51.8% (-0.1% change).

View more on Code Climate.

@maage
Copy link
Contributor Author

maage commented Mar 27, 2023

Looking automatus results.

One way I do to speed up testing timewise would be to split remediation type per job. For example 3 way works for most: not defined, ansible and bash. This requires some extra patches.

Why "Automatus Fedora / Run Tests (pull_request)" uses "product rhel8" and "ssg-rhel8-ds.xml"? I have used always fedora versions and I guess this explains some discrepancies. Fedora does not have sssd_ldap_configure_tls_ca_dir and service_pcscd_enabled passes in my test env.

I guess these should be labeled as warnings. They should not fail the test. You are just trying to test a rule on platform not configured to allow rule. Same as notapplicable.

ERROR - Rule 'xccdf_org.ssgproject.content_rule_ntpd_configure_restrictions' isn't present in benchmark 'xccdf_org.ssgproject.content_benchmark_RHEL-8' in '/tmp/ssgts-ds-675d98n5'
ERROR - Rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_tally2_unlock_time' isn't present in benchmark 'xccdf_org.ssgproject.content_benchmark_RHEL-8' in '/tmp/ssgts-ds-675d98n5'
ERROR - Rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_tally2_deny_root' isn't present in benchmark 'xccdf_org.ssgproject.content_benchmark_RHEL-8' in '/tmp/ssgts-ds-675d98n5'
ERROR - Rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_tally2' isn't present in benchmark 'xccdf_org.ssgproject.content_benchmark_RHEL-8' in '/tmp/ssgts-ds-675d98n5'

I think both of these might be unrelated failures. Further analysis would require automatus logs from logs_ansible or logs_bash.

INFO - Script ldap_tls_cacertdir_bad_value.fail.sh using profile xccdf_org.ssgproject.content_profile_stig OK
ERROR - Rule evaluation resulted in fail, instead of expected pass during final stage 
ERROR - The check after remediation failed for rule 'xccdf_org.ssgproject.content_rule_sssd_ldap_configure_tls_ca_dir'.
ERROR - Script service_enabled.pass.sh using profile (all) found issue:
ERROR - Rule evaluation resulted in error, instead of expected pass during initial stage 
ERROR - The initial scan failed for rule 'xccdf_org.ssgproject.content_rule_service_pcscd_enabled'.

@maage maage requested a review from jan-cerny March 27, 2023 07:23
@maage
Copy link
Contributor Author

maage commented Mar 27, 2023

This xccdf_org.ssgproject.content_rule_service_pcscd_enabled seems to work still with rhel8 ds in my env.

It seems xccdf_org.ssgproject.content_rule_sssd_ldap_configure_tls_ca_dir final fix fails because it produces about the empty ansible playbook:

---
###############################################################################
#
# Ansible Playbook generated from evaluation of DISA STIG for Red Hat Enterprise Linux 8
#
# Profile ID: xccdf_org.ssgproject.content_profile_stig
# XCCDF Version:  1.2
#
# Evaluation Start Time:  2023-03-27T08:19:05+00:00
# Evaluation End Time:  2023-03-27T08:19:05+00:00
#
# This file was generated by OpenSCAP 1.3.7 using:
# $ oscap xccdf generate fix --result-id xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_stig --fix-type ansible xccdf-results.xml
#
# This Ansible Playbook is generated from the results of a profile evaluation.
# It attempts to remediate all issues from the selected rules that failed the test.
#
# How to apply this Ansible Playbook:
# $ ansible-playbook -i "localhost," -c local playbook.yml
# $ ansible-playbook -i "192.168.1.155," playbook.yml
# $ ansible-playbook -i inventory.ini playbook.yml
#
###############################################################################


- hosts: all
  vars:
  tasks:

This matches xccdf_org.ssgproject.content_rule_sssd_ldap_configure_tls_ca_dir.yml content in log directory.

From arf:

          <rule-result idref="xccdf_org.ssgproject.content_rule_sssd_ldap_configure_tls_ca_dir" role="full" time="2023-03-27T08:12:49+00:00" severity="medium" weight="1.000000">
            <result>fail</result>
            <ident system="https://ncp.nist.gov/cce">CCE-82456-5</ident>
            <check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
              <check-export export-name="oval:ssg-var_sssd_ldap_tls_ca_dir:var:1" value-id="xccdf_org.ssgproject.content_value_var_sssd_ldap_tls_ca_dir"/>
              <check-content-ref name="oval:ssg-sssd_ldap_configure_tls_ca_dir:def:1" href="#oval0"/>
            </check>
          </rule-result>
...
                <test test_id="oval:ssg-test_sssd_ldap_tls_ca_dir:tst:1" version="1" check_existence="all_exist" check="all" result="false">
                  <tested_item item_id="1004714" result="false"/>
                  <tested_variable variable_id="oval:ssg-var_sssd_ldap_tls_ca_dir:var:1">/etc/openldap/cacerts</tested_variable>
                </test>
...
                <collected_objects>
                  <object id="oval:ssg-object_sssd_ldap_tls_ca_dir:obj:1" version="1" flag="complete">
                    <reference item_ref="1004714"/>
                  </object>
                </collected_objects>
                <system_data>
                  <ind-sys:textfilecontent_item id="1004714" status="exists">
                    <ind-sys:filepath>/etc/sssd/sssd.conf</ind-sys:filepath>
                    <ind-sys:path>/etc/sssd</ind-sys:path>
                    <ind-sys:filename>sssd.conf</ind-sys:filename>
                    <ind-sys:pattern>^[\s]*\[domain\/[^]]*](?:[^\n[\]]*\n+)+?[\s]*ldap_tls_cacertdir[\s]+=[\s]+([^\s]+)[\s]*$</ind-sys:pattern>
                    <ind-sys:instance datatype="int">1</ind-sys:instance>
                    <ind-sys:line>^[\s]*\[domain\/[^]]*](?:[^\n[\]]*\n+)+?[\s]*ldap_tls_cacertdir[\s]+=[\s]+([^\s]+)[\s]*$</ind-sys:line>
                    <ind-sys:text>[domain/default]

ldap_id_use_start_tls = True
id_provider = ldap
autofs_provider = ldap
auth_provider = krb5
chpass_provider = krb5
ldap_search_base = dc=com
ldap_tls_cacertdir = /tmp/etc/openldap/cacerts</ind-sys:text>
                    <ind-sys:subexpression>/tmp/etc/openldap/cacerts</ind-sys:subexpression>
                  </ind-sys:textfilecontent_item>
                </system_data>

At least xccdf_org.ssgproject.content_rule_service_pcscd_enabled.yml content is expected.

I don't know how to analyze this further. It might be bug in oscap.

<xccdf-1.2:fix system="urn:xccdf:fix:script:ansible" id="sssd_ldap_configure_tls_ca_dir" complexity="low" disruption="medium" reboot="false" strategy="unknown"> seems okay in ds. As generated files also seems okay:

./build/rhel8/checks/oval/sssd_ldap_configure_tls_ca_dir.xml
./build/rhel8/rules/sssd_ldap_configure_tls_ca.yml
./build/rhel8/rules/sssd_ldap_configure_tls_ca_dir.yml
./build/rhel8/fixes/bash/sssd_ldap_configure_tls_ca_dir.sh
./build/rhel8/fixes/ansible/sssd_ldap_configure_tls_ca_dir.yml
./build/rhel8/playbooks/all/sssd_ldap_configure_tls_ca_dir.yml

Definitely none was broken like my example above.

@maage
Copy link
Contributor Author

maage commented Mar 27, 2023

Okay, find out why. Because rule is not selected:

% oscap --verbose DEVEL xccdf generate fix --result-id xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_stig --fix-type ansible sssd_ldap_configure_tls_ca_dir-ldap_tls_cacertdir_bad_value.fail.sh-final-arf.xml
I: oscap: Identified document type: asset-report-collection [oscap(309910):oscap(7ce820c25040):doc_type.c:96:oscap_determine_document_type_reader]
I: oscap: Identified document type: data-stream-collection [oscap(309910):oscap(7ce820c25040):doc_type.c:96:oscap_determine_document_type_reader]
I: oscap: Created a new XCCDF session from a SCAP Source Datastream '(null)/report-request.xml'. [oscap(309910):oscap(7ce820c25040):xccdf_session.c:179:xccdf_session_new_from_source]
D: oscap: Validating SCAP Source Datastream (1.3) document from (null)/report-request.xml. [oscap(309910):oscap(7ce820c25040):oscap_source.c:350:oscap_source_validate]
I: oscap: Validating XML signature. [oscap(309910):oscap(7ce820c25040):signature.c:122:_oscap_signature_validate_doc]
I: oscap: Signature node not found [oscap(309910):oscap(7ce820c25040):signature.c:167:_oscap_signature_validate_doc]
D: oscap: SDS session created temporary directory '/tmp/oscap.Y0EXXu'. [oscap(309910):oscap(7ce820c25040):ds_sds_session.c:125:ds_sds_session_get_temp_dir]
D: oscap: Successfully dumped script component (id='scap_org.open-scap_ecomp_rhel8-checks-sce-ssh_keys_passphrase_protected.sh') to file '/tmp/oscap.Y0EXXu/./././rhel8/checks/sce/ssh_keys_passphrase_protected.sh'. [oscap(309910):oscap(7ce820c25040):sds.c:196:ds_sds_dump_component_sce]
WARNING: Datastream component 'scap_org.open-scap_cref_security-data-oval-com.redhat.rhsa-RHEL8.xml.bz2' points out to the remote 'https://access.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml.bz2'. Use '--fetch-remote-resources' option to download it.
WARNING: Skipping 'https://access.redhat.com/security/data/oval/com.redhat.rhsa-RHEL8.xml.bz2' file which is referenced from datastream
I: oscap: Identified document type: Benchmark [oscap(309910):oscap(7ce820c25040):doc_type.c:96:oscap_determine_document_type_reader]
I: oscap: Generating result-oriented fixes for policy(result/@id=xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_stig) [oscap(309910):oscap(7ce820c25040):xccdf_policy_remediate.c:1301:xccdf_policy_generate_fix]
---
###############################################################################
#
# Ansible Playbook generated from evaluation of DISA STIG for Red Hat Enterprise Linux 8
#
# Profile ID: xccdf_org.ssgproject.content_profile_stig
# XCCDF Version:  1.2
#
# Evaluation Start Time:  2023-03-27T08:17:16+00:00
# Evaluation End Time:  2023-03-27T08:17:16+00:00
#
# This file was generated by OpenSCAP 1.3.8 using:
# $ oscap xccdf generate fix --result-id xccdf_org.open-scap_testresult_xccdf_org.ssgproject.content_profile_stig --fix-type ansible xccdf-results.xml
#
# This Ansible Playbook is generated from the results of a profile evaluation.
# It attempts to remediate all issues from the selected rules that failed the test.
#
# How to apply this Ansible Playbook:
# $ ansible-playbook -i "localhost," -c local playbook.yml
# $ ansible-playbook -i "192.168.1.155," playbook.yml
# $ ansible-playbook -i inventory.ini playbook.yml
#
###############################################################################


- hosts: all
I: oscap: Skipping unselected Rule/@id="xccdf_org.ssgproject.content_rule_sssd_ldap_configure_tls_ca_dir" [oscap(309910):oscap(7ce820c25040):xccdf_policy_remediate.c:819:_xccdf_policy_rule_get_fix_text]
  vars:
  tasks:

If I edit arf:

% diff -u sssd_ldap_configure_tls_ca_dir-domain_not_there.fail.sh-final-arf.xml xccdf-results.xml
--- sssd_ldap_configure_tls_ca_dir-domain_not_there.fail.sh-final-arf.xml	2023-03-27 11:18:02.678442152 +0300
+++ xccdf-results.xml	2023-03-27 12:55:27.663350563 +0300
@@ -270967,7 +270967,7 @@
                 <xccdf-1.2:check-content-ref href="ssg-rhel8-ocil.xml" name="ocil:ssg-sssd_ldap_configure_tls_ca_ocil:questionnaire:1"/>
               </xccdf-1.2:check>
             </xccdf-1.2:Rule>
-            <xccdf-1.2:Rule selected="false" id="xccdf_org.ssgproject.content_rule_sssd_ldap_configure_tls_ca_dir" severity="medium">
+            <xccdf-1.2:Rule selected="true" id="xccdf_org.ssgproject.content_rule_sssd_ldap_configure_tls_ca_dir" severity="medium">
               <xccdf-1.2:title>Configure SSSD LDAP Backend Client CA Certificate Location</xccdf-1.2:title>
               <xccdf-1.2:description>Configure SSSD to implement cryptography to protect the
 integrity of LDAP remote access sessions. By setting

output is expected.

I guess for arf.xml should be modified to mark tested rule as selected. Or maybe actual ds modified to mark rules to be tested as selected. I think any of these ideas should be handled as separate task.

@jan-cerny
Copy link
Collaborator

Okay, find out why. Because rule is not selected:

The rule not being selected is expected here. But I think that we have hit some bug in OpenSCAP. I have reported it in OpenSCAP/openscap#1963.

2 similar comments
@jan-cerny
Copy link
Collaborator

Okay, find out why. Because rule is not selected:

The rule not being selected is expected here. But I think that we have hit some bug in OpenSCAP. I have reported it in OpenSCAP/openscap#1963.

@jan-cerny
Copy link
Collaborator

Okay, find out why. Because rule is not selected:

The rule not being selected is expected here. But I think that we have hit some bug in OpenSCAP. I have reported it in OpenSCAP/openscap#1963.

@jan-cerny
Copy link
Collaborator

Okay, find out why. Because rule is not selected:

The rule not being selected is expected here. But I think that we have hit some bug in OpenSCAP. I have reported it in OpenSCAP/openscap#1963.

Then we need to decide about the Automatus behavior. So I have reported a #10369

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have verified that the test unique-cces fails if I create a CCE that isn't unique. I have also seen that the test_assert_reference_unique is executed within the python-unit-ssg_test_suite CTest test.

@jan-cerny jan-cerny self-assigned this Mar 30, 2023
@jan-cerny jan-cerny added this to the 0.1.68 milestone Mar 30, 2023
@jan-cerny jan-cerny merged commit bc29275 into ComplianceAsCode:master Mar 30, 2023
@maage maage deleted the ctest-lint-1 branch March 30, 2023 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Used by openshift-ci bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants