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

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