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 directory_ownership_var_log_audit #11012

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low

- name: '{{{ rule_title }}} - Register Audit Configuration Text'
ansible.builtin.slurp:
src: /etc/audit/auditd.conf
register: auditd_config_slurp

- name: '{{{ rule_title }}} - Set Permissions Custom Location'
ansible.builtin.file:
owner: root
path: "{{ auditd_config_slurp['content'] | b64decode | regex_findall('\nlog_file\\s*=\\s*(.+)') | default(['/var/log/audit/audit.log',], boolean=True) | first | dirname }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

sed -i "/\s*log_file.*/d" /etc/audit/auditd.conf
echo "log_file = /var/log/audit2/audit.log" >> /etc/audit/auditd.conf

mkdir /var/log/audit2
touch /var/log/audit2/audit.log
chown root /var/log/audit2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

sed -i "/\s*log_file.*/d" /etc/audit/auditd.conf

useradd testuser_123
chown testuser_123 /var/log/audit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved

sed -i "/\s*log_file.*/d" /etc/audit/auditd.conf
echo "log_file = /var/log/audit2/audit.log" >> /etc/audit/auditd.conf

mkdir /var/log/audit2
touch /var/log/audit2/audit.log
useradd testuser_123
chown testuser_123 /var/log/audit2