Blame SOURCES/scap-security-guide-0.1.67-firewalld_sshd_port_enabled_tests-PR_10162.patch

cf5f1e
From a8cea205d5f9f975ca03ef39e79d18698236cfe2 Mon Sep 17 00:00:00 2001
cf5f1e
From: Watson Sato <wsato@redhat.com>
cf5f1e
Date: Mon, 13 Feb 2023 17:49:14 +0100
cf5f1e
Subject: [PATCH 3/5] Change custom zones check in firewalld_sshd_port_enabled
cf5f1e
cf5f1e
Patch-name: scap-security-guide-0.1.67-firewalld_sshd_port_enabled_tests-PR_10162.patch
cf5f1e
Patch-status: Change custom zones check in firewalld_sshd_port_enabled
cf5f1e
---
cf5f1e
 .../oval/shared.xml                           | 68 +++++++++++++++----
cf5f1e
 1 file changed, 54 insertions(+), 14 deletions(-)
cf5f1e
cf5f1e
diff --git a/linux_os/guide/services/ssh/ssh_server/firewalld_sshd_port_enabled/oval/shared.xml b/linux_os/guide/services/ssh/ssh_server/firewalld_sshd_port_enabled/oval/shared.xml
cf5f1e
index 4adef2e53f..d7c96665b4 100644
cf5f1e
--- a/linux_os/guide/services/ssh/ssh_server/firewalld_sshd_port_enabled/oval/shared.xml
cf5f1e
+++ b/linux_os/guide/services/ssh/ssh_server/firewalld_sshd_port_enabled/oval/shared.xml
cf5f1e
@@ -133,9 +133,10 @@
cf5f1e
          OVAL resources in order to detect and assess only active zone, which are zones with at
cf5f1e
          least one NIC assigned to it. Since it was possible to easily have the list of active
cf5f1e
          zones, it was cumbersome to use that list in other OVAL objects without introduce a high
cf5f1e
-         level of complexity to make sure environments with multiple NICs and multiple zones are
cf5f1e
-         in use. So, in favor of simplicity and readbility it was decided to work with a static
cf5f1e
-         list. It means that, in the future, it is possible this list needs to be updated. -->
cf5f1e
+         level of complexity to ensure proper assessment in environments where multiple NICs and
cf5f1e
+         multiple zones are in use. So, in favor of simplicity and readbility it was decided to
cf5f1e
+         work with a static list. It means that, in the future, it is possible this list needs to
cf5f1e
+         be updated. -->
cf5f1e
     
cf5f1e
         datatype="string"
cf5f1e
         comment="Regex containing the list of zones files delivered in the firewalld package">
cf5f1e
@@ -145,23 +146,62 @@
cf5f1e
     
cf5f1e
          in the /etc/firewalld/zones dir in order to override the default zone settings. The same
cf5f1e
          directory is applicable for new zones created by the administrator. Therefore, all files
cf5f1e
-         in this directory should also allow SSH. -->
cf5f1e
-    
cf5f1e
+         in this directory should also allow SSH.
cf5f1e
+         This test was updated in a reaction to https://github.com/OpenSCAP/openscap/issues/1923,
cf5f1e
+         which changed the behaviour of xmlfilecontent probe in OpenSCAP 1.3.7. Currently, a
cf5f1e
+         variable test is the simplest way to check if all custom zones are allowing ssh, but have
cf5f1e
+         an impact in transparency since the objects are not shown in reports. The transparency
cf5f1e
+         impact can be workarounded by using other OVAL objects, but this would impact in
cf5f1e
+         readability and would increase complexity. This solution is in favor of simplicity. -->
cf5f1e
+    
cf5f1e
         check="all" check_existence="at_least_one_exists" version="1"
cf5f1e
         comment="SSH service is defined in all zones created or modified by the administrator">
cf5f1e
-      <ind:object object_ref="object_firewalld_sshd_port_enabled_zone_files_etc"/>
cf5f1e
-      <ind:state state_ref="state_firewalld_sshd_port_enabled_zone_files_etc"/>
cf5f1e
-    </ind:xmlfilecontent_test>
cf5f1e
+        
cf5f1e
+            object_ref="object_firewalld_sshd_port_enabled_custom_zone_files_with_ssh_count"/>
cf5f1e
+        <ind:state state_ref="state_firewalld_sshd_port_enabled_custom_zone_files_count"/>
cf5f1e
+    </ind:variable_test>
cf5f1e
+
cf5f1e
+    
cf5f1e
+        version="1">
cf5f1e
+      <ind:var_ref>var_firewalld_sshd_port_enabled_custom_zone_files_with_ssh_count</ind:var_ref>
cf5f1e
+    </ind:variable_object>
cf5f1e
+
cf5f1e
+    
cf5f1e
+        datatype="int" version="1"
cf5f1e
+        comment="Variable including number of custom zone files allowing ssh">
cf5f1e
+        <count>
cf5f1e
+            
cf5f1e
+                object_ref="object_firewalld_sshd_port_enabled_zone_files_etc"/>
cf5f1e
+        </count>
cf5f1e
+    </local_variable>
cf5f1e
 
cf5f1e
     <ind:xmlfilecontent_object id="object_firewalld_sshd_port_enabled_zone_files_etc" version="1">
cf5f1e
-      <ind:path>/etc/firewalld/zones</ind:path>
cf5f1e
-      <ind:filename operation="pattern match">^.*\.xml$</ind:filename>
cf5f1e
-      <ind:xpath>/zone/service[@name='ssh']</ind:xpath>
cf5f1e
+        <ind:path>/etc/firewalld/zones</ind:path>
cf5f1e
+        <ind:filename operation="pattern match">^.*\.xml$</ind:filename>
cf5f1e
+        <ind:xpath>/zone/service[@name='ssh']</ind:xpath>
cf5f1e
     </ind:xmlfilecontent_object>
cf5f1e
 
cf5f1e
-    <ind:xmlfilecontent_state id="state_firewalld_sshd_port_enabled_zone_files_etc" version="1">
cf5f1e
-      <ind:xpath>/zone/service[@name='ssh']</ind:xpath>
cf5f1e
-    </ind:xmlfilecontent_state>
cf5f1e
+    
cf5f1e
+        version="1">
cf5f1e
+        
cf5f1e
+            var_ref="var_firewalld_sshd_port_enabled_custom_zone_files_count"/>
cf5f1e
+    </ind:variable_state>
cf5f1e
+
cf5f1e
+    
cf5f1e
+        datatype="int" version="1"
cf5f1e
+        comment="Variable including number of custom zone files present in /etc/firewalld/zones">
cf5f1e
+        <count>
cf5f1e
+            
cf5f1e
+                object_ref="object_firewalld_sshd_port_enabled_custom_zone_files"/>
cf5f1e
+        </count>
cf5f1e
+    </local_variable>
cf5f1e
+
cf5f1e
+    <unix:file_object id="object_firewalld_sshd_port_enabled_custom_zone_files" version="1">
cf5f1e
+        
cf5f1e
+            recurse_file_system="local"/>
cf5f1e
+        <unix:path>/etc/firewalld/zones</unix:path>
cf5f1e
+        <unix:filename operation="pattern match">^.*\.xml$</unix:filename>
cf5f1e
+    </unix:file_object>
cf5f1e
 
cf5f1e
     
cf5f1e
     
cf5f1e
-- 
cf5f1e
2.39.1
cf5f1e