Blame SOURCES/scap-security-guide-0.1.51-fix_rsyslog_rules_PR_5763.patch

ac2e16
From 179cf6b43b8f10b4907267d976cb503066710e6f Mon Sep 17 00:00:00 2001
ac2e16
From: Watson Sato <wsato@redhat.com>
ac2e16
Date: Thu, 14 May 2020 01:20:53 +0200
ac2e16
Subject: [PATCH 1/4] Do not take paths from include or IncludeConfig
ac2e16
ac2e16
All paths in /etc/rsyslog.conf were taken as log files, but paths
ac2e16
in lines containing "include" or "$IncludeConfig" are config files.
ac2e16
ac2e16
Let's not take them in as log files
ac2e16
---
ac2e16
 .../rsyslog_files_permissions/oval/shared.xml          | 10 ++++++++++
ac2e16
 1 file changed, 10 insertions(+)
ac2e16
ac2e16
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
ac2e16
index a78cd69df2..c74f3da3f5 100644
ac2e16
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
ac2e16
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
ac2e16
@@ -87,8 +87,18 @@
ac2e16
     -->
ac2e16
     <ind:pattern operation="pattern match">^[^\s#\$]+[\s]+.*[\s]+-?(/+[^:;\s]+);*.*$</ind:pattern>
ac2e16
     <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
ac2e16
+    <filter action="exclude">state_ignore_include_paths</filter>
ac2e16
   </ind:textfilecontent54_object>
ac2e16
 
ac2e16
+  <ind:textfilecontent54_state id="state_ignore_include_paths" comment="ignore" version="1">
ac2e16
+    
ac2e16
+         include() or $IncludeConfig statements.
ac2e16
+         These paths are conf files, not log files. Their permissions don't need to be as
ac2e16
+         required for log files, thus, lets exclude them from the list of objects found
ac2e16
+    -->
ac2e16
+    <ind:text operation="pattern match">(?:file="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+)</ind:text>
ac2e16
+  </ind:textfilecontent54_state>
ac2e16
+
ac2e16
   
ac2e16
        retrieved from the different rsyslog configuration files
ac2e16
   -->
ac2e16
ac2e16
From 4a408d29313d8ea5aed4fa65cacad86f8078159c Mon Sep 17 00:00:00 2001
ac2e16
From: Watson Sato <wsato@redhat.com>
ac2e16
Date: Thu, 14 May 2020 00:16:37 +0200
ac2e16
Subject: [PATCH 2/4] Fix permissions of files referenced by include()
ac2e16
ac2e16
The remediation script also needs to parse the files included via
ac2e16
"include()".
ac2e16
The awk also takes into consideration the multiline aspect.
ac2e16
---
ac2e16
 .../rsyslog_files_permissions/bash/shared.sh                  | 4 +++-
ac2e16
 1 file changed, 3 insertions(+), 1 deletion(-)
ac2e16
ac2e16
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
ac2e16
index 6cbf0c6a24..dca35301e7 100644
ac2e16
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
ac2e16
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
ac2e16
@@ -6,12 +6,14 @@ RSYSLOG_ETC_CONFIG="/etc/rsyslog.conf"
ac2e16
 # * And also the log file paths listed after rsyslog's $IncludeConfig directive
ac2e16
 #   (store the result into array for the case there's shell glob used as value of IncludeConfig)
ac2e16
 readarray -t RSYSLOG_INCLUDE_CONFIG < <(grep -e "\$IncludeConfig[[:space:]]\+[^[:space:];]\+" /etc/rsyslog.conf | cut -d ' ' -f 2)
ac2e16
+readarray -t RSYSLOG_INCLUDE < <(awk '/)/{f=0} /include\(/{f=1} f{nf=gensub(".*file=\"(\\S+)\".*","\\1",1); if($0!=nf){print nf}}' /etc/rsyslog.conf)
ac2e16
+
ac2e16
 # Declare an array to hold the final list of different log file paths
ac2e16
 declare -a LOG_FILE_PATHS
ac2e16
 
ac2e16
 # Browse each file selected above as containing paths of log files
ac2e16
 # ('/etc/rsyslog.conf' and '/etc/rsyslog.d/*.conf' in the default configuration)
ac2e16
-for LOG_FILE in "${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}"
ac2e16
+for LOG_FILE in "${RSYSLOG_ETC_CONFIG}" "${RSYSLOG_INCLUDE_CONFIG[@]}" "${RSYSLOG_INCLUDE[@]}"
ac2e16
 do
ac2e16
 	# From each of these files extract just particular log file path(s), thus:
ac2e16
 	# * Ignore lines starting with space (' '), comment ('#"), or variable syntax ('$') characters,
ac2e16
ac2e16
From 812e9b487e3c11a18e5e3a965ac23ec1a0d64e91 Mon Sep 17 00:00:00 2001
ac2e16
From: Watson Sato <wsato@redhat.com>
ac2e16
Date: Fri, 15 May 2020 15:53:58 +0200
ac2e16
Subject: [PATCH 3/4] Make regex for include file more strict
ac2e16
ac2e16
For some reason gensub in awk doesn't support non capturing group.
ac2e16
So the group with OR is capturing and we substitute everyting with the
ac2e16
second group, witch matches the file path.
ac2e16
---
ac2e16
 .../rsyslog_files_permissions/bash/shared.sh                    | 2 +-
ac2e16
 1 file changed, 1 insertion(+), 1 deletion(-)
ac2e16
ac2e16
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
ac2e16
index dca35301e7..99d2d0e794 100644
ac2e16
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
ac2e16
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/bash/shared.sh
ac2e16
@@ -6,7 +6,7 @@ RSYSLOG_ETC_CONFIG="/etc/rsyslog.conf"
ac2e16
 # * And also the log file paths listed after rsyslog's $IncludeConfig directive
ac2e16
 #   (store the result into array for the case there's shell glob used as value of IncludeConfig)
ac2e16
 readarray -t RSYSLOG_INCLUDE_CONFIG < <(grep -e "\$IncludeConfig[[:space:]]\+[^[:space:];]\+" /etc/rsyslog.conf | cut -d ' ' -f 2)
ac2e16
-readarray -t RSYSLOG_INCLUDE < <(awk '/)/{f=0} /include\(/{f=1} f{nf=gensub(".*file=\"(\\S+)\".*","\\1",1); if($0!=nf){print nf}}' /etc/rsyslog.conf)
ac2e16
+readarray -t RSYSLOG_INCLUDE < <(awk '/)/{f=0} /include\(/{f=1} f{nf=gensub("^(include\\(|\\s*)file=\"(\\S+)\".*","\\2",1); if($0!=nf){print nf}}' /etc/rsyslog.conf)
ac2e16
 
ac2e16
 # Declare an array to hold the final list of different log file paths
ac2e16
 declare -a LOG_FILE_PATHS
ac2e16
ac2e16
From c49f8aaf717313a41bbdfca188dd491a13d1133e Mon Sep 17 00:00:00 2001
ac2e16
From: Watson Sato <wsato@redhat.com>
ac2e16
Date: Fri, 15 May 2020 16:55:02 +0200
ac2e16
Subject: [PATCH 4/4] Extend OVAL fix to groupownership and ownership
ac2e16
ac2e16
These three files basically work the same way
ac2e16
---
ac2e16
 .../rsyslog_files_groupownership/oval/shared.xml       | 10 ++++++++++
ac2e16
 .../rsyslog_files_ownership/oval/shared.xml            | 10 ++++++++++
ac2e16
 .../rsyslog_files_permissions/oval/shared.xml          |  4 ++--
ac2e16
 3 files changed, 22 insertions(+), 2 deletions(-)
ac2e16
ac2e16
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml
ac2e16
index 5828f25321..9941e2b94f 100644
ac2e16
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml
ac2e16
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_groupownership/oval/shared.xml
ac2e16
@@ -86,8 +86,18 @@
ac2e16
     -->
ac2e16
     <ind:pattern operation="pattern match">^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*.*$</ind:pattern>
ac2e16
     <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
ac2e16
+    <filter action="exclude">state_groupownership_ignore_include_paths</filter>
ac2e16
   </ind:textfilecontent54_object>
ac2e16
 
ac2e16
+  <ind:textfilecontent54_state id="state_groupownership_ignore_include_paths" comment="ignore" version="1">
ac2e16
+    
ac2e16
+         include() or $IncludeConfig statements.
ac2e16
+         These paths are conf files, not log files. Their groupownership don't need to be as
ac2e16
+         required for log files, thus, lets exclude them from the list of objects found
ac2e16
+    -->
ac2e16
+    <ind:text operation="pattern match">(?:file="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+)</ind:text>
ac2e16
+  </ind:textfilecontent54_state>
ac2e16
+
ac2e16
   
ac2e16
        retrieved from the different rsyslog configuration files
ac2e16
   -->
ac2e16
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml
ac2e16
index 3c46eab6d6..29dd1a989e 100644
ac2e16
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml
ac2e16
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_ownership/oval/shared.xml
ac2e16
@@ -83,8 +83,18 @@
ac2e16
     -->
ac2e16
     <ind:pattern operation="pattern match">^[^(\s|#|\$)]+[\s]+.*[\s]+-?(/+[^:;\s]+);*.*$</ind:pattern>
ac2e16
     <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
ac2e16
+    <filter action="exclude">state_owner_ignore_include_paths</filter>
ac2e16
   </ind:textfilecontent54_object>
ac2e16
 
ac2e16
+  <ind:textfilecontent54_state id="state_owner_ignore_include_paths" comment="ignore" version="1">
ac2e16
+    
ac2e16
+         include() or $IncludeConfig statements.
ac2e16
+         These paths are conf files, not log files. Their owner don't need to be as
ac2e16
+         required for log files, thus, lets exclude them from the list of objects found
ac2e16
+    -->
ac2e16
+    <ind:text operation="pattern match">(?:file="[^\s;]+"|\$IncludeConfig[\s]+[^\s;]+)</ind:text>
ac2e16
+  </ind:textfilecontent54_state>
ac2e16
+
ac2e16
   
ac2e16
        retrieved from the different rsyslog configuration files
ac2e16
   -->
ac2e16
diff --git a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
ac2e16
index c74f3da3f5..da37a15b8c 100644
ac2e16
--- a/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
ac2e16
+++ b/linux_os/guide/system/logging/ensure_rsyslog_log_file_configuration/rsyslog_files_permissions/oval/shared.xml
ac2e16
@@ -87,10 +87,10 @@
ac2e16
     -->
ac2e16
     <ind:pattern operation="pattern match">^[^\s#\$]+[\s]+.*[\s]+-?(/+[^:;\s]+);*.*$</ind:pattern>
ac2e16
     <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
ac2e16
-    <filter action="exclude">state_ignore_include_paths</filter>
ac2e16
+    <filter action="exclude">state_permissions_ignore_include_paths</filter>
ac2e16
   </ind:textfilecontent54_object>
ac2e16
 
ac2e16
-  <ind:textfilecontent54_state id="state_ignore_include_paths" comment="ignore" version="1">
ac2e16
+  <ind:textfilecontent54_state id="state_permissions_ignore_include_paths" comment="ignore" version="1">
ac2e16
     
ac2e16
          include() or $IncludeConfig statements.
ac2e16
          These paths are conf files, not log files. Their permissions don't need to be as