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 Ansible remediation in rsyslog_logfiles_attributes_modify template #10551

Merged

Conversation

marcusburghardt
Copy link
Member

Description:

The Ansible remediation in the rsyslog_logfiles_attributes_modify template uses the file module to set file permissions. The mode option receives the value from a Jinja2 variable.
This value was not quoted, making the octal number be converted to a decimal number and consequently impacting the remediation.

This was the result of the relevant task in the Ansible Playbook when the 0640 value was used without quotes in the mode option of the file module:

ansible.builtin.file:
  path: '{{ item }}'
  mode: 416
  state: file

This is the expected result, fixed by this PR:

ansible.builtin.file:
  path: '{{ item }}'
  mode: '0640'
  state: file

In addition, some minor updates were done in test scenario scripts:

  • The existing scripts were renamed to be better organized.
  • The default permission in the "correct" test scenario scripts was updated from 0600 to 0640 in alignment to the respective rule.
  • It was included new test scenarios checking stricter permissions.

Rationale:

Ansible remediation fixed.
Better test scenario scripts.

Review Hints:

Example of automatus command for a RHEL8 VM:

./tests/automatus.py rule --libvirt qemu:///session <RHEL8 VM> --datastream build/ssg-rhel8-ds.xml --dontclean --remediate-using ansible rsyslog_files_permissions

Checking the resulted Ansible Playbook could also be interesting during the review.

The existing scripts were renamed to be better organized.
The default permission in the "correct" test scenario scripts was
updated from "0600" to "0640" in alingment to the respective rule.
It was also included new test scenarios checking stricter permissions.
The Ansible remediation in the rsyslog_logfiles_attributes_modify
template uses the file module to set file permissions. The mode option
receives the value from a Jinja2 variable. This value was not quoted,
making the octal number be converted to a decimal number and
consequently impacting the remediation.
@marcusburghardt marcusburghardt added bugfix Fixes to reported bugs. Ansible Ansible remediation update. labels May 10, 2023
@marcusburghardt marcusburghardt added this to the 0.1.68 milestone May 10, 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 May 10, 2023

Code Climate has analyzed commit 022a81b 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 52.4% (0.0% change).

View more on Code Climate.

@Mab879 Mab879 self-assigned this May 11, 2023
@Mab879 Mab879 merged commit 4fc59e9 into ComplianceAsCode:master May 11, 2023
@marcusburghardt marcusburghardt deleted the rsyslog_file_permissions_tests branch May 11, 2023 18:54
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.

2 participants