Blame SOURCES/scap-security-guide-0.1.61-rear_not_applicable_aarch64-PR_8221.patch

07cb6b
From 622558873703704bd97fde1874a9a782d4cb8b0e Mon Sep 17 00:00:00 2001
07cb6b
From: Gabriel Becker <ggasparb@redhat.com>
07cb6b
Date: Mon, 14 Feb 2022 17:51:50 +0100
07cb6b
Subject: [PATCH] Introduce CPE for aarch64 and make package_rear_installed n/a
07cb6b
 aarch64.
07cb6b
07cb6b
This rule is not applicable for RHEL9 only.
07cb6b
---
07cb6b
 .../package_rear_installed/rule.yml           |  4 +++
07cb6b
 shared/applicability/arch.yml                 | 12 +++++++
07cb6b
 ...proc_sys_kernel_osrelease_arch_aarch64.xml | 33 +++++++++++++++++++
07cb6b
 ..._sys_kernel_osrelease_arch_not_aarch64.xml | 16 +++++++++
07cb6b
 ssg/constants.py                              |  2 ++
07cb6b
 5 files changed, 67 insertions(+)
07cb6b
 create mode 100644 shared/checks/oval/proc_sys_kernel_osrelease_arch_aarch64.xml
07cb6b
 create mode 100644 shared/checks/oval/proc_sys_kernel_osrelease_arch_not_aarch64.xml
07cb6b
07cb6b
diff --git a/linux_os/guide/system/software/system-tools/package_rear_installed/rule.yml b/linux_os/guide/system/software/system-tools/package_rear_installed/rule.yml
07cb6b
index 6e3c11e5749..efb591654a9 100644
07cb6b
--- a/linux_os/guide/system/software/system-tools/package_rear_installed/rule.yml
07cb6b
+++ b/linux_os/guide/system/software/system-tools/package_rear_installed/rule.yml
07cb6b
@@ -25,6 +25,10 @@ ocil: '{{{ ocil_package(package="rear") }}}'
07cb6b
 # The package is not available for s309x on RHEL<8.5
07cb6b
 # platform: not_s390x_arch
07cb6b
 
07cb6b
+{{%- if product == "rhel9" %}}
07cb6b
+platform: not_aarch64_arch
07cb6b
+{{%- endif %}}
07cb6b
+
07cb6b
 template:
07cb6b
     name: package_installed
07cb6b
     vars:
07cb6b
diff --git a/shared/applicability/arch.yml b/shared/applicability/arch.yml
07cb6b
index d2cbd102310..9ac05317a95 100644
07cb6b
--- a/shared/applicability/arch.yml
07cb6b
+++ b/shared/applicability/arch.yml
07cb6b
@@ -12,3 +12,15 @@ cpes:
07cb6b
       check_id: proc_sys_kernel_osrelease_arch_s390x
07cb6b
       bash_conditional: 'grep -q s390x /proc/sys/kernel/osrelease'
07cb6b
 
