-
Notifications
You must be signed in to change notification settings - Fork 698
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
Use platform_package_overrides in bash and ansible macros #10626
Conversation
Hi @maage. Thanks for your PR. I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
099974d
to
08fa878
Compare
This datastream diff is auto generated by the check Click here to see the full diffansible remediation for rule 'xccdf_org.ssgproject.content_rule_aide_build_database' differs.
--- xccdf_org.ssgproject.content_rule_aide_build_database
+++ xccdf_org.ssgproject.content_rule_aide_build_database
@@ -1,9 +1,8 @@
-- name: Ensure AIDE is installed
- package:
- name: '{{ item }}'
+- name: Build and Test AIDE Database - Ensure AIDE Package Is Installed
+ ansible.builtin.package:
+ name:
+ - aide
state: present
- with_items:
- - aide
when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
tags:
- CCE-80675-2
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_aide_check_audit_tools' differs.
--- xccdf_org.ssgproject.content_rule_aide_check_audit_tools
+++ xccdf_org.ssgproject.content_rule_aide_check_audit_tools
@@ -1,9 +1,8 @@
-- name: Ensure aide is installed
- package:
- name: '{{ item }}'
+- name: Configure AIDE to Verify the Audit Tools - Ensure AIDE Package Is Installed
+ ansible.builtin.package:
+ name:
+ - aide
state: present
- with_items:
- - aide
when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
tags:
- CCE-85964-5
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_aide_periodic_cron_checking' differs.
--- xccdf_org.ssgproject.content_rule_aide_periodic_cron_checking
+++ xccdf_org.ssgproject.content_rule_aide_periodic_cron_checking
@@ -1,5 +1,5 @@
-- name: Ensure AIDE is installed
- package:
+- name: Configure Periodic Execution of AIDE - Ensure AIDE Packages Are Installed
+ ansible.builtin.package:
name:
- aide
- crontabs
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_aide_scan_notification' differs.
--- xccdf_org.ssgproject.content_rule_aide_scan_notification
+++ xccdf_org.ssgproject.content_rule_aide_scan_notification
@@ -4,8 +4,9 @@
tags:
- always
-- name: Ensure AIDE is installed
- package:
+- name: Configure Notification of Post-AIDE Scan Details - Ensure AIDE Packages Are
+ Installed
+ ansible.builtin.package:
name:
- aide
- crontabs
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir' differs.
--- xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
+++ xccdf_org.ssgproject.content_rule_accounts_passwords_pam_faillock_dir
@@ -641,14 +641,13 @@
- medium_severity
- no_reboot_needed
-- name: Lock Accounts Must Persist - Ensure necessary SELinux packages are installed
+- name: Lock Accounts Must Persist - Ensure necessary SELinux Packages Are Installed
ansible.builtin.package:
- name: '{{ item }}'
+ name:
+ - python3-libselinux
+ - python3-policycoreutils
+ - policycoreutils-python-utils
state: present
- with_items:
- - python3-libselinux
- - python3-policycoreutils
- - policycoreutils-python-utils
when: '"pam" in ansible_facts.packages'
tags:
- CCE-86067-6
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_wireless_disable_interfaces' differs.
--- xccdf_org.ssgproject.content_rule_wireless_disable_interfaces
+++ xccdf_org.ssgproject.content_rule_wireless_disable_interfaces
@@ -20,12 +20,12 @@
- unknown_strategy
- wireless_disable_interfaces
-- name: Ensure NetworkManager is installed
+- name: Deactivate Wireless Network Interfaces - Ensure the NetworkManager Package
+ Is Installed
ansible.builtin.package:
- name: '{{ item }}'
+ name:
+ - NetworkManager
state: present
- with_items:
- - NetworkManager
tags:
- CCE-83501-7
- DISA-STIG-RHEL-08-040110
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_firewalld_sshd_port_enabled' differs.
--- xccdf_org.ssgproject.content_rule_firewalld_sshd_port_enabled
+++ xccdf_org.ssgproject.content_rule_firewalld_sshd_port_enabled
@@ -4,14 +4,13 @@
tags:
- always
-- name: Enable SSH Server firewalld Firewall Exception - Ensure firewalld and NetworkManager
- packages are installed
+- name: Enable SSH Server firewalld Firewall Exception - Ensure the firewalld and
+ NetworkManager Packages Are Installed
ansible.builtin.package:
- name: '{{ item }}'
+ name:
+ - firewalld
+ - NetworkManager
state: present
- with_items:
- - firewalld
- - NetworkManager
when: ansible_virtualization_type not in ["docker", "lxc", "openvz", "podman", "container"]
tags:
- CCE-80820-4
bash remediation for rule 'xccdf_org.ssgproject.content_rule_package_sssd_installed' differs.
--- xccdf_org.ssgproject.content_rule_package_sssd_installed
+++ xccdf_org.ssgproject.content_rule_package_sssd_installed
@@ -1,8 +1,8 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q sssd-common; then
-if ! rpm -q --quiet "sssd" ; then
- yum install -y "sssd"
+if ! rpm -q --quiet "sssd-common" ; then
+ yum install -y "sssd-common"
fi
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
A couple of changes to align to the style guide.
a72fdc7
to
7783cb1
Compare
Fixed issues raised in review. Added doc to |
@maage This is great stuff! Is it still a work in progress or do you want to click on "Ready for review"? |
@maage bump ^^ |
7783cb1
to
cfb1cab
Compare
Now added other ansible package: sections, but |
601b204
to
b630196
Compare
… to install packages
b630196
to
bb6bcec
Compare
Code Climate has analyzed commit bb6bcec 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.9% (0.0% change). View more on Code Climate. |
{{%- if name is none %}} | ||
{{%- set name = "the " ~ (packages | join_comma_and) -%}} | ||
{{%- endif %}} | ||
- name: "{{{ rule_title }}} - Ensure {{{ name }}} {{% if packages | length > 1 %}}Packages Are{{% else %}}Package Is{{% endif %}} Installed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if the overridden package name would be also used in the task name.
state: present | ||
with_items: | ||
- NetworkManager | ||
{{{ ansible_package_install(["NetworkManager"]) }}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention at the task below this. The task uses "when:" statement where the package name will have to be overridden as well
PR needs rebase. 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/test-infra repository. |
@maage please check the review above and please resolve the conflicts. |
Closing for no reaction for more than a month. If you still plan to work on this PR, please address the feedback and reopen the PR. |
Description:
Use
platform_package_overrides
inbash_package_install
andbash_package_remove
. And it should be used in every path where packages are installed if at all feasible. Another way is to do it like https://github.com/maage/scap-security-guide/blob/08fa8789b71e0ce2863000bb957c56693942df7e/linux_os/guide/system/software/integrity/software-integrity/aide/aide_periodic_cron_checking/ansible/shared.yml#L9Add
ansible_package_install
and it usesplatform_package_overrides
. Maybe it should handle one package at a time, but if you do it like that, running playbook takes forever. One issue is that testing list is not simplest of tasks.Rationale:
Using this fully would simplify code I guess and avoid issues like: #10557 (comment)
Why even this was not already the case?
Review Hints:
This is generally not tested at all. At least datastream diff looks sane and it seems actually to fix things already.