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

Add ansible remediation for log perm for UBTU-20-010122 #11091

Conversation

dexterle
Copy link
Contributor

@dexterle dexterle commented Sep 8, 2023

Description:

  • Fix UBTU-20-010122
  • Add ansible remediation for ubuntu, and fix styling

Rationale:

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-010122"

To test changes with bash, run the remediation sections: xccdf_org.ssgproject.content_rule_file_permissions_var_log_audit

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

git checkout dexterle:add-manual-stig-ubtu-20-v1r9

This STIG can not be tested with the latest Ubuntu 2004 Benchmark SCAP. Please perform a manual check given the check text. For reference, please review the latest artifacts: https://public.cyber.mil/stigs/downloads/

This commit will add log perm ansible remediation for ensuring all audit logs are 600 or less permissible.
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Sep 8, 2023
@dexterle
Copy link
Contributor Author

dexterle commented Sep 8, 2023

feedback: 114455d#r1319043421

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Sep 8, 2023
@openshift-ci
Copy link

openshift-ci bot commented Sep 8, 2023

Hi @dexterle. 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/test-infra repository.

@Mab879 Mab879 added Ubuntu Ubuntu product related. STIG STIG Benchmark related. labels Sep 8, 2023
@github-actions
Copy link

github-actions bot commented Sep 8, 2023

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 Sep 8, 2023

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_file_permissions_var_log_audit' differs.
--- xccdf_org.ssgproject.content_rule_file_permissions_var_log_audit
+++ xccdf_org.ssgproject.content_rule_file_permissions_var_log_audit
@@ -18,8 +18,8 @@
   - no_reboot_needed
   - restrict_strategy
 
-- name: Get audit log files
-  command: grep -iw ^log_file /etc/audit/auditd.conf
+- name: System Audit Logs Must Have Mode 0640 or Less Permissive - Get Audit Log Files
+  ansible.builtin.command: grep -iw ^log_file /etc/audit/auditd.conf
   failed_when: false
   register: log_file_exists
   when:
@@ -42,8 +42,9 @@
   - no_reboot_needed
   - restrict_strategy
 
-- name: Parse log file line
-  command: awk -F '=' '/^log_file/ {print $2}' /etc/audit/auditd.conf
+- name: System Audit Logs Must Have Mode 0640 or Less Permissive - Parse Log File
+    Line
+  ansible.builtin.command: awk -F '=' '/^log_file/ {print $2}' /etc/audit/auditd.conf
   register: log_file_line
   when:
   - '"audit" in ansible_facts.packages'
@@ -66,8 +67,9 @@
   - no_reboot_needed
   - restrict_strategy
 
-- name: Set default log_file if not set
-  set_fact:
+- name: System Audit Logs Must Have Mode 0640 or Less Permissive - Set Default log_file
+    if Not Set
+  ansible.builtin.set_fact:
     log_file: /var/log/audit/audit.log
   when:
   - '"audit" in ansible_facts.packages'
@@ -90,8 +92,9 @@
   - no_reboot_needed
   - restrict_strategy
 
-- name: Set log_file from log_file_line if not set already
-  set_fact:
+- name: System Audit Logs Must Have Mode 0640 or Less Permissive - Set log_file From
+    log_file_line if Not Set Already
+  ansible.builtin.set_fact:
     log_file: '{{ log_file_line.stdout | trim }}'
   when:
   - '"audit" in ansible_facts.packages'
@@ -114,8 +117,9 @@
   - no_reboot_needed
   - restrict_strategy
 
-- name: Apply mode to log file
-  file:
+- name: System Audit Logs Must Have Mode 0640 or Less Permissive - Apply Mode to Log
+    File
+  ansible.builtin.file:
     path: '{{ log_file }}'
     mode: 384
   failed_when: false

@codeclimate
Copy link

codeclimate bot commented Sep 8, 2023

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

View more on Code Climate.

@dexterle dexterle marked this pull request as ready for review September 11, 2023 16:51
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label Sep 11, 2023
@dexterle
Copy link
Contributor Author

feedback: 114455d#r1319043421

I believe that this PR can be enhanced if it removes the second command task with similar changes here: #11092

@dodys dodys self-assigned this Sep 12, 2023
@dodys dodys requested a review from a team September 12, 2023 08:56
{{% if 'ol' not in product and "rhel" not in product %}}
- name: Get log files group
command: grep -m 1 ^log_group /etc/audit/auditd.conf
{{% if 'ol' not in product and "rhel" not in product and "ubuntu" not in product %}}
Copy link
Contributor

Choose a reason for hiding this comment

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

this deviates from the bash remediation, please check it

@dodys dodys added ok-to-test Used by openshift-ci bot. and removed needs-ok-to-test Used by openshift-ci bot. labels Sep 12, 2023
@vojtapolasek vojtapolasek added this to the 0.1.72 milestone Nov 29, 2023
@marcusburghardt marcusburghardt modified the milestones: 0.1.72, 0.1.73 Jan 29, 2024
@vojtapolasek vojtapolasek modified the milestones: 0.1.73, 0.1.74 Apr 30, 2024
@Mab879 Mab879 modified the milestones: 0.1.74, 0.1.75 Jul 29, 2024
Copy link

openshift-ci bot commented Jul 30, 2024

@dexterle: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/4.14-images af2b256 link true /test 4.14-images
ci/prow/4.13-images af2b256 link true /test 4.13-images
ci/prow/4.15-images af2b256 link true /test 4.15-images
ci/prow/4.16-images af2b256 link true /test 4.16-images
ci/prow/4.12-images af2b256 link true /test 4.12-images
ci/prow/4.17-images af2b256 link true /test 4.17-images

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@jan-cerny
Copy link
Collaborator

ping

@dodys
Copy link
Contributor

dodys commented Aug 2, 2024

dexterle reached out last week about continuing work on this PRs, and I've asked to open new ones for a clean state. Therefore closing this one.

@dodys dodys closed this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants