|
|
dac76a |
From 2f6ceca58e64ab6c362afef629ac6ac235b0abe9 Mon Sep 17 00:00:00 2001
|
|
|
dac76a |
From: Watson Sato <wsato@redhat.com>
|
|
|
dac76a |
Date: Fri, 15 May 2020 11:52:35 +0200
|
|
|
dac76a |
Subject: [PATCH 1/4] audit_rules_system_shutdown: Don't remove unrelated line
|
|
|
dac76a |
|
|
|
dac76a |
Very likey a copy-pasta error from bash remediation for
|
|
|
dac76a |
audit_rules_immutable
|
|
|
dac76a |
---
|
|
|
dac76a |
.../audit_rules_system_shutdown/bash/shared.sh | 2 +-
|
|
|
dac76a |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
dac76a |
|
|
|
dac76a |
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh
|
|
|
dac76a |
index 1c9748ce9b..b56513cdcd 100644
|
|
|
dac76a |
--- a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh
|
|
|
dac76a |
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh
|
|
|
dac76a |
@@ -8,7 +8,7 @@
|
|
|
dac76a |
# files to check if '-f .*' setting is present in that '*.rules' file already.
|
|
|
dac76a |
# If found, delete such occurrence since auditctl(8) manual page instructs the
|
|
|
dac76a |
# '-f 2' rule should be placed as the last rule in the configuration
|
|
|
dac76a |
-find /etc/audit /etc/audit/rules.d -maxdepth 1 -type f -name '*.rules' -exec sed -i '/-e[[:space:]]\+.*/d' {} ';'
|
|
|
dac76a |
+find /etc/audit /etc/audit/rules.d -maxdepth 1 -type f -name '*.rules' -exec sed -i '/-f[[:space:]]\+.*/d' {} ';'
|
|
|
dac76a |
|
|
|
dac76a |
# Append '-f 2' requirement at the end of both:
|
|
|
dac76a |
# * /etc/audit/audit.rules file (for auditctl case)
|
|
|
dac76a |
|
|
|
dac76a |
From 189aed2c79620940438fc025a3cb9919cd8ee80a Mon Sep 17 00:00:00 2001
|
|
|
dac76a |
From: Watson Sato <wsato@redhat.com>
|
|
|
dac76a |
Date: Fri, 15 May 2020 12:12:21 +0200
|
|
|
dac76a |
Subject: [PATCH 2/4] Add Ansible for audit_rules_system_shutdown
|
|
|
dac76a |
|
|
|
dac76a |
Along with very basic test scenarios
|
|
|
dac76a |
---
|
|
|
dac76a |
.../ansible/shared.yml | 28 +++++++++++++++++++
|
|
|
dac76a |
.../tests/augen_correct.pass.sh | 4 +++
|
|
|
dac76a |
.../tests/augen_e_2_immutable.fail.sh | 3 ++
|
|
|
dac76a |
3 files changed, 35 insertions(+)
|
|
|
dac76a |
create mode 100644 linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/ansible/shared.yml
|
|
|
dac76a |
create mode 100644 linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_correct.pass.sh
|
|
|
dac76a |
create mode 100644 linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_e_2_immutable.fail.sh
|
|
|
dac76a |
|
|
|
dac76a |
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/ansible/shared.yml b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/ansible/shared.yml
|
|
|
dac76a |
new file mode 100644
|
|
|
dac76a |
index 0000000000..b9e8fa87fa
|
|
|
dac76a |
--- /dev/null
|
|
|
dac76a |
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/ansible/shared.yml
|
|
|
dac76a |
@@ -0,0 +1,28 @@
|
|
|
dac76a |
+# platform = multi_platform_all
|
|
|
dac76a |
+# reboot = true
|
|
|
dac76a |
+# strategy = restrict
|
|
|
dac76a |
+# complexity = low
|
|
|
dac76a |
+# disruption = low
|
|
|
dac76a |
+
|
|
|
dac76a |
+- name: Collect all files from /etc/audit/rules.d with .rules extension
|
|
|
dac76a |
+ find:
|
|
|
dac76a |
+ paths: "/etc/audit/rules.d/"
|
|
|
dac76a |
+ patterns: "*.rules"
|
|
|
dac76a |
+ register: find_rules_d
|
|
|
dac76a |
+
|
|
|
dac76a |
+- name: Remove the -f option from all Audit config files
|
|
|
dac76a |
+ lineinfile:
|
|
|
dac76a |
+ path: "{{ item }}"
|
|
|
dac76a |
+ regexp: '^\s*(?:-f)\s+.*$'
|
|
|
dac76a |
+ state: absent
|
|
|
dac76a |
+ loop: "{{ find_rules_d.files | map(attribute='path') | list + ['/etc/audit/audit.rules'] }}"
|
|
|
dac76a |
+
|
|
|
dac76a |
+- name: Add Audit -f option into /etc/audit/rules.d/immutable.rules and /etc/audit/audit.rules
|
|
|
dac76a |
+ lineinfile:
|
|
|
dac76a |
+ path: "{{ item }}"
|
|
|
dac76a |
+ create: True
|
|
|
dac76a |
+ line: "-f 2"
|
|
|
dac76a |
+ loop:
|
|
|
dac76a |
+ - "/etc/audit/audit.rules"
|
|
|
dac76a |
+ - "/etc/audit/rules.d/immutable.rules"
|
|
|
dac76a |
+
|
|
|
dac76a |
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_correct.pass.sh b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_correct.pass.sh
|
|
|
dac76a |
new file mode 100644
|
|
|
dac76a |
index 0000000000..0587b937e0
|
|
|
dac76a |
--- /dev/null
|
|
|
dac76a |
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_correct.pass.sh
|
|
|
dac76a |
@@ -0,0 +1,4 @@
|
|
|
dac76a |
+#!/bin/bash
|
|
|
dac76a |
+
|
|
|
dac76a |
+echo "-e 2" > /etc/audit/rules.d/immutable.rules
|
|
|
dac76a |
+echo "-f 2" >> /etc/audit/rules.d/immutable.rules
|
|
|
dac76a |
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_e_2_immutable.fail.sh b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_e_2_immutable.fail.sh
|
|
|
dac76a |
new file mode 100644
|
|
|
dac76a |
index 0000000000..fa5b7231df
|
|
|
dac76a |
--- /dev/null
|
|
|
dac76a |
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/tests/augen_e_2_immutable.fail.sh
|
|
|
dac76a |
@@ -0,0 +1,3 @@
|
|
|
dac76a |
+#!/bin/bash
|
|
|
dac76a |
+
|
|
|
dac76a |
+echo "-e 2" > /etc/audit/rules.d/immutable.rules
|
|
|
dac76a |
|
|
|
dac76a |
From d693af1e00521d85b5745001aa13860bdac16632 Mon Sep 17 00:00:00 2001
|
|
|
dac76a |
From: Watson Sato <wsato@redhat.com>
|
|
|
dac76a |
Date: Fri, 15 May 2020 14:06:08 +0200
|
|
|
dac76a |
Subject: [PATCH 3/4] Clarify audit_rules_immutable Ansible task name
|
|
|
dac76a |
|
|
|
dac76a |
---
|
|
|
dac76a |
.../audit_rules_immutable/ansible/shared.yml | 2 +-
|
|
|
dac76a |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
dac76a |
|
|
|
dac76a |
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml
|
|
|
dac76a |
index 5ac7b3dabb..1cafb744cc 100644
|
|
|
dac76a |
--- a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml
|
|
|
dac76a |
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_immutable/ansible/shared.yml
|
|
|
dac76a |
@@ -17,7 +17,7 @@
|
|
|
dac76a |
state: absent
|
|
|
dac76a |
loop: "{{ find_rules_d.files | map(attribute='path') | list + ['/etc/audit/audit.rules'] }}"
|
|
|
dac76a |
|
|
|
dac76a |
-- name: Insert configuration into /etc/audit/rules.d/immutable.rules and /etc/audit/audit.rules
|
|
|
dac76a |
+- name: Add Audit -e option into /etc/audit/rules.d/immutable.rules and /etc/audit/audit.rules
|
|
|
dac76a |
lineinfile:
|
|
|
dac76a |
path: "{{ item }}"
|
|
|
dac76a |
create: True
|
|
|
dac76a |
|
|
|
dac76a |
From 92d38c1968059e53e3ab20f46f5ce0885a989aee Mon Sep 17 00:00:00 2001
|
|
|
dac76a |
From: Watson Sato <wsato@redhat.com>
|
|
|
dac76a |
Date: Tue, 19 May 2020 11:02:56 +0200
|
|
|
dac76a |
Subject: [PATCH 4/4] Remove misleading comments in system shutdown fix
|
|
|
dac76a |
|
|
|
dac76a |
---
|
|
|
dac76a |
.../audit_rules_system_shutdown/bash/shared.sh | 8 --------
|
|
|
dac76a |
1 file changed, 8 deletions(-)
|
|
|
dac76a |
|
|
|
dac76a |
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh
|
|
|
dac76a |
index b56513cdcd..a349bb1ca1 100644
|
|
|
dac76a |
--- a/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh
|
|
|
dac76a |
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_rules_system_shutdown/bash/shared.sh
|
|
|
dac76a |
@@ -4,16 +4,8 @@
|
|
|
dac76a |
#
|
|
|
dac76a |
# /etc/audit/audit.rules, (for auditctl case)
|
|
|
dac76a |
# /etc/audit/rules.d/*.rules (for augenrules case)
|
|
|
dac76a |
-#
|
|
|
dac76a |
-# files to check if '-f .*' setting is present in that '*.rules' file already.
|
|
|
dac76a |
-# If found, delete such occurrence since auditctl(8) manual page instructs the
|
|
|
dac76a |
-# '-f 2' rule should be placed as the last rule in the configuration
|
|
|
dac76a |
find /etc/audit /etc/audit/rules.d -maxdepth 1 -type f -name '*.rules' -exec sed -i '/-f[[:space:]]\+.*/d' {} ';'
|
|
|
dac76a |
|
|
|
dac76a |
-# Append '-f 2' requirement at the end of both:
|
|
|
dac76a |
-# * /etc/audit/audit.rules file (for auditctl case)
|
|
|
dac76a |
-# * /etc/audit/rules.d/immutable.rules (for augenrules case)
|
|
|
dac76a |
-
|
|
|
dac76a |
for AUDIT_FILE in "/etc/audit/audit.rules" "/etc/audit/rules.d/immutable.rules"
|
|
|
dac76a |
do
|
|
|
dac76a |
echo '' >> $AUDIT_FILE
|