Blame SOURCES/scap-security-guide-0.1.41-restrict-remediation-for-dev-shm.patch

7629ac
From 3cba3a59a004582c787cba725fee033c104bfe43 Mon Sep 17 00:00:00 2001
7629ac
From: Watson Sato <wsato@redhat.com>
7629ac
Date: Wed, 25 Jul 2018 18:02:01 +0200
7629ac
Subject: [PATCH 1/4] Drop restrictions to build remediations for some sysctl
7629ac
 rules
7629ac
7629ac
Templated generation of remediations for these rules were restricted.
7629ac
I don't see the motivation to restrict them, besides to easy comparison
7629ac
of generated datastream in 9aa2184d8d0f866df3fb6f1ea1beeafb076b3be5.
7629ac
7629ac
RHEL7 content build the OVAL just fine.
7629ac
---
7629ac
 rhel6/templates/csv/sysctl_values.csv | 10 +++++-----
7629ac
 1 file changed, 5 insertions(+), 5 deletions(-)
7629ac
7629ac
diff --git a/rhel6/templates/csv/sysctl_values.csv b/rhel6/templates/csv/sysctl_values.csv
7629ac
index ad0507a2f4..af321acde0 100644
7629ac
--- a/rhel6/templates/csv/sysctl_values.csv
7629ac
+++ b/rhel6/templates/csv/sysctl_values.csv
7629ac
@@ -21,8 +21,8 @@ net.ipv4.ip_forward,0
7629ac
 net.ipv4.tcp_syncookies,
7629ac
 net.ipv6.conf.default.accept_ra,
7629ac
 net.ipv6.conf.default.accept_redirects,
7629ac
-net.ipv6.conf.all.accept_ra,#only-for:oval
7629ac
-net.ipv6.conf.all.accept_redirects,#only-for:oval
7629ac
-net.ipv6.conf.default.accept_source_route,#only-for:oval
7629ac
-net.ipv6.conf.all.accept_source_route,#only-for:oval
7629ac
-net.ipv6.conf.all.forwarding,#only-for:oval
7629ac
+net.ipv6.conf.all.accept_ra,
7629ac
+net.ipv6.conf.all.accept_redirects,
7629ac
+net.ipv6.conf.default.accept_source_route,
7629ac
+net.ipv6.conf.all.accept_source_route,
7629ac
+net.ipv6.conf.all.forwarding,
7629ac
7629ac
From 574defca3e1559bb5b954e65763b5df542bfeb99 Mon Sep 17 00:00:00 2001
7629ac
From: Watson Sato <wsato@redhat.com>
7629ac
Date: Wed, 25 Jul 2018 18:08:12 +0200
7629ac
Subject: [PATCH 2/4] Drop generation of kernel_dmesg_restrict
7629ac
7629ac
Rule kernel_dmest_restrict is not selected by any sle12 Profile.
7629ac
And currently the rule is applicable for rhel6, rhel7 and fedora.
7629ac
I see this as a copy pasta legacy.
7629ac
---
7629ac
 sle12/templates/csv/sysctl_values.csv | 1 -
7629ac
 1 file changed, 1 deletion(-)
7629ac
7629ac
diff --git a/sle12/templates/csv/sysctl_values.csv b/sle12/templates/csv/sysctl_values.csv
7629ac
index 9428bc8a9f..d9b34c9aad 100644
7629ac
--- a/sle12/templates/csv/sysctl_values.csv
7629ac
+++ b/sle12/templates/csv/sysctl_values.csv
7629ac
@@ -1,7 +1,6 @@
7629ac
 # Add <sysctl_parameter_name, desired_value> to generate hard-coded OVAL and remediation content.
7629ac
 # Add <sysctl_parameter_name,> to generate OVAL and remediation content that use the XCCDF value.
7629ac
 fs.suid_dumpable,0
7629ac
-kernel.dmesg_restrict,1#only-for:bash,ansible
7629ac
 #kernel.exec-shield,1
7629ac
 kernel.randomize_va_space,2
7629ac
 net.ipv4.conf.all.accept_redirects,
7629ac
7629ac
From 79166dab27c8f23e6918b675e126f473395bc70b Mon Sep 17 00:00:00 2001
7629ac
From: Watson Sato <wsato@redhat.com>
7629ac
Date: Wed, 25 Jul 2018 18:27:08 +0200
7629ac
Subject: [PATCH 3/4] Flip template restriction to exclude target languages
7629ac
7629ac
It is more likely and easier that we want to generate content for
7629ac
all supported languages, and filter out the exceptions.
7629ac
---
7629ac
 shared/templates/template_common.py | 14 +++++++-------
7629ac
 1 file changed, 7 insertions(+), 7 deletions(-)
7629ac
7629ac
diff --git a/shared/templates/template_common.py b/shared/templates/template_common.py
7629ac
index da746e0323..b0fdf5fcc9 100644
7629ac
--- a/shared/templates/template_common.py
7629ac
+++ b/shared/templates/template_common.py
7629ac
@@ -36,7 +36,7 @@ def __init__(self, template, paths):
7629ac
 
7629ac
 
7629ac
 TEMPLATED_LANGUAGES = ["bash", "ansible", "oval", "anaconda", "puppet"]
7629ac
-TARGET_REGEX = re.compile(r"#\s*only-for:([\s\w,]*)")
7629ac
+TARGET_EXCLUDE_REGEX = re.compile(r"#\s*except-for:([\s\w,]*)")
7629ac
 
7629ac
 
7629ac
 class FilesGenerator(object):
7629ac
@@ -113,13 +113,13 @@ def process_csv_line(self, line, target):
7629ac
         """
7629ac
 
7629ac
         if target is not None:
7629ac
-            match = TARGET_REGEX.search(line)
7629ac
+            exclude_match = TARGET_EXCLUDE_REGEX.search(line)
7629ac
 
7629ac
-            if match:
7629ac
-                # if line contains restriction to target, check it
7629ac
-                supported_targets = \
7629ac
-                    [x.strip() for x in match.group(1).split(",")]
7629ac
-                if target not in supported_targets:
7629ac
+            if exclude_match:
7629ac
+                # Check if line contains restriction to target
7629ac
+                unsupported_targets = \
7629ac
+                    [x.strip() for x in exclude_match.group(1).split(",")]
7629ac
+                if target in unsupported_targets:
7629ac
                     return None
7629ac
 
7629ac
         # get part before comment
7629ac
7629ac
From 89a059d096641d8f971c9f2d9af903742d251083 Mon Sep 17 00:00:00 2001
7629ac
From: Watson Sato <wsato@redhat.com>
7629ac
Date: Wed, 25 Jul 2018 18:44:11 +0200
7629ac
Subject: [PATCH 4/4] Dont generate fix for unavailable mount points
7629ac
7629ac
Do not generate anaconda remediation for mount options of /dev/shm.
7629ac
These mount points are not there at install time.
7629ac
---
7629ac
 rhel7/templates/csv/mount_options.csv | 8 +++++---
7629ac
 1 file changed, 5 insertions(+), 3 deletions(-)
7629ac
7629ac
diff --git a/rhel7/templates/csv/mount_options.csv b/rhel7/templates/csv/mount_options.csv
7629ac
index 759e51b0fe..f5d9ed8cea 100644
7629ac
--- a/rhel7/templates/csv/mount_options.csv
7629ac
+++ b/rhel7/templates/csv/mount_options.csv
7629ac
@@ -6,9 +6,11 @@
7629ac
 #     '$' to reference a variable, e.g. var_removable_partition,nodev)
7629ac
 #  If the remediation can create (i.e. not just modify) an /etc/fstab line,
7629ac
 #  add the 'create_fstab_entry_if_needed' literal string as the third argument.
7629ac
-/dev/shm,nodev
7629ac
-/dev/shm,noexec
7629ac
-/dev/shm,nosuid
7629ac
+
7629ac
+# /dev/shm is created by systemd and is not available at install time
7629ac
+/dev/shm,nodev #except-for:anaconda
7629ac
+/dev/shm,noexec #except-for:anaconda
7629ac
+/dev/shm,nosuid #except-for:anaconda
7629ac
 /home,nosuid
7629ac
 /home,nodev
7629ac
 /tmp,nodev