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

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