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

fix loops within ansible template for rsyslog_files #10349

Conversation

vojtapolasek
Copy link
Collaborator

Description:

  • get rid of map functions
  • also previous implementation did not account for the fact that variable created in loops have results stored in ".results" data structure

Rationale:

Review Hints:

see the issue fixed by this PR

- get rid of map functions
also previous implementation did not account for the fact that variable created in loops have results stored in ".results" data structure
@vojtapolasek vojtapolasek added bugfix Fixes to reported bugs. Ansible Ansible remediation update. labels Mar 22, 2023
@vojtapolasek vojtapolasek added this to the 0.1.67 milestone Mar 22, 2023
@github-actions
Copy link

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

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@codeclimate
Copy link

codeclimate bot commented Mar 22, 2023

Code Climate has analyzed commit 48c3b99 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 51.8% (0.0% change).

View more on Code Climate.

@jan-cerny jan-cerny self-assigned this Mar 23, 2023
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 was able to reproduce the issue #10170 in a RHEL 7.9 machine with the 20230228.1 compose - both the host and the guest are the same RHEL 7.9 version.

[root@cisco-c210-01 content]# python3 tests/automatus.py rule --libvirt qemu:///system test_suite_vm --remediate-using ansible rsyslog_files_groupownership
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /root/content/logs/rule-custom-2023-03-24-0400/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_rsyslog_files_groupownership
INFO - Script rainer_include_incorrect_attr.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_rsyslog_files_groupownership'.
INFO - Script rainer_include_correct_attr.pass.sh using profile (all) OK
INFO - Script legacy_include_incorrect_attr.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_rsyslog_files_groupownership'.
INFO - Script rainer_include_multiline_incorrect_attr.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_rsyslog_files_groupownership'.
INFO - Script legacy_correct_attr.pass.sh using profile (all) OK
INFO - Script mixed_incorrect_attr_rainer.fail.sh using profile (all) OK
INFO - Script mixed_correct_attr.pass.sh using profile (all) OK
INFO - Script mixed_incorrect_attr_cloudinit.fail.sh using profile (all) OK
INFO - Script mixed_include_incorrect_attr_legacy.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_rsyslog_files_groupownership'.
INFO - Script mixed_incorrect_attr_legacy.fail.sh using profile (all) OK
INFO - Script rainer_include_multiline_correct_attr.pass.sh using profile (all) OK
INFO - Script mixed_include_incorrect_attr_rainer.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_rsyslog_files_groupownership'.
INFO - Script mixed_include_correct_attr.pass.sh using profile (all) OK
INFO - Script legacy_incorrect_attr.fail.sh using profile (all) OK
INFO - Script legacy_include_correct_attr.pass.sh using profile (all) OK
INFO - Script rainer_correct_attr.pass.sh using profile (all) OK
INFO - Script rainer_incorrect_attr.fail.sh using profile (all) OK

I can confirm that with this PR the test fails are fixed and they all pass:

[root@cisco-c210-01 content]# python3 tests/automatus.py rule --libvirt qemu:///system test_suite_vm --remediate-using ansible rsyslog_files_groupownership
Setting console output to log level INFO
INFO - The base image option has not been specified, choosing libvirt-based test environment.
INFO - Logging into /root/content/logs/rule-custom-2023-03-24-0438/test_suite.log
INFO - xccdf_org.ssgproject.content_rule_rsyslog_files_groupownership
INFO - Script mixed_incorrect_attr_rainer.fail.sh using profile (all) OK
INFO - Script legacy_incorrect_attr.fail.sh using profile (all) OK
INFO - Script rainer_incorrect_attr.fail.sh using profile (all) OK
INFO - Script mixed_include_correct_attr.pass.sh using profile (all) OK
INFO - Script legacy_include_correct_attr.pass.sh using profile (all) OK
INFO - Script legacy_correct_attr.pass.sh using profile (all) OK
INFO - Script mixed_include_incorrect_attr_legacy.fail.sh using profile (all) OK
INFO - Script mixed_include_incorrect_attr_rainer.fail.sh using profile (all) OK
INFO - Script rainer_include_correct_attr.pass.sh using profile (all) OK
INFO - Script rainer_include_multiline_incorrect_attr.fail.sh using profile (all) OK
INFO - Script rainer_include_incorrect_attr.fail.sh using profile (all) OK
INFO - Script mixed_incorrect_attr_legacy.fail.sh using profile (all) OK
INFO - Script rainer_correct_attr.pass.sh using profile (all) OK
INFO - Script legacy_include_incorrect_attr.fail.sh using profile (all) OK
INFO - Script rainer_include_multiline_correct_attr.pass.sh using profile (all) OK
INFO - Script mixed_correct_attr.pass.sh using profile (all) OK
INFO - Script mixed_incorrect_attr_cloudinit.fail.sh using profile (all) OK

@jan-cerny jan-cerny merged commit 056a981 into ComplianceAsCode:master Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. bugfix Fixes to reported bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rsyslog log files related rules don't pass after Ansible remediation in some test scenarios
2 participants