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

Improve the arguments for Ansible command module #9921

Merged

Conversation

marcusburghardt
Copy link
Member

Description:

It was used the awk command in a task and the delimiter character was :.
This was not quoted and making it prone to be interpreted as a module parameter.
This has likely been worked around in the past, but not in the most compatible way, causing the Playbook a fatal error on some systems with different versions of Ansible. Relevant tasks have been improved to be more robust and compatible.

Rationale:

Avoid fatal errors on Ansible Playbooks

It was used the awk command in a task and the delimiter character was
":". This has likely been worked around in the past, but not in the
most compatible way, causing the Playbook a fatal error on some systems
with different versions of Ansible. Relevant tasks have been improved
to be more robust and compatible.
@marcusburghardt marcusburghardt added Ansible Ansible remediation update. productization-issue Issue found in upstream stabilization process. labels Dec 2, 2022
@marcusburghardt marcusburghardt added this to the 0.1.66 milestone Dec 2, 2022
@github-actions
Copy link

github-actions bot commented Dec 2, 2022

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 Dec 2, 2022

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_accounts_password_set_max_life_existing' differs.
--- xccdf_org.ssgproject.content_rule_accounts_password_set_max_life_existing
+++ xccdf_org.ssgproject.content_rule_accounts_password_set_max_life_existing
@@ -5,8 +5,9 @@
 - always
 
 - name: Collect users with not correct maximum time period between password changes
