Skip to content

Add check if to continue with ansible task#11299

Merged
jan-cerny merged 1 commit into
ComplianceAsCode:masterfrom
teacup-on-rockingchair:sle_anssi_ansible_check_mode_fix
Dec 1, 2023
Merged

Add check if to continue with ansible task#11299
jan-cerny merged 1 commit into
ComplianceAsCode:masterfrom
teacup-on-rockingchair:sle_anssi_ansible_check_mode_fix

Conversation

@teacup-on-rockingchair
Copy link
Copy Markdown
Contributor

Description:

  • When run in check mode ansible remediation scripts should be more isolated and need extra checks instead of assumptions

Rationale:

  • Fix ansible remediations run in check mode for rules part of the SLE ANSSI profile

@teacup-on-rockingchair teacup-on-rockingchair added Ansible Ansible remediation update. SLES SUSE Linux Enterprise Server product related. labels Nov 22, 2023
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 22, 2023
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Nov 22, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@github-actions
Copy link
Copy Markdown

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
Copy Markdown

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dir_perms_world_writable_root_owned' differs.
--- xccdf_org.ssgproject.content_rule_dir_perms_world_writable_root_owned
+++ xccdf_org.ssgproject.content_rule_dir_perms_world_writable_root_owned
@@ -142,6 +142,7 @@
     world_writable_dirs: '{{ world_writable_dirs | union(item.stdout_lines) | list
       }}'
   loop: '{{ result_found_dirs.results }}'
+  when: item is not skipped
   tags:
   - CCE-83375-6
   - DISA-STIG-RHEL-08-010700

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_dir_perms_world_writable_sticky_bits' differs.
--- xccdf_org.ssgproject.content_rule_dir_perms_world_writable_sticky_bits
+++ xccdf_org.ssgproject.content_rule_dir_perms_world_writable_sticky_bits
@@ -163,6 +163,7 @@
     world_writable_dirs: '{{ world_writable_dirs | union(item.stdout_lines) | list
       }}'
   loop: '{{ result_found_dirs.results }}'
+  when: result_found_dirs is not skipped and item is not skipped
   tags:
   - CCE-80783-4
   - DISA-STIG-RHEL-08-010190

@qlty-cloud-legacy
Copy link
Copy Markdown

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

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

This pull request will bring the total coverage in the repository to 58.5%.

View more on Code Climate.

@teacup-on-rockingchair teacup-on-rockingchair marked this pull request as ready for review November 28, 2023 08:15
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Nov 28, 2023
@teacup-on-rockingchair
Copy link
Copy Markdown
Contributor Author

failing automatus tests seemed to be because of dir_perms_world_writable_root_owned test involves some systemd service restarting and we have no systemd on podman

@vojtapolasek vojtapolasek added this to the 0.1.72 milestone Nov 29, 2023
@jan-cerny jan-cerny self-assigned this Dec 1, 2023
Copy link
Copy Markdown
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.

The test scenarios pass locally when using a virtual machine back end.

jcerny@fedora ~/work/git/scap-security-guide (pr/11299) $ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel8 --remediate-using ansible dir_perms_world_writable_root_owned dir_perms_world_writable_sticky_bits
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-2023-12-01-1155/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_dir_perms_world_writable_root_owned
INFO - Script all_dirs_ok.pass.sh using profile (all) OK
INFO - Script world_writable_dir_on_nonlocal_fs.fail.sh using profile (all) OK
INFO - Script world_writable_dir_owned_by_uid_2.fail.sh using profile (all) OK
INFO - xccdf_org.ssgproject.content_rule_dir_perms_world_writable_sticky_bits
INFO - Script correct.pass.sh using profile (all) OK
INFO - Script tmp_no_sticky.fail.sh using profile (all) OK
jcerny@fedora ~/work/git/scap-security-guide (pr/11299) $ python3 tests/automatus.py rule --libvirt qemu:///system ssgts_rhel9 --remediate-using ansible dir_perms_world_writable_root_owned dir_perms_world_writable_sticky_bits
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-2023-12-01-1202/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_dir_perms_world_writable_root_owned
INFO - Script all_dirs_ok.pass.sh using profile (all) OK
INFO - Script world_writable_dir_on_nonlocal_fs.fail.sh using profile (all) OK
INFO - Script world_writable_dir_owned_by_uid_2.fail.sh using profile (all) OK
INFO - xccdf_org.ssgproject.content_rule_dir_perms_world_writable_sticky_bits
INFO - Script correct.pass.sh using profile (all) OK
INFO - Script tmp_no_sticky.fail.sh using profile (all) OK

@jan-cerny jan-cerny merged commit c0978ed into ComplianceAsCode:master Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ansible Ansible remediation update. SLES SUSE Linux Enterprise Server product related.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants