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 for audispd plugin UBTU-20-010216 #12293

Merged

Conversation

ghost
Copy link

@ghost ghost commented Aug 12, 2024

Description:

  • This commit will fix ansible remediation for audispd plugin which also ensures that the plugin is enabled within au-remote.conf.

Original PR: #11093

Rationale:

  • Apply ubuntu specific remediation for ansible
  • Align existing ansible remediation tasks to proper format
  • Part of Ubuntu 2004 STIG v1r12 profile upgrade

Review Hints:

Build the product:

./build_product ubuntu2004

To test these changes with Ansible:

ansible-playbook build/ansible/ubuntu2004-playbook-stig.yml --tags "DISA-STIG-UBTU-20-010216"

Checkout Manual STIG OVAL definitions, and use software like DISA STIG Viewer to view definitions.

git checkout yunimoo:update-manual-stig-ubtu-20-v1r12

For reference, please review the latest artifacts: https://public.cyber.mil/stigs/downloads/

Copy link

openshift-ci bot commented Aug 12, 2024

Hi @yunimoo. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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-sigs/prow repository.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Aug 12, 2024
Copy link

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

Copy link

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_auditd_audispd_configure_remote_server' differs.
--- xccdf_org.ssgproject.content_rule_auditd_audispd_configure_remote_server
+++ xccdf_org.ssgproject.content_rule_auditd_audispd_configure_remote_server
@@ -15,8 +15,9 @@
   tags:
     - always
 
-- name: Make sure that a remote server is configured for Audispd
-  lineinfile:
+- name: Configure audispd Plugin To Send Logs To Remote Server - Make sure that a
+    remote server is configured for Audispd
+  ansible.builtin.lineinfile:
     path: /etc/audit/audisp-remote.conf
     line: remote_server = {{ var_audispd_remote_server }}
     regexp: ^\s*remote_server\s*=.*$

@jan-cerny jan-cerny self-assigned this Aug 12, 2024
@jan-cerny jan-cerny added this to the 0.1.75 milestone Aug 12, 2024
Copy link

github-actions bot commented Aug 12, 2024

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:12293
This image was built from commit: 293f09c

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:12293

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:12293 make deploy-local

- name: "{{{ rule_title }}} - Set active to true for offloading to remote server"
ansible.builtin.lineinfile:
path: "{{{ audisp_config_plugin_path }}}"
regexp: ^(.*)(active\s*=)(?!.*yes)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test scenarios for this rule, eg. ubuntu_correct.pass.sh, use a capital A in Active, however, this remediation and the rule description use small a in `active. The OVAL seems to correctly use a case-insensitive regex modifier. Could you investigate this discrepancy about the A case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks for the feedback, I will take a look at this

Copy link
Author

@ghost ghost Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how you would like to proceed since the STIG and man page seem to use active over Active. Though, I don't think this would matter as it is case insensitive. The bash remediation is also active instead of capital A.

Not sure if this is helpful, but I found these related docs:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming that these options are case insensitive. Based on that, I think that:

  • in the rule description we can use whatever we want, ie. it can stay lowercase
  • in the OVAL we should use case-insentive check, which we already have
  • the Ansible and Bash remediations should be able to set the correct option value regardless of the case used in the file (it can change it to lowercase during the remediation if that's convenient for us)
  • the test scenarios should be testing multiple different letter cases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bash remediation makes use of set_config_file macro which has a insensitive parameter. Perhaps ansible needs the same parameter, as ansible_set_config_file doesn't have one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea, I'll work on adding the insensitive capabilities for ansible_set_config_file. Should this change be here or should I open up a new PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dodys excellent idea!

@yunimoo If the change of the macro would be large it would be better to have it as a separate PR.

@dodys dodys added Ubuntu Ubuntu product related. Ansible Ansible remediation update. STIG STIG Benchmark related. ok-to-test Used by openshift-ci bot. and removed needs-ok-to-test Used by openshift-ci bot. labels Aug 12, 2024
@dodys dodys requested a review from a team August 12, 2024 08:18
@ghost ghost force-pushed the add-remediation-ubtu-20-010216 branch from 83fe180 to cee3639 Compare August 12, 2024 18:09
This commit will add in ansible remediation for audispd plugin which also ensures that the plugin is enabled within au-remote.conf.
@ghost ghost force-pushed the add-remediation-ubtu-20-010216 branch from cee3639 to 293f09c Compare August 19, 2024 12:39
Copy link

codeclimate bot commented Aug 19, 2024

Code Climate has analyzed commit 293f09c 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 59.4% (0.0% change).

View more on Code Climate.

@jan-cerny
Copy link
Collaborator

/packit build

Copy link
Contributor

@dodys dodys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@jan-cerny if you agree we can merge this and the other PR was open in #12314 (currently WIP)

@jan-cerny jan-cerny merged commit cde6314 into ComplianceAsCode:master Aug 21, 2024
96 of 98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. ok-to-test Used by openshift-ci bot. STIG STIG Benchmark related. Ubuntu Ubuntu product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants