Blame SOURCES/scap-security-guide-0.1.64-accept_sudoers_wihout_includes-PR_9283.patch

f386a0
From 07261c69afcdc5f9afcdd5aefc2ee9510d705f37 Mon Sep 17 00:00:00 2001
f386a0
From: =?UTF-8?q?Jan=20=C4=8Cern=C3=BD?= <jcerny@redhat.com>
f386a0
Date: Wed, 3 Aug 2022 13:08:25 +0200
f386a0
Subject: [PATCH 6/8] Merge pull request #9283 from
f386a0
 yuumasato/accept_sudoers_without_includes
f386a0
f386a0
Patch-name: scap-security-guide-0.1.64-accept_sudoers_wihout_includes-PR_9283.patch
f386a0
Patch-status: Accept sudoers files without includes as compliant
f386a0
---
f386a0
 .../oval/shared.xml                           | 24 +++++++++++++++----
f386a0
 .../sudo/sudoers_default_includedir/rule.yml  |  8 ++++---
f386a0
 ...cludedir.fail.sh => no_includedir.pass.sh} |  2 +-
f386a0
 3 files changed, 26 insertions(+), 8 deletions(-)
f386a0
 rename linux_os/guide/system/software/sudo/sudoers_default_includedir/tests/{no_includedir.fail.sh => no_includedir.pass.sh} (51%)
f386a0
f386a0
diff --git a/linux_os/guide/system/software/sudo/sudoers_default_includedir/oval/shared.xml b/linux_os/guide/system/software/sudo/sudoers_default_includedir/oval/shared.xml
f386a0
index 59cab0b89d..82095acc6e 100644
f386a0
--- a/linux_os/guide/system/software/sudo/sudoers_default_includedir/oval/shared.xml
f386a0
+++ b/linux_os/guide/system/software/sudo/sudoers_default_includedir/oval/shared.xml
f386a0
@@ -1,10 +1,16 @@
f386a0
 <def-group>
f386a0
   <definition class="compliance" id="{{{ rule_id }}}" version="1">
f386a0
     {{{ oval_metadata("Check if sudo includes only the default includedir") }}}
f386a0
-    <criteria operator="AND">
f386a0
-      <criterion comment="Check /etc/sudoers for #includedir" test_ref="test_sudoers_default_includedir" />
f386a0
-      <criterion comment="Check /etc/sudoers for #include" test_ref="test_sudoers_without_include" />
f386a0
-      <criterion comment="Check /etc/sudoers.d for includes" test_ref="test_sudoersd_without_includes" />
f386a0
+    <criteria operator="OR">
f386a0
+      <criteria operator="AND">
f386a0
+        <criterion comment="Check /etc/sudoers doesn't have any #include" test_ref="test_sudoers_without_include" />
f386a0
+        <criterion comment="Check /etc/sudoers doesn't have any #includedir" test_ref="test_sudoers_without_includedir" />
f386a0
+      </criteria>
f386a0
+      <criteria operator="AND">
f386a0
+        <criterion comment="Check /etc/sudoers for #includedir" test_ref="test_sudoers_default_includedir" />
f386a0
+        <criterion comment="Check /etc/sudoers doesn't have any #include" test_ref="test_sudoers_without_include" />
f386a0
+        <criterion comment="Check /etc/sudoers.d doesn't have any #include or #includedir" test_ref="test_sudoersd_without_includes" />
f386a0
+      </criteria>
f386a0
     </criteria>
f386a0
   </definition>
f386a0
 
f386a0
@@ -32,6 +38,16 @@
f386a0
     <ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
f386a0
   </ind:textfilecontent54_object>
f386a0
 
f386a0
+  
f386a0
+      comment="audit augenrules rmmod" id="test_sudoers_without_includedir" version="1">
f386a0
+    <ind:object object_ref="object_sudoers_without_includedir" />
f386a0
+  </ind:textfilecontent54_test>
f386a0
+  <ind:textfilecontent54_object id="object_sudoers_without_includedir" version="1">
f386a0
+    <ind:filepath>/etc/sudoers</ind:filepath>
f386a0
+    <ind:pattern operation="pattern match">^#includedir[\s]+.*$</ind:pattern>
f386a0
+    <ind:instance operation="greater than or equal" datatype="int">1</ind:instance>
f386a0
+  </ind:textfilecontent54_object>
f386a0
+
f386a0
   
f386a0
       comment="audit augenrules rmmod" id="test_sudoersd_without_includes" version="1">
f386a0
     <ind:object object_ref="object_sudoersd_without_includes" />
f386a0
diff --git a/linux_os/guide/system/software/sudo/sudoers_default_includedir/rule.yml b/linux_os/guide/system/software/sudo/sudoers_default_includedir/rule.yml
f386a0
index aa2aaee19f..83bfb0183b 100644
f386a0
--- a/linux_os/guide/system/software/sudo/sudoers_default_includedir/rule.yml
f386a0
+++ b/linux_os/guide/system/software/sudo/sudoers_default_includedir/rule.yml
f386a0
@@ -8,9 +8,11 @@ description: |-
f386a0
     Administrators can configure authorized <tt>sudo</tt> users via drop-in files, and it is possible to include
f386a0
     other directories and configuration files from the file currently being parsed.
f386a0
   
f386a0
-    Make sure that <tt>/etc/sudoers</tt> only includes drop-in configuration files from <tt>/etc/sudoers.d</tt>.
f386a0
-    The <tt>/etc/sudoers</tt> should contain only one <tt>#includedir</tt> directive pointing to
f386a0
-    <tt>/etc/sudoers.d</tt>, and no file in <tt>/etc/sudoers.d/</tt> should include other files or directories.
f386a0
+    Make sure that <tt>/etc/sudoers</tt> only includes drop-in configuration files from <tt>/etc/sudoers.d</tt>,
f386a0
+    or that no drop-in file is included.
f386a0
+    Either the <tt>/etc/sudoers</tt> should contain only one <tt>#includedir</tt> directive pointing to
f386a0
+    <tt>/etc/sudoers.d</tt>, and no file in <tt>/etc/sudoers.d/</tt> should include other files or directories;
f386a0
+    Or the <tt>/etc/sudoers</tt> should not contain any <tt>#include</tt> or <tt>#includedir</tt> directives.
f386a0
     Note that the '#' character doesn't denote a comment in the configuration file.
f386a0
 
f386a0
 rationale: |-
f386a0
diff --git a/linux_os/guide/system/software/sudo/sudoers_default_includedir/tests/no_includedir.fail.sh b/linux_os/guide/system/software/sudo/sudoers_default_includedir/tests/no_includedir.pass.sh
f386a0
similarity index 51%
f386a0
rename from linux_os/guide/system/software/sudo/sudoers_default_includedir/tests/no_includedir.fail.sh
f386a0
rename to linux_os/guide/system/software/sudo/sudoers_default_includedir/tests/no_includedir.pass.sh
f386a0
index 1e0ab8aea9..fe73cb2507 100644
f386a0
--- a/linux_os/guide/system/software/sudo/sudoers_default_includedir/tests/no_includedir.fail.sh
f386a0
+++ b/linux_os/guide/system/software/sudo/sudoers_default_includedir/tests/no_includedir.pass.sh
f386a0
@@ -1,4 +1,4 @@
f386a0
 #!/bin/bash
f386a0
 # platform = multi_platform_all
f386a0
 
f386a0
-sed -i "/#includedir.*/d" /etc/sudoers
f386a0
+sed -i "/#include(dir)?.*/d" /etc/sudoers
f386a0
-- 
f386a0
2.37.1
f386a0