Blame SOURCES/scap-security-guide-0.1.58-RHEL_08_010360-PR_7209.patch

76240a
From 386f9787ceac9b0fc732bcd5fd5f7174254922b3 Mon Sep 17 00:00:00 2001
76240a
From: Matthew Burket <mburket@redhat.com>
76240a
Date: Thu, 15 Jul 2021 14:33:44 -0500
76240a
Subject: [PATCH]  Update 'Configure Notification of Post-AIDE Scan Details'
76240a
76240a
Added
76240a
- Ansible fix for this rule
76240a
- Configurable email for sending notification email for AIDE alerts
76240a
---
76240a
 .../aide_scan_notification/ansible/shared.yml | 28 +++++++++++++++++++
76240a
 .../aide_scan_notification/bash/shared.sh     | 18 ++++++++----
76240a
 .../aide/aide_scan_notification/rule.yml      |  2 ++
76240a
 .../var_aide_scan_notification_email.var      | 16 +++++++++++
76240a
 4 files changed, 58 insertions(+), 6 deletions(-)
76240a
 create mode 100644 linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/ansible/shared.yml
76240a
 create mode 100644 linux_os/guide/system/software/integrity/software-integrity/var_aide_scan_notification_email.var
76240a
76240a
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/ansible/shared.yml
76240a
new file mode 100644
76240a
index 00000000000..5c11fc1719e
76240a
--- /dev/null
76240a
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/ansible/shared.yml
76240a
@@ -0,0 +1,28 @@
76240a
+# platform = Red Hat Enterprise Linux 7,Red Hat Enterprise Linux 8,Red Hat Virtualization 4,multi_platform_wrlinux,multi_platform_ol,multi_platform_sle
76240a
+# reboot = false
76240a
+# strategy = restrict
76240a
+# complexity = low
76240a
+# disruption = low
76240a
+{{% if product in ["sle12", "sle15"] %}}
76240a
+    {{% set aide_path = "/usr/bin/aide" %}}
76240a
+{{% else %}}
76240a
+    {{% set aide_path = "/usr/sbin/aide" %}}
76240a
+{{% endif %}}
76240a
+
76240a
+- (xccdf-var var_aide_scan_notification_email)
76240a
+
76240a
+- name: "Ensure AIDE is installed"
76240a
+  package:
76240a
+    name: "{{ item }}"
76240a
+    state: present
76240a
+  with_items:
76240a
+    - aide
76240a
+
76240a
+- name: "{{{ rule_title }}}"
76240a
+  cron:
76240a
+    name: "run AIDE check"
76240a
+    minute: 05
76240a
+    hour: 04
76240a
+    weekday: 0
76240a
+    user: root
76240a
+    job: '{{{aide_path}}}  --check | /bin/mail -s "$(hostname) - AIDE Integrity Check" {{ var_aide_scan_notification_email }}'
76240a
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/bash/shared.sh b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/bash/shared.sh
76240a
index 2f129e568b2..3cb8b72a0bd 100644
76240a
--- a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/bash/shared.sh
76240a
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/bash/shared.sh
76240a
@@ -1,6 +1,16 @@
76240a
 # platform = multi_platform_all
76240a
 
76240a
+. /usr/share/scap-security-guide/remediation_functions
76240a
+
76240a
 {{{ bash_package_install("aide") }}}
76240a
+{{{ bash_instantiate_variables("var_aide_scan_notification_email") }}}
76240a
+{{% if product in ["sle12", "sle15"] %}}
76240a
+    {{% set aide_path = "/usr/bin/aide" %}}
76240a
+{{% else %}}
76240a
+    {{% set aide_path = "/usr/sbin/aide" %}}
76240a
+{{% endif %}}
76240a
+
76240a
+
76240a
 
76240a
 CRONTAB=/etc/crontab
76240a
 CRONDIRS='/etc/cron.d /etc/cron.daily /etc/cron.weekly /etc/cron.monthly'
76240a
@@ -14,11 +24,7 @@ if [ -f /var/spool/cron/root ]; then
76240a
 	VARSPOOL=/var/spool/cron/root
76240a
 fi
76240a
 
76240a
-if ! grep -qR '^.*\/usr\/sbin\/aide\s*\-\-check.*|.*\/bin\/mail\s*-s\s*".*"\s*root@.*$' $CRONTAB_EXIST $VARSPOOL $CRONDIRS; then
76240a
-{{% if product in ["sle12", "sle15"] %}}
76240a
-	echo '0 5 * * * root /usr/bin/aide  --check | /bin/mail -s "$(hostname) - AIDE Integrity Check" root@localhost' >> $CRONTAB
76240a
-{{% else %}}
76240a
-	echo '0 5 * * * root /usr/sbin/aide  --check | /bin/mail -s "$(hostname) - AIDE Integrity Check" root@localhost' >> $CRONTAB
76240a
-{{% endif %}}
76240a
+if ! grep -qR '^.*{{{aide_path}}}\s*\-\-check.*|.*\/bin\/mail\s*-s\s*".*"\s*.*@.*$' $CRONTAB_EXIST $VARSPOOL $CRONDIRS; then
76240a
+	echo "0 5 * * * root {{{ aide_path }}}  --check | /bin/mail -s \"\$(hostname) - AIDE Integrity Check\" $var_aide_scan_notification_email" >> $CRONTAB
76240a
 fi
76240a
 
76240a
diff --git a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/rule.yml b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/rule.yml
76240a
index 51dae72ee6d..cb35c5c642d 100644
76240a
--- a/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/rule.yml
76240a
+++ b/linux_os/guide/system/software/integrity/software-integrity/aide/aide_scan_notification/rule.yml
76240a
@@ -57,3 +57,5 @@ ocil: |-
76240a
     
$ grep aide /etc/crontab
76240a
     The output should return something similar to the following:
76240a
     
05 4 * * * root /usr/sbin/aide --check | /bin/mail -s "$(hostname) - AIDE Integrity Check" root@localhost
76240a
+    The email address that the notifications are sent to can be changed by overriding
76240a
+    
<sub idref="var_aide_scan_notification_email" />
.
76240a
diff --git a/linux_os/guide/system/software/integrity/software-integrity/var_aide_scan_notification_email.var b/linux_os/guide/system/software/integrity/software-integrity/var_aide_scan_notification_email.var
76240a
new file mode 100644
76240a
index 00000000000..75b9f5d2650
76240a
--- /dev/null
76240a
+++ b/linux_os/guide/system/software/integrity/software-integrity/var_aide_scan_notification_email.var
76240a
@@ -0,0 +1,16 @@
76240a
+documentation_complete: true
76240a
+
76240a
+title: Integrity Scan Notification Email Address
76240a
+
76240a
+description: |-
76240a
+    Specify the email address for designated personnel if baseline
76240a
+    configurations are changed in an unauthorized manner.
76240a
+
76240a
+type: string
76240a
+
76240a
+operator: equals
76240a
+
76240a
+interactive: true
76240a
+
76240a
+options:
76240a
+    default: root@localhost