- ansible.builtin.command: |
- awk -F: '$5 > {{ var_accounts_maximum_age_login_defs }} || $5 == "" {print $1}' /etc/shadow
+ ansible.builtin.command:
+ cmd: awk -F':' '$5 > {{ var_accounts_maximum_age_login_defs }} || $5 == "" {print
+ $1}' /etc/shadow
 register: user_names
 tags:
 - CCE-82473-0

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_grub2_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if rpm --quiet -q grub2-common && [ ! -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if [ ! -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chgrp 0 /boot/grub2/grub.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_grub2_cfg
@@ -20,8 +20,8 @@
 path: /boot/grub2/grub.cfg
 register: file_exists
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-80800-6
@@ -42,8 +42,8 @@
 path: /boot/grub2/grub.cfg
 group: '0'
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_user_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if rpm --quiet -q grub2-common && [ ! -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if [ ! -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chgrp 0 /boot/grub2/user.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_user_cfg
@@ -20,8 +20,8 @@
 path: /boot/grub2/user.cfg
 register: file_exists
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-86009-8
@@ -42,8 +42,8 @@
 path: /boot/grub2/user.cfg
 group: '0'
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_grub2_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if rpm --quiet -q grub2-common && [ ! -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if [ ! -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chown 0 /boot/grub2/grub.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_grub2_cfg
@@ -20,8 +20,8 @@
 path: /boot/grub2/grub.cfg
 register: file_exists
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-80805-5
@@ -42,8 +42,8 @@
 path: /boot/grub2/grub.cfg
 owner: '0'
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_user_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if rpm --quiet -q grub2-common && [ ! -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if [ ! -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chown 0 /boot/grub2/user.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_user_cfg
@@ -20,8 +20,8 @@
 path: /boot/grub2/user.cfg
 register: file_exists
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-86015-5
@@ -42,8 +42,8 @@
 path: /boot/grub2/user.cfg
 owner: '0'
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_grub2_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if rpm --quiet -q grub2-common && [ ! -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if [ ! -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chmod u-xs,g-xwrs,o-xwrt /boot/grub2/grub.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_grub2_cfg
@@ -18,8 +18,8 @@
 path: /boot/grub2/grub.cfg
 register: file_exists
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-80814-7
@@ -38,8 +38,8 @@
 path: /boot/grub2/grub.cfg
 mode: u-xs,g-xwrs,o-xwrt
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_user_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if rpm --quiet -q grub2-common && [ ! -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if [ ! -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chmod u-xs,g-xwrs,o-xwrt /boot/grub2/user.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_user_cfg
@@ -18,8 +18,8 @@
 path: /boot/grub2/user.cfg
 register: file_exists
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-86024-7
@@ -38,8 +38,8 @@
 path: /boot/grub2/user.cfg
 mode: u-xs,g-xwrs,o-xwrt
 when:
+ - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - '"grub2-common" in ansible_facts.packages'
- - '"/boot/efi" not in ansible_mounts | map(attribute="mount") | list'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_efi_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_efi_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_efi_grub2_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if rpm --quiet -q grub2-common && [ -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chgrp 0 /boot/efi/EFI/redhat/grub.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_efi_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_efi_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_efi_grub2_cfg
@@ -20,8 +20,8 @@
 path: /boot/efi/EFI/redhat/grub.cfg
 register: file_exists
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-85915-7
@@ -42,8 +42,8 @@
 path: /boot/efi/EFI/redhat/grub.cfg
 group: '0'
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_efi_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_efi_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_efi_user_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if rpm --quiet -q grub2-common && [ -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chgrp 0 /boot/efi/EFI/redhat/user.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_efi_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_efi_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_groupowner_efi_user_cfg
@@ -20,8 +20,8 @@
 path: /boot/efi/EFI/redhat/user.cfg
 register: file_exists
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-86012-2
@@ -42,8 +42,8 @@
 path: /boot/efi/EFI/redhat/user.cfg
 group: '0'
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_efi_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_efi_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_efi_grub2_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if rpm --quiet -q grub2-common && [ -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chown 0 /boot/efi/EFI/redhat/grub.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_efi_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_efi_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_efi_grub2_cfg
@@ -20,8 +20,8 @@
 path: /boot/efi/EFI/redhat/grub.cfg
 register: file_exists
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-85913-2
@@ -42,8 +42,8 @@
 path: /boot/efi/EFI/redhat/grub.cfg
 owner: '0'
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_efi_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_efi_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_efi_user_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if rpm --quiet -q grub2-common && [ -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chown 0 /boot/efi/EFI/redhat/user.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_efi_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_efi_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_owner_efi_user_cfg
@@ -20,8 +20,8 @@
 path: /boot/efi/EFI/redhat/user.cfg
 register: file_exists
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-86021-3
@@ -42,8 +42,8 @@
 path: /boot/efi/EFI/redhat/user.cfg
 owner: '0'
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_efi_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_efi_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_efi_grub2_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if rpm --quiet -q grub2-common && [ -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chmod u-s,g-xwrs,o-xwrt /boot/efi/EFI/redhat/grub.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_efi_grub2_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_efi_grub2_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_efi_grub2_cfg
@@ -18,8 +18,8 @@
 path: /boot/efi/EFI/redhat/grub.cfg
 register: file_exists
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-85912-4
@@ -38,8 +38,8 @@
 path: /boot/efi/EFI/redhat/grub.cfg
 mode: u-s,g-xwrs,o-xwrt
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_efi_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_efi_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_efi_user_cfg
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ -f /sys/firmware/efi ] && rpm --quiet -q grub2-common && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
+if rpm --quiet -q grub2-common && [ -f /sys/firmware/efi ] && { [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; }; then
 
 chmod u-xs,g-xwrs,o-xwrt /boot/efi/EFI/redhat/user.cfg
 

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_permissions_efi_user_cfg' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_efi_user_cfg
+++ xccdf_org.ssgproject.content_rule_file_permissions_efi_user_cfg
@@ -18,8 +18,8 @@
 path: /boot/efi/EFI/redhat/user.cfg
 register: file_exists
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 tags:
 - CCE-86028-8
@@ -38,8 +38,8 @@
 path: /boot/efi/EFI/redhat/user.cfg
 mode: u-xs,g-xwrs,o-xwrt
 when:
+ - '"grub2-common" in ansible_facts.packages'
 - '"/boot/efi" in ansible_mounts | map(attribute="mount") | list'
- - '"grub2-common" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
 - file_exists.stat is defined and file_exists.stat.exists
 tags:

bash remediation for rule 'xccdf_org.ssgproject.content_rule_postfix_prevent_unrestricted_relay' differs.
--- xccdf_org.ssgproject.content_rule_postfix_prevent_unrestricted_relay
+++ xccdf_org.ssgproject.content_rule_postfix_prevent_unrestricted_relay
@@ -1,5 +1,5 @@
 # Remediation is applicable only in certain platforms
-if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ] && rpm --quiet -q postfix; then
+if rpm --quiet -q postfix && [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
 
 if ! grep -q ^smtpd_client_restrictions /etc/postfix/main.cf; then
 echo "smtpd_client_restrictions = permit_mynetworks,reject" >> /etc/postfix/main.cf

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_postfix_prevent_unrestricted_relay' differs.
--- xccdf_org.ssgproject.content_rule_postfix_prevent_unrestricted_relay
+++ xccdf_org.ssgproject.content_rule_postfix_prevent_unrestricted_relay
@@ -40,8 +40,8 @@
 line: smtpd_client_restrictions = permit_mynetworks,reject
 state: present
 when:
+ - '"postfix" in ansible_facts.packages'
 - ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
- - '"postfix" in ansible_facts.packages'
 tags:
 - CCE-84054-6
 - DISA-STIG-RHEL-08-040290

@codeclimate
Copy link

codeclimate bot commented Dec 2, 2022

Code Climate has analyzed commit a26be8a 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 48.8% (0.0% change).

View more on Code Climate.

@jan-cerny
Copy link
Collaborator

please link the productization issue

@marcusburghardt
Copy link
Member Author

please link the productization issue

Honza, this issue was only visible in ppc64 when executing the /usr/share/scap-security-guide/ansible/rhel7-playbook-stig.yml playbook.

The error was:

ERROR! this task 'ansible.builtin.command' has extra params, which is only allowed in the following modules: shell, win_shell, include_vars, add_host, raw, include_role, meta, set_fact, include, import_tasks, script, import_role, include_tasks, group_by, command, win_command

The error appears to be in '/usr/share/scap-security-guide/ansible/rhel7-playbook-stig.yml': line 8591, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: Collect users with not correct maximum time period between password changes
      ^ here

So, it happens only in a very specific case and was pretty easy to be fixed. Therefore, I sent this PR directly.
It seems the syntax ansible.builtin.command: > is not enough in some cases.

@jan-cerny jan-cerny self-assigned this Dec 15, 2022
@jan-cerny jan-cerny merged commit 147c6c6 into ComplianceAsCode:master Dec 15, 2022
@marcusburghardt marcusburghardt deleted the ansible_command_improvement branch December 15, 2022 14:28
@dodys
Copy link
Contributor

dodys commented Dec 15, 2022

@marcusburghardt fyi, this might be also an issue for accounts_password_set_min_life_existing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. productization-issue Issue found in upstream stabilization process.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants