Blame SOURCES/scap-security-guide-0.1.65-RHEL_08_040137_v1r8-PR_9817.patch

f6303c
From 3fba5ec874f0269d81af9bca90e524703980345d Mon Sep 17 00:00:00 2001
f6303c
From: Marcus Burghardt <maburgha@redhat.com>
f6303c
Date: Mon, 14 Nov 2022 15:46:12 +0100
f6303c
Subject: [PATCH 1/5] Update ocil and fixtext in fapolicy_default_deny
f6303c
f6303c
Rules are stored in different places depending on the system version.
f6303c
These changes are now explicit in ocil and fixtext. In RHEL8.6 it was
f6303c
introduced the rules.d feature and together the fagenrules script which
f6303c
reads and concatenate the rules from rules.d to finally save the result
f6303c
in the /etc/fapolicyd/compiled.rules file.
f6303c
---
f6303c
 .../services/fapolicyd/fapolicy_default_deny/rule.yml  | 10 +++++++++-
f6303c
 1 file changed, 9 insertions(+), 1 deletion(-)
f6303c
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml
f6303c
index 5b9a1649571..eeecd34e69a 100644
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml
f6303c
@@ -39,10 +39,14 @@ ocil: |-
f6303c
 
f6303c
     permissive = 0
f6303c
 
f6303c
-    Check that fapolicyd employs a deny-all policy on system mounts with the following command:
f6303c
+    Check that fapolicyd employs a deny-all policy on system mounts with the following commands:
f6303c
 
f6303c
+    For RHEL 8.5 systems and older:
f6303c
     $ sudo tail /etc/fapolicyd/fapolicyd.rules
f6303c
 
f6303c
+    For RHEL 8.6 systems and newer:
f6303c
+    $ sudo tail /etc/fapolicyd/compiled.rules
f6303c
+
f6303c
     allow exe=/usr/bin/python3.7 : ftype=text/x-python
f6303c
     deny_audit perm=any pattern=ld_so : all
f6303c
     deny perm=any all : all
f6303c
@@ -54,8 +58,12 @@ fixtext: |-
f6303c
 
f6303c
     permissive = 1
f6303c
 
f6303c
+    For RHEL 8.5 systems and older:
f6303c
     Build the whitelist in the "/etc/fapolicyd/fapolicyd.rules" file ensuring the last rule is "deny perm=any all : all".
f6303c
 
f6303c
+    For RHEL 8.6 systems and newer:
f6303c
+    Build the whitelist in a file within the "/etc/fapolicyd/rules.d" directory ensuring the last rule is "deny perm=any all : all".
f6303c
+
f6303c
     Once it is determined the whitelist is built correctly, set the fapolicyd to enforcing mode by editing the "permissive" line in the /etc/fapolicyd/fapolicyd.conf file.
f6303c
 
f6303c
     permissive = 0
f6303c
f6303c
From 0b4eaa7e7d96600eef42ad45524e0b4c6e003990 Mon Sep 17 00:00:00 2001
f6303c
From: Marcus Burghardt <maburgha@redhat.com>
f6303c
Date: Thu, 17 Nov 2022 09:40:20 +0100
f6303c
Subject: [PATCH 2/5] Refactored the OVAL assessment for fapolicy_default_deny
f6303c
f6303c
Firsly the existing checks were aligned to the style guides and the
f6303c
comments were reviewed. The regex used to identify the expected policy
f6303c
was also fixed since it wasn't ensuring the deny policy if defined in a
f6303c
wrong position. Finally, it was extended the assessment to consider the
f6303c
/etc/fapolicyd/compiled.rules file.
f6303c
---
f6303c
 .../fapolicy_default_deny/oval/shared.xml     | 64 +++++++++++++------
f6303c
 1 file changed, 43 insertions(+), 21 deletions(-)
f6303c
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/oval/shared.xml b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/oval/shared.xml
f6303c
index 9989459ad22..40bdcf870ca 100644
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/oval/shared.xml
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/oval/shared.xml
f6303c
@@ -4,36 +4,58 @@
f6303c
         oval_metadata("Configure Fapolicy Module to Employ a Deny-all, Permit-by-exception Policy")
f6303c
         }}}
f6303c
         <criteria>
f6303c
-        
f6303c
-        test_ref="test_fapolicy_default_deny_policy" />
f6303c
-        
f6303c
-        test_ref="test_fapolicy_default_deny_enforcement" />
f6303c
+            <criteria operator="OR">
f6303c
+                
f6303c
+                    test_ref="test_fapolicy_default_deny_policy_with_rulesd"/>
f6303c
+                
f6303c
+                    test_ref="test_fapolicy_default_deny_policy_without_rulesd"/>
f6303c
+            </criteria>
f6303c
+            
f6303c
+                test_ref="test_fapolicy_default_deny_enforcement"/>
f6303c
         </criteria>
f6303c
     </definition>
f6303c
 
f6303c
-    
f6303c
-    comment="fapolicyd employs a deny-all policy"
f6303c
-    id="test_fapolicy_default_deny_policy" version="1">
f6303c
-        <ind:object object_ref="obj_fapolicy_default_deny_policy" />
f6303c
+    
f6303c
+        check_existence="only_one_exists" check="all"
f6303c
+        comment="fapolicyd employs a deny-all policy in compiled.rules file">
f6303c
+        <ind:object object_ref="object_fapolicy_default_deny_policy_compiled_rules"/>
f6303c
     </ind:textfilecontent54_test>
f6303c
-    <ind:textfilecontent54_object id="obj_fapolicy_default_deny_policy" version="1">
f6303c
-        <ind:behaviors multiline="false" />
f6303c
+
f6303c
+    
f6303c
+        version="1">
f6303c
+        <ind:filepath>/etc/fapolicyd/compiled.rules</ind:filepath>
f6303c
+        <ind:pattern operation="pattern match">^\s*deny\s*perm=any\s*all\s*:\s*all\s*\z</ind:pattern>
f6303c
+        <ind:instance datatype="int">1</ind:instance>
f6303c
+    </ind:textfilecontent54_object>
f6303c
+
f6303c
+    
f6303c
+        check_existence="only_one_exists" check="all"
f6303c
+        comment="fapolicyd employs a deny-all policy in fapolicyd.rules file">
f6303c
+        <ind:object object_ref="object_fapolicy_default_deny_policy_fapolicyd_rules"/>
f6303c
+    </ind:textfilecontent54_test>
f6303c
+
f6303c
+    
f6303c
+        version="2">
f6303c
         <ind:filepath>/etc/fapolicyd/fapolicyd.rules</ind:filepath>
f6303c
-        <ind:pattern operation="pattern match">(^|\n)\s*deny\s*perm=any\s*all\s*:\s*all\s*$</ind:pattern>
f6303c
+        <ind:pattern operation="pattern match">^\s*deny\s*perm=any\s*all\s*:\s*all\s*\z</ind:pattern>
f6303c
         <ind:instance datatype="int">1</ind:instance>
f6303c
     </ind:textfilecontent54_object>
f6303c
-    
f6303c
-    comment="fapolicyd is in enforcement mode"
f6303c
-    id="test_fapolicy_default_deny_enforcement" version="1">
f6303c
-        <ind:object object_ref="obj_fapolicy_default_deny_enforcement" />
f6303c
-        <ind:state state_ref="state_fapolicy_default_deny_enforcement" />
f6303c
+
f6303c
+    
f6303c
+        check_existence="all_exist" check="all"
f6303c
+        comment="permissive mode is disabled in fapolicyd settings">
f6303c
+        <ind:object object_ref="object_fapolicy_default_deny_permissive_mode" />
f6303c
+        <ind:state state_ref="state_fapolicy_default_deny_permissive_mode_off" />
f6303c
     </ind:textfilecontent54_test>
f6303c
-    <ind:textfilecontent54_object id="obj_fapolicy_default_deny_enforcement" version="1">
f6303c
+
f6303c
+    <ind:textfilecontent54_object id="object_fapolicy_default_deny_permissive_mode" version="2">
f6303c
         <ind:filepath>/etc/fapolicyd/fapolicyd.conf</ind:filepath>
f6303c
         <ind:pattern operation="pattern match">^\s*permissive\s*=\s*(\d+)</ind:pattern>
f6303c
-        <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
f6303c
+        <ind:instance datatype="int" operation="equals">1</ind:instance>
f6303c
     </ind:textfilecontent54_object>
f6303c
-    <ind:textfilecontent54_state id="state_fapolicy_default_deny_enforcement" version="1" comment="root email alias">
f6303c
-    <ind:subexpression operation="equals" datatype="int">0</ind:subexpression>
f6303c
-  </ind:textfilecontent54_state>
f6303c
+
f6303c
+    
f6303c
+        comment="permissive mode value is set to 0 (off) in fapolicyd settings file">
f6303c
+        <ind:subexpression operation="equals" datatype="int">0</ind:subexpression>
f6303c
+    </ind:textfilecontent54_state>
f6303c
 </def-group>
f6303c
f6303c
From a0fc2ee0b58404ca642804a8977eca6b77fb6807 Mon Sep 17 00:00:00 2001
f6303c
From: Marcus Burghardt <maburgha@redhat.com>
f6303c
Date: Thu, 17 Nov 2022 10:32:51 +0100
f6303c
Subject: [PATCH 3/5] Refactored the test scenario scripts
f6303c
f6303c
The scripts were invalid and wrongly reporting results. The main issue
f6303c
was in scripts which intended to create two lines in a file but were
f6303c
overwriting the entire file in the second command instead of append the
f6303c
second line. The scripts were also refactored to consider systems using
f6303c
the rules.d feature and also older systems which doesn't have the
f6303c
rules.d feature. Another issue was that "no_quotes" was false by default
f6303c
in the bash_shell_file_set macro, but the fapolicyd.conf doesn't expect
f6303c
quotes and this was causing inconsistency in the file, so the no_quotes
f6303c
was set to true when calling the macro from test scenarios. Finally the
f6303c
scripts names were better aligned to their respective scenarios.
f6303c
---
f6303c
 .../tests/allow_policy.fail.sh                 | 18 ++++++++++++++++++
f6303c
 .../tests/commented_value.fail.sh              | 12 ------------
f6303c
 .../tests/correct_value.pass.sh                | 12 ------------
f6303c
 .../tests/deny_not_last.fail.sh                | 12 ------------
f6303c
 .../tests/deny_policy.pass.sh                  | 18 ++++++++++++++++++
f6303c
 .../tests/deny_policy_but_permissive.fail.sh   | 16 ++++++++++++++++
f6303c
 .../tests/deny_policy_commented.fail.sh        | 18 ++++++++++++++++++
f6303c
 .../tests/deny_policy_not_ensured.fail.sh      | 18 ++++++++++++++++++
f6303c
 .../tests/fapolicy_permissive.fail.sh          |  5 -----
f6303c
 .../tests/wrong_value.fail.sh                  | 11 -----------
f6303c
 10 files changed, 88 insertions(+), 52 deletions(-)
f6303c
 create mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/allow_policy.fail.sh
f6303c
 delete mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/commented_value.fail.sh
f6303c
 delete mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/correct_value.pass.sh
f6303c
 delete mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_not_last.fail.sh
f6303c
 create mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy.pass.sh
f6303c
 create mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_but_permissive.fail.sh
f6303c
 create mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_commented.fail.sh
f6303c
 create mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_not_ensured.fail.sh
f6303c
 delete mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/fapolicy_permissive.fail.sh
f6303c
 delete mode 100644 linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/wrong_value.fail.sh
f6303c
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/allow_policy.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/allow_policy.fail.sh
f6303c
new file mode 100644
f6303c
index 00000000000..23d7e699056
f6303c
--- /dev/null
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/allow_policy.fail.sh
f6303c
@@ -0,0 +1,18 @@
f6303c
+#!/bin/bash
f6303c
+# packages = fapolicyd
f6303c
+# remediation = none
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}
f6303c
+
f6303c
+if [ -f /etc/fapolicyd/compiled.rules ]; then
f6303c
+    active_rules_file="/etc/fapolicyd/compiled.rules"
f6303c
+else
f6303c
+    active_rules_file="/etc/fapolicyd/fapolicyd.rules"
f6303c
+fi
f6303c
+
f6303c
+truncate -s 0 $active_rules_file
f6303c
+
f6303c
+echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
f6303c
+echo "allow perm=any all : all" >> $active_rules_file
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/commented_value.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/commented_value.fail.sh
f6303c
deleted file mode 100644
f6303c
index a8df835af76..00000000000
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/commented_value.fail.sh
f6303c
+++ /dev/null
f6303c
@@ -1,12 +0,0 @@
f6303c
-#!/bin/bash
f6303c
-# packages = fapolicyd
f6303c
-# remediation = none
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","1") }}}
f6303c
-
f6303c
-truncate -s 0 /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" > /etc/fapolicyd/fapolicyd.rules
f6303c
-echo "# deny perm=any all : all" > /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","0") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/correct_value.pass.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/correct_value.pass.sh
f6303c
deleted file mode 100644
f6303c
index c88406b0be4..00000000000
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/correct_value.pass.sh
f6303c
+++ /dev/null
f6303c
@@ -1,12 +0,0 @@
f6303c
-#!/bin/bash
f6303c
-# packages = fapolicyd
f6303c
-# remediation = none
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","1") }}}
f6303c
-
f6303c
-truncate -s 0 /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" > /etc/fapolicyd/fapolicyd.rules
f6303c
-echo "deny perm=any all : all" > /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","0") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_not_last.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_not_last.fail.sh
f6303c
deleted file mode 100644
f6303c
index 59b16308563..00000000000
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_not_last.fail.sh
f6303c
+++ /dev/null
f6303c
@@ -1,12 +0,0 @@
f6303c
-#!/bin/bash
f6303c
-# packages = fapolicyd
f6303c
-# remediation = none
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","1") }}}
f6303c
-
f6303c
-truncate -s 0 /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-echo "deny perm=any all : all" >> /etc/fapolicyd/fapolicyd.rules
f6303c
-echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" > /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","0") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy.pass.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy.pass.sh
f6303c
new file mode 100644
f6303c
index 00000000000..f3ff83ca602
f6303c
--- /dev/null
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy.pass.sh
f6303c
@@ -0,0 +1,18 @@
f6303c
+#!/bin/bash
f6303c
+# packages = fapolicyd
f6303c
+# remediation = none
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}
f6303c
+
f6303c
+if [ -f /etc/fapolicyd/compiled.rules ]; then
f6303c
+    active_rules_file="/etc/fapolicyd/compiled.rules"
f6303c
+else
f6303c
+    active_rules_file="/etc/fapolicyd/fapolicyd.rules"
f6303c
+fi
f6303c
+
f6303c
+truncate -s 0 $active_rules_file
f6303c
+
f6303c
+echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
f6303c
+echo "deny perm=any all : all" >> $active_rules_file
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_but_permissive.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_but_permissive.fail.sh
f6303c
new file mode 100644
f6303c
index 00000000000..caa401ca174
f6303c
--- /dev/null
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_but_permissive.fail.sh
f6303c
@@ -0,0 +1,16 @@
f6303c
+#!/bin/bash
f6303c
+# packages = fapolicyd
f6303c
+# remediation = none
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}
f6303c
+
f6303c
+if [ -f /etc/fapolicyd/compiled.rules ]; then
f6303c
+    active_rules_file="/etc/fapolicyd/compiled.rules"
f6303c
+else
f6303c
+    active_rules_file="/etc/fapolicyd/fapolicyd.rules"
f6303c
+fi
f6303c
+
f6303c
+truncate -s 0 $active_rules_file
f6303c
+
f6303c
+echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
f6303c
+echo "deny perm=any all : all" >> $active_rules_file
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_commented.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_commented.fail.sh
f6303c
new file mode 100644
f6303c
index 00000000000..4e4bc430cec
f6303c
--- /dev/null
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_commented.fail.sh
f6303c
@@ -0,0 +1,18 @@
f6303c
+#!/bin/bash
f6303c
+# packages = fapolicyd
f6303c
+# remediation = none
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}
f6303c
+
f6303c
+if [ -f /etc/fapolicyd/compiled.rules ]; then
f6303c
+    active_rules_file="/etc/fapolicyd/compiled.rules"
f6303c
+else
f6303c
+    active_rules_file="/etc/fapolicyd/fapolicyd.rules"
f6303c
+fi
f6303c
+
f6303c
+truncate -s 0 $active_rules_file
f6303c
+
f6303c
+echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
f6303c
+echo "# deny perm=any all : all" >> $active_rules_file
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_not_ensured.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_not_ensured.fail.sh
f6303c
new file mode 100644
f6303c
index 00000000000..b52e5446afc
f6303c
--- /dev/null
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/deny_policy_not_ensured.fail.sh
f6303c
@@ -0,0 +1,18 @@
f6303c
+#!/bin/bash
f6303c
+# packages = fapolicyd
f6303c
+# remediation = none
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "1", "true") }}}
f6303c
+
f6303c
+if [ -f /etc/fapolicyd/compiled.rules ]; then
f6303c
+    active_rules_file="/etc/fapolicyd/compiled.rules"
f6303c
+else
f6303c
+    active_rules_file="/etc/fapolicyd/fapolicyd.rules"
f6303c
+fi
f6303c
+
f6303c
+truncate -s 0 $active_rules_file
f6303c
+
f6303c
+echo "deny perm=any all : all" >> $active_rules_file
f6303c
+echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" >> $active_rules_file
f6303c
+
f6303c
+{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf", "permissive", "0", "true") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/fapolicy_permissive.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/fapolicy_permissive.fail.sh
f6303c
deleted file mode 100644
f6303c
index 50756a0e7a3..00000000000
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/fapolicy_permissive.fail.sh
f6303c
+++ /dev/null
f6303c
@@ -1,5 +0,0 @@
f6303c
-#!/bin/bash
f6303c
-# packages = fapolicyd
f6303c
-# remediation = none
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","0") }}}
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/wrong_value.fail.sh b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/wrong_value.fail.sh
f6303c
deleted file mode 100644
f6303c
index da3e33f57fd..00000000000
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/tests/wrong_value.fail.sh
f6303c
+++ /dev/null
f6303c
@@ -1,11 +0,0 @@
f6303c
-#!/bin/bash
f6303c
-# packages = fapolicyd
f6303c
-# remediation = none
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","1") }}}
f6303c
-
f6303c
-truncate -s 0 /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-echo "allow exe=/usr/bin/python3.7 : ftype=text/x-python" > /etc/fapolicyd/fapolicyd.rules
f6303c
-
f6303c
-{{{ bash_shell_file_set("/etc/fapolicyd/fapolicyd.conf","permissive","0") }}}
f6303c
f6303c
From 0b731cf7a0433111311ab5e427a54d2f6c1b9d14 Mon Sep 17 00:00:00 2001
f6303c
From: Marcus Burghardt <maburgha@redhat.com>
f6303c
Date: Thu, 17 Nov 2022 11:02:34 +0100
f6303c
Subject: [PATCH 4/5] Fixed bash_shell_file_set macro to consider spaces
f6303c
f6303c
Once the test scenario scripts were fixed, an issue was revelead in
f6303c
bash_shell_file_set macro. The macro was not considering config files
f6303c
which have spaces before and after the separator carachter. Since the
f6303c
separator_regex parameter already expects regex format, it was easily
f6303c
extended.
f6303c
---
f6303c
 shared/macros/10-bash.jinja | 8 ++++----
f6303c
 1 file changed, 4 insertions(+), 4 deletions(-)
f6303c
f6303c
diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja
f6303c
index ae0f0e5e6ad..0e369314645 100644
f6303c
--- a/shared/macros/10-bash.jinja
f6303c
+++ b/shared/macros/10-bash.jinja
f6303c
@@ -122,13 +122,13 @@ fi
f6303c
 {{%- macro bash_shell_file_set(path, parameter, value, no_quotes=false) -%}}
f6303c
 {{% if no_quotes -%}}
f6303c
   {{% if "$" in value %}}
f6303c
-  {{% set value = '%s' % value.replace("$", "\\$") %}}
f6303c
+    {{% set value = '%s' % value.replace("$", "\\$") %}}
f6303c
   {{% endif %}}
f6303c
 {{%- else -%}}
f6303c
   {{% if "$" in value %}}
f6303c
-  {{% set value = '\\"%s\\"' % value.replace("$", "\\$") %}}
f6303c
+    {{% set value = '\\"%s\\"' % value.replace("$", "\\$") %}}
f6303c
   {{% else %}}
f6303c
-  {{% set value = "'%s'" % value %}}
f6303c
+    {{% set value = "'%s'" % value %}}
f6303c
   {{% endif %}}
f6303c
 {{%- endif -%}}
f6303c
 {{{ set_config_file(
f6303c
@@ -140,7 +140,7 @@ fi
f6303c
         insert_before="^#\s*" ~ parameter,
f6303c
         insensitive=false,
f6303c
         separator="=",
f6303c
-        separator_regex="=",
f6303c
+        separator_regex="\s*=\s*",
f6303c
         prefix_regex="^\s*")
f6303c
     }}}
f6303c
 {{%- endmacro -%}}
f6303c
f6303c
From 3a8101e921f7b0b5e261fdbf4b42bf210fcccf78 Mon Sep 17 00:00:00 2001
f6303c
From: Marcus Burghardt <maburgha@redhat.com>
f6303c
Date: Fri, 18 Nov 2022 09:58:47 +0100
f6303c
Subject: [PATCH 5/5] Use jinja to limit the RHEL 8 minor version text
f6303c
f6303c
The change is intended to avoid that RHEL 9 and OL get RHEL 8 minor
f6303c
version text.
f6303c
---
f6303c
 .../guide/services/fapolicyd/fapolicy_default_deny/rule.yml   | 4 ++++
f6303c
 1 file changed, 4 insertions(+)
f6303c
f6303c
diff --git a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml
f6303c
index eeecd34e69a..220801bc471 100644
f6303c
--- a/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml
f6303c
+++ b/linux_os/guide/services/fapolicyd/fapolicy_default_deny/rule.yml
f6303c
@@ -41,10 +41,12 @@ ocil: |-
f6303c
 
f6303c
     Check that fapolicyd employs a deny-all policy on system mounts with the following commands:
f6303c
 
f6303c
+    {{%- if product in ["rhel8"] %}}
f6303c
     For RHEL 8.5 systems and older:
f6303c
     $ sudo tail /etc/fapolicyd/fapolicyd.rules
f6303c
 
f6303c
     For RHEL 8.6 systems and newer:
f6303c
+    {{%- endif %}}
f6303c
     $ sudo tail /etc/fapolicyd/compiled.rules
f6303c
 
f6303c
     allow exe=/usr/bin/python3.7 : ftype=text/x-python
f6303c
@@ -58,10 +60,12 @@ fixtext: |-
f6303c
 
f6303c
     permissive = 1
f6303c
 
f6303c
+    {{%- if product in ["rhel8"] %}}
f6303c
     For RHEL 8.5 systems and older:
f6303c
     Build the whitelist in the "/etc/fapolicyd/fapolicyd.rules" file ensuring the last rule is "deny perm=any all : all".
f6303c
 
f6303c
     For RHEL 8.6 systems and newer:
f6303c
+    {{%- endif %}}
f6303c
     Build the whitelist in a file within the "/etc/fapolicyd/rules.d" directory ensuring the last rule is "deny perm=any all : all".
f6303c
 
f6303c
     Once it is determined the whitelist is built correctly, set the fapolicyd to enforcing mode by editing the "permissive" line in the /etc/fapolicyd/fapolicyd.conf file.