Blame SOURCES/scap-security-guide-0.1.53-add-platform-to-package-mapping_PR_6047.patch

973b04
From 7c0b04c157374e9251360d1d5e12a9e00dd4375e Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 4 Sep 2020 09:50:54 +0200
973b04
Subject: [PATCH 1/3] Introduce platform_package_overrides
973b04
973b04
Introduce a mapping of CPE package platform name to a package name.
973b04
973b04
Each linux distro or version may have its specific name for a package,
973b04
this mapping allows a product to override the package name of a
973b04
platorm.
973b04
973b04
By default, it assumes that the package name will be the same as the
973b04
platform name.
973b04
---
973b04
 rhel8/product.yml         | 7 +++++++
973b04
 ssg/build_remediations.py | 3 +++
973b04
 2 files changed, 10 insertions(+)
973b04
973b04
diff --git a/rhel8/product.yml b/rhel8/product.yml
973b04
index 6cdc51919e..6b5b4e2748 100644
973b04
--- a/rhel8/product.yml
973b04
+++ b/rhel8/product.yml
973b04
@@ -18,3 +18,10 @@ aux_pkg_version: "d4082792"
973b04
 
973b04
 release_key_fingerprint: "567E347AD0044ADE55BA8A5F199E2F91FD431D51"
973b04
 auxiliary_key_fingerprint: "6A6AA7C97C8890AEC6AEBFE2F76F66C3D4082792"
973b04
+
973b04
+# Mapping of CPE platform to package
973b04
+platform_package_overrides:
973b04
+  grub2: "grub2-pc"
973b04
+  login_defs: "shadow-utils"
973b04
+  sssd: "sssd-common"
973b04
+  zipl: "s390x-utils"
973b04
diff --git a/ssg/build_remediations.py b/ssg/build_remediations.py
973b04
index 866450dd8c..ccbdf9fc1f 100644
973b04
--- a/ssg/build_remediations.py
973b04
+++ b/ssg/build_remediations.py
973b04
@@ -389,6 +389,9 @@ def update_when_from_rule(self, to_update):
973b04
                 if "package_facts" in to_update:
973b04
                     continue
973b04
 
973b04
+                if platform in self.local_env_yaml["platform_package_overrides"]:
973b04
+                    platform = self.local_env_yaml["platform_package_overrides"].get(platform)
973b04
+
973b04
                 additional_when.append('"' + platform + '" in ansible_facts.packages')
973b04
                 # After adding the conditional, we need to make sure package_facts are collected.
973b04
                 # This is done via inject_package_facts_task()
973b04
973b04
From 10dc62084cf8e38be9189b527c3b99b545826091 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 4 Sep 2020 14:42:57 +0200
973b04
Subject: [PATCH 2/3] Move platform to cpe mappings to ssg/constants
973b04
973b04
---
973b04
 rhel8/product.yml | 6 ------
973b04
 ssg/constants.py  | 8 ++++++++
973b04
 2 files changed, 8 insertions(+), 6 deletions(-)
973b04
973b04
diff --git a/rhel8/product.yml b/rhel8/product.yml
973b04
index 6b5b4e2748..d839b23231 100644
973b04
--- a/rhel8/product.yml
973b04
+++ b/rhel8/product.yml
973b04
@@ -19,9 +19,3 @@ aux_pkg_version: "d4082792"
973b04
 release_key_fingerprint: "567E347AD0044ADE55BA8A5F199E2F91FD431D51"
973b04
 auxiliary_key_fingerprint: "6A6AA7C97C8890AEC6AEBFE2F76F66C3D4082792"
973b04
 
973b04
-# Mapping of CPE platform to package
973b04
-platform_package_overrides:
973b04
-  grub2: "grub2-pc"
973b04
-  login_defs: "shadow-utils"
973b04
-  sssd: "sssd-common"
973b04
-  zipl: "s390x-utils"
973b04
diff --git a/ssg/constants.py b/ssg/constants.py
973b04
index 3f9d7d37ce..7e9678241c 100644
973b04
--- a/ssg/constants.py
973b04
+++ b/ssg/constants.py
973b04
@@ -501,6 +501,14 @@
973b04
     "zipl": "cpe:/a:zipl",
973b04
 }
973b04
 
973b04
+# Default platform to package mapping
973b04
+XCCDF_PLATFORM_TO_PACKAGE = {
973b04
+  "grub2": "grub2-pc",
973b04
+  "login_defs": "login",
973b04
+  "sssd": "sssd-common",
973b04
+  "zipl": "s390x-utils",
973b04
+}
973b04
+
973b04
 # _version_name_map = {
973b04
 MAKEFILE_ID_TO_PRODUCT_MAP = {
973b04
     'chromium': 'Google Chromium Browser',
973b04
973b04
From feb012f06adae989138be15431020f2c174becc4 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 4 Sep 2020 14:47:29 +0200
973b04
Subject: [PATCH 3/3] Allow override of default platform package mapping
973b04
973b04
With default platform to package mappings defined, we need to allow a
973b04
product to override it if needed.
973b04
---
973b04
 rhel6/product.yml   | 4 ++++
973b04
 rhel7/product.yml   | 4 ++++
973b04
 rhel8/product.yml   | 3 +++
973b04
 rhosp10/product.yml | 3 +++
973b04
 rhosp13/product.yml | 4 ++++
973b04
 rhv4/product.yml    | 4 ++++
973b04
 ssg/yaml.py         | 6 +++++-
973b04
 8 files changed, 31 insertions(+), 1 deletion(-)
973b04
973b04
diff --git a/rhel6/product.yml b/rhel6/product.yml
973b04
index cc8fa4f8ed..eab9b80c47 100644
973b04
--- a/rhel6/product.yml
973b04
+++ b/rhel6/product.yml
973b04
@@ -20,3 +20,7 @@ aux_pkg_version: "2fa658e0"
973b04
 
973b04
 release_key_fingerprint: "567E347AD0044ADE55BA8A5F199E2F91FD431D51"
973b04
 auxiliary_key_fingerprint: "43A6E49C4A38F4BE9ABF2A5345689C882FA658E0"
973b04
+
973b04
+# Mapping of CPE platform to package
973b04
+platform_package_overrides:
973b04
+  login_defs: "shadow-utils"
973b04
diff --git a/rhel7/product.yml b/rhel7/product.yml
973b04
index f03c928b8f..3ff996b8cc 100644
973b04
--- a/rhel7/product.yml
973b04
+++ b/rhel7/product.yml
973b04
@@ -18,3 +18,7 @@ aux_pkg_version: "2fa658e0"
973b04
 
973b04
 release_key_fingerprint: "567E347AD0044ADE55BA8A5F199E2F91FD431D51"
973b04
 auxiliary_key_fingerprint: "43A6E49C4A38F4BE9ABF2A5345689C882FA658E0"
973b04
+
973b04
+# Mapping of CPE platform to package
973b04
+platform_package_overrides:
973b04
+  login_defs: "shadow-utils"
973b04
diff --git a/rhel8/product.yml b/rhel8/product.yml
973b04
index d839b23231..f3aa59faec 100644
973b04
--- a/rhel8/product.yml
973b04
+++ b/rhel8/product.yml
973b04
@@ -19,3 +19,6 @@ aux_pkg_version: "d4082792"
973b04
 release_key_fingerprint: "567E347AD0044ADE55BA8A5F199E2F91FD431D51"
973b04
 auxiliary_key_fingerprint: "6A6AA7C97C8890AEC6AEBFE2F76F66C3D4082792"
973b04
 
973b04
+# Mapping of CPE platform to package
973b04
+platform_package_overrides:
973b04
+  login_defs: "shadow-utils"
973b04
diff --git a/rhosp10/product.yml b/rhosp10/product.yml
973b04
index 51d0a932a5..af42ca998d 100644
973b04
--- a/rhosp10/product.yml
973b04
+++ b/rhosp10/product.yml
973b04
@@ -10,3 +10,6 @@ pkg_manager: "yum"
973b04
 
973b04
 init_system: "systemd"
973b04
 
973b04
+# Mapping of CPE platform to package
973b04
+platform_package_overrides:
973b04
+  login_defs: "shadow-utils"
973b04
diff --git a/rhosp13/product.yml b/rhosp13/product.yml
973b04
index 5e849ff609..ba42a31cd7 100644
973b04
--- a/rhosp13/product.yml
973b04
+++ b/rhosp13/product.yml
973b04
@@ -9,3 +9,7 @@ profiles_root: "./profiles"
973b04
 pkg_manager: "yum"
973b04
 
973b04
 init_system: "systemd"
973b04
+
973b04
+# Mapping of CPE platform to package
973b04
+platform_package_overrides:
973b04
+  login_defs: "shadow-utils"
973b04
diff --git a/rhv4/product.yml b/rhv4/product.yml
973b04
index 10a2eda079..a61bf1588d 100644
973b04
--- a/rhv4/product.yml
973b04
+++ b/rhv4/product.yml
973b04
@@ -18,3 +18,7 @@ aux_pkg_version: "d4082792"
973b04
 
973b04
 release_key_fingerprint: "567E347AD0044ADE55BA8A5F199E2F91FD431D51"
973b04
 auxiliary_key_fingerprint: "6A6AA7C97C8890AEC6AEBFE2F76F66C3D4082792"
973b04
+
973b04
+# Mapping of CPE platform to package
973b04
+platform_package_overrides:
973b04
+  login_defs: "shadow-utils"
973b04
diff --git a/ssg/yaml.py b/ssg/yaml.py
973b04
index cefbba374c..22cf5bad66 100644
973b04
--- a/ssg/yaml.py
973b04
+++ b/ssg/yaml.py
973b04
@@ -10,7 +10,8 @@
973b04
 
973b04
 from .jinja import load_macros, process_file
973b04
 from .constants import (PKG_MANAGER_TO_SYSTEM,
973b04
-                        PKG_MANAGER_TO_CONFIG_FILE)
973b04
+                        PKG_MANAGER_TO_CONFIG_FILE,
973b04
+                        XCCDF_PLATFORM_TO_PACKAGE)
973b04
 from .constants import DEFAULT_UID_MIN
973b04
 
973b04
 try:
973b04
@@ -138,6 +139,9 @@ def open_raw(yaml_file):
973b04
 
973b04
 def open_environment(build_config_yaml, product_yaml):
973b04
     contents = open_raw(build_config_yaml)
973b04
+    # Load common platform package mappings,
973b04
+    # any specific mapping in product_yaml will override the default
973b04
+    contents["platform_package_overrides"] = XCCDF_PLATFORM_TO_PACKAGE
973b04
     contents.update(open_raw(product_yaml))
973b04
     contents.update(_get_implied_properties(contents))
973b04
     return contents