07cb6b
+  - not_aarch64_arch:
07cb6b
+      name: "cpe:/a:not_aarch64_arch"
07cb6b
+      title: "System architecture is not AARCH64"
07cb6b
+      check_id: proc_sys_kernel_osrelease_arch_not_aarch64
07cb6b
+      bash_conditional: "! grep -q aarch64 /proc/sys/kernel/osrelease"
07cb6b
+
07cb6b
+  - aarch64_arch:
07cb6b
+      name: "cpe:/a:aarch64_arch"
07cb6b
+      title: "System architecture is AARCH64"
07cb6b
+      check_id: proc_sys_kernel_osrelease_arch_aarch64
07cb6b
+      bash_conditional: 'grep -q aarch64 /proc/sys/kernel/osrelease'
07cb6b
+
07cb6b
diff --git a/shared/checks/oval/proc_sys_kernel_osrelease_arch_aarch64.xml b/shared/checks/oval/proc_sys_kernel_osrelease_arch_aarch64.xml
07cb6b
new file mode 100644
07cb6b
index 00000000000..3d54f81e6d4
07cb6b
--- /dev/null
07cb6b
+++ b/shared/checks/oval/proc_sys_kernel_osrelease_arch_aarch64.xml
07cb6b
@@ -0,0 +1,33 @@
07cb6b
+<def-group>
07cb6b
+  
07cb6b
+  version="1">
07cb6b
+    <metadata>
07cb6b
+      <title>Test that the architecture is aarch64</title>
07cb6b
+      <affected family="unix">
07cb6b
+        <platform>multi_platform_all</platform>
07cb6b
+      </affected>
07cb6b
+      <description>Check that architecture of kernel in /proc/sys/kernel/osrelease is aarch64</description>
07cb6b
+    </metadata>
07cb6b
+    <criteria>
07cb6b
+      
07cb6b
+      test_ref="test_proc_sys_kernel_osrelease_arch_aarch64" />
07cb6b
+    </criteria>
07cb6b
+  </definition>
07cb6b
+  
07cb6b
+      comment="proc_sys_kernel is for aarch64 architecture"
07cb6b
+      id="test_proc_sys_kernel_osrelease_arch_aarch64"
07cb6b
+  version="1">
07cb6b
+    <ind:object object_ref="object_proc_sys_kernel_osrelease_arch_aarch64" />
07cb6b
+    <ind:state state_ref="state_proc_sys_kernel_osrelease_arch_aarch64" />
07cb6b
+  </ind:textfilecontent54_test>
07cb6b
+
07cb6b
+  <ind:textfilecontent54_object id="object_proc_sys_kernel_osrelease_arch_aarch64" version="1">
07cb6b
+    <ind:filepath>/proc/sys/kernel/osrelease</ind:filepath>
07cb6b
+    <ind:pattern operation="pattern match">^.*\.(.*)$</ind:pattern>
07cb6b
+    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
07cb6b
+  </ind:textfilecontent54_object>
07cb6b
+
07cb6b
+  <ind:textfilecontent54_state id="state_proc_sys_kernel_osrelease_arch_aarch64" version="1">
07cb6b
+    <ind:subexpression datatype="string" operation="pattern match">^aarch64$</ind:subexpression>
07cb6b
+  </ind:textfilecontent54_state>
07cb6b
+</def-group>
07cb6b
diff --git a/shared/checks/oval/proc_sys_kernel_osrelease_arch_not_aarch64.xml b/shared/checks/oval/proc_sys_kernel_osrelease_arch_not_aarch64.xml
07cb6b
new file mode 100644
07cb6b
index 00000000000..3fce66ee00a
07cb6b
--- /dev/null
07cb6b
+++ b/shared/checks/oval/proc_sys_kernel_osrelease_arch_not_aarch64.xml
07cb6b
@@ -0,0 +1,16 @@
07cb6b
+<def-group>
07cb6b
+  
07cb6b
+  version="1">
07cb6b
+    <metadata>
07cb6b
+      <title>Test for different architecture than aarch64</title>
07cb6b
+      <affected family="unix">
07cb6b
+        <platform>multi_platform_all</platform>
07cb6b
+      </affected>
07cb6b
+      <description>Check that architecture of kernel in /proc/sys/kernel/osrelease is not aarch64</description>
07cb6b
+    </metadata>
07cb6b
+    <criteria>
07cb6b
+      
07cb6b
+      definition_ref="proc_sys_kernel_osrelease_arch_aarch64" negate="true"/>
07cb6b
+    </criteria>
07cb6b
+  </definition>
07cb6b
+</def-group>
07cb6b
diff --git a/ssg/constants.py b/ssg/constants.py
07cb6b
index 64d7d36c989..92cc2f8de34 100644
07cb6b
--- a/ssg/constants.py
07cb6b
+++ b/ssg/constants.py
07cb6b
@@ -424,6 +424,8 @@
07cb6b
   "non-uefi": None,
07cb6b
   "not_s390x_arch": None,
07cb6b
   "s390x_arch": None,
07cb6b
+  "not_aarch64_arch": None,
07cb6b
+  "aarch64_arch": None,
07cb6b
   "ovirt": None,
07cb6b
   "no_ovirt": None,
07cb6b
 }