Skip to content

Conversation

@ggbecker
Copy link
Member

Description:

  • Modify the ansible remediation to execute /usr/bin/update-crypto-policies --set only when the current crypto-policy is different than the expected.

@ggbecker ggbecker added this to the 0.1.79 milestone Sep 25, 2025
@ggbecker ggbecker added the Ansible Ansible remediation update. label Sep 25, 2025
@ggbecker
Copy link
Member Author

/packit retest-failed

@ggbecker ggbecker force-pushed the ansible-idempotency-configure_crypto_policy branch 2 times, most recently from dd7749f to 458e7e1 Compare September 29, 2025 13:40
@jan-cerny jan-cerny self-assigned this Sep 30, 2025
{{% endif %}}

- name: "{{{ rule_title }}}"
- name: "{{{ rule_title }}} - Set Crypto Policy"
Copy link
Collaborator

Choose a reason for hiding this comment

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

With your change, many Automatus test scenarios start to fail. Please take a look into this.

Here is my output on RHEL9:

jcerny@fedora:~/work/git/scap-security-guide (pr/13932)$ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --remediate-using ansible   configure_crypto_policy
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /home/jcerny/work/git/scap-security-guide/logs/rule-custom-2025-09-30-0929/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_configure_crypto_policy
INFO - Script policy_default_cis_l1.pass.sh using profile xccdf_org.ssgproject.content_profile_cis_server_l1 OK
INFO - Script policy_default_cis_l1.pass.sh using profile xccdf_org.ssgproject.content_profile_cis_workstation_l1 OK
INFO - Script policy_default_nosha1_set.pass.sh using profile xccdf_org.ssgproject.content_profile_e8 OK
INFO - Script cis_l2.pass.sh using profile xccdf_org.ssgproject.content_profile_cis OK
INFO - Script cis_l2.pass.sh using profile xccdf_org.ssgproject.content_profile_cis_workstation_l2 OK
INFO - Script config_and_current_same_time.pass.sh using profile (all) OK
INFO - Script config_newer_than_current.fail.sh using profile (all) 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_configure_crypto_policy'.
INFO - Script missing_nss_config.fail.sh using profile xccdf_org.ssgproject.content_profile_ospp 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_configure_crypto_policy'.
INFO - Script missing_policy.fail.sh using profile xccdf_org.ssgproject.content_profile_ospp 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_configure_crypto_policy'.
INFO - Script missing_policy_file.fail.sh using profile xccdf_org.ssgproject.content_profile_ospp 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_configure_crypto_policy'.
INFO - Script nss_config_as_file.pass.sh using profile xccdf_org.ssgproject.content_profile_ospp OK
INFO - Script nss_config_as_symlink.pass.sh using profile xccdf_org.ssgproject.content_profile_ospp OK
WARNING - Script policy_default_set.pass.sh - profile xccdf_org.ssgproject.content_profile_standard not found in data stream
INFO - Script policy_fips_ospp_set.pass.sh using profile xccdf_org.ssgproject.content_profile_ospp OK
INFO - Script wrong_policy.fail.sh using profile xccdf_org.ssgproject.content_profile_ospp 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_configure_crypto_policy'.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jan-cerny I have extended the ansible playbook to cover all automatus test scenarios. It means there are more conditions for when the update-crypto-policies might get executed in the ansible playbook.


- name: Verify that Crypto Policy is Set (runtime)
- name: "{{{ rule_title }}} - Check current crypto policy (runtime)"
ansible.builtin.command: /usr/bin/update-crypto-policies --show
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will show the state after modifying the /etc/crypto-policies/config by the previous task. This causes that the next task that runs --set will never be executed.

I suggest removing the task that modifies /etc/crypto-policies/config above.

This current crypto policy file is set by the update-crypto-policies
command, if there is a mismatch, the OVAL will detect and result in
fail.
@ggbecker ggbecker force-pushed the ansible-idempotency-configure_crypto_policy branch from 458e7e1 to 07be9d4 Compare October 9, 2025 12:24
This is to mimic the OVAL that does the same check.
@ggbecker ggbecker force-pushed the ansible-idempotency-configure_crypto_policy branch from 07be9d4 to 04f7eb2 Compare October 9, 2025 12:24
@ggbecker ggbecker requested a review from jan-cerny October 9, 2025 12:26
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 run automatus TSs locally on a RHEL 9 VM back end and they pass for me. THen. I used the generated per-rule Ansible Playbook build/rhel9/playbooks/cis/configure_crypto_policy.yml to configure a VM and with the second run all tasks are ok or skipped.

@openshift-ci
Copy link

openshift-ci bot commented Oct 9, 2025

@ggbecker: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-openshift-node-compliance 04f7eb2 link true /test e2e-aws-openshift-node-compliance

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@jan-cerny
Copy link
Collaborator

/packit build

4 similar comments
@Mab879
Copy link
Member

Mab879 commented Oct 9, 2025

/packit build

@jan-cerny
Copy link
Collaborator

/packit build

@jan-cerny
Copy link
Collaborator

/packit build

@jan-cerny
Copy link
Collaborator

/packit build

@jan-cerny jan-cerny merged commit 27c362f into ComplianceAsCode:master Oct 13, 2025
134 of 136 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants