Blame SOURCES/scap-security-guide-0.1.52-add-zipl-boot-options-template_PR_5908.patch

973b04
From f37e40e3de5ff493c60c61a054026dabf7b79032 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Wed, 1 Jul 2020 16:12:35 +0200
973b04
Subject: [PATCH 01/18] Kickstart zipl_bls_entries_option template
973b04
973b04
Create initial version of zIPL specific BLS entries
973b04
template by copying bls_entries_option template.
973b04
---
973b04
 .../template_OVAL_zipl_bls_entries_option     | 32 +++++++++++++++++++
973b04
 ssg/templates.py                              |  5 +++
973b04
 2 files changed, 37 insertions(+)
973b04
 create mode 100644 shared/templates/template_OVAL_zipl_bls_entries_option
973b04
973b04
diff --git a/shared/templates/template_OVAL_zipl_bls_entries_option b/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
new file mode 100644
973b04
index 0000000000..a19bd5a89c
973b04
--- /dev/null
973b04
+++ b/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
@@ -0,0 +1,32 @@
973b04
+<def-group>
973b04
+  <definition class="compliance" id="{{{ _RULE_ID }}}" version="1">
973b04
+    <metadata>
973b04
+      <title>Ensure that BLS-compatible boot loader is configured to run Linux operating system with argument {{{ ARG_NAME_VALUE }}}</title>
973b04
+      {{{- oval_affected(products) }}}
973b04
+      <description>Ensure {{{ ARG_NAME_VALUE }}} option is configured in the 'options' line in /boot/loader/entries/*.conf.</description>
973b04
+    </metadata>
973b04
+    <criteria operator="AND">
973b04
+        
973b04
+        comment="Check if {{{ ARG_NAME_VALUE }}} is present in the 'options' line in /boot/loader/entries/*" />
973b04
+    </criteria>
973b04
+  </definition>
973b04
+
973b04
+  
973b04
+  comment="check for kernel option {{{ ARG_NAME_VALUE }}} for all snippets in /boot/loader/entries"
973b04
+  check="all" check_existence="all_exist" version="1">
973b04
+    <ind:object object_ref="object_bls_{{{ SANITIZED_ARG_NAME }}}_options" />
973b04
+    <ind:state state_ref="state_bls_{{{ SANITIZED_ARG_NAME }}}_option" />
973b04
+  </ind:textfilecontent54_test>
973b04
+
973b04
+  
973b04
+  version="1">
973b04
+    <ind:filepath operation="pattern match">^/boot/loader/entries/.*\.conf$</ind:filepath>
973b04
+    <ind:pattern operation="pattern match">^options (.*)$</ind:pattern>
973b04
+    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
973b04
+  </ind:textfilecontent54_object>
973b04
+
973b04
+  
973b04
+  version="1">
973b04
+    <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?{{{ ESCAPED_ARG_NAME_VALUE }}}(?:\s.*)?$</ind:subexpression>
973b04
+  </ind:textfilecontent54_state>
973b04
+</def-group>
973b04
diff --git a/ssg/templates.py b/ssg/templates.py
973b04
index 2795267abd..fc09416abe 100644
973b04
--- a/ssg/templates.py
973b04
+++ b/ssg/templates.py
973b04
@@ -340,6 +340,22 @@ def bls_entries_option(data, lang):
973b04
     return data
973b04
 
973b04
 
973b04
+@template(["oval"])
973b04
+def bls_entries_option(data, lang):
973b04
+    data["arg_name_value"] = data["arg_name"] + "=" + data["arg_value"]
973b04
+    if lang == "oval":
973b04
+        # escape dot, this is used in oval regex
973b04
+        data["escaped_arg_name_value"] = data["arg_name_value"].replace(".", "\\.")
973b04
+        # replace . with _, this is used in test / object / state ids
973b04
+        data["sanitized_arg_name"] = data["arg_name"].replace(".", "_")
973b04
+    return data
973b04
+
973b04
+
973b04
+@template(["oval"])
973b04
+def zipl_bls_entries_option(data, lang):
973b04
+    return bls_entries_option(data, lang)
973b04
+
973b04
+
973b04
 class Builder(object):
973b04
     """
973b04
     Class for building all templated content for a given product.
973b04
973b04
From f54c3c974b6a3ce6d40533a51f867d2e8985b688 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Thu, 9 Jul 2020 14:11:04 +0200
973b04
Subject: [PATCH 02/18] zipl_bls_entries_option: check opts after install
973b04
973b04
Extend zipl_bls_entries_option template to check that the kernel option
973b04
is also configure in /etc/kernel/cmdline.
973b04
The presence of the argument in /etc/kernel/cmdline ensures that newly
973b04
installed kernels will be configure if the option.
973b04
---
973b04
 .../template_OVAL_zipl_bls_entries_option     | 19 +++++++++++++++++--
973b04
 1 file changed, 17 insertions(+), 2 deletions(-)
973b04
973b04
diff --git a/shared/templates/template_OVAL_zipl_bls_entries_option b/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
index a19bd5a89c..9af1bcfbee 100644
973b04
--- a/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
+++ b/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
@@ -6,8 +6,10 @@
973b04
       <description>Ensure {{{ ARG_NAME_VALUE }}} option is configured in the 'options' line in /boot/loader/entries/*.conf.</description>
973b04
     </metadata>
973b04
     <criteria operator="AND">
973b04
-        
973b04
-        comment="Check if {{{ ARG_NAME_VALUE }}} is present in the 'options' line in /boot/loader/entries/*" />
973b04
+      
973b04
+      comment="Check if {{{ ARG_NAME_VALUE }}} is present in the 'options' line in /boot/loader/entries/*" />
973b04
+      
973b04
+      comment="Make sure that newly installed kernels will retain {{{ ARG_NAME_VALUE }}} option" />
973b04
     </criteria>
973b04
   </definition>
973b04
 
973b04
@@ -25,6 +27,19 @@
973b04
     <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
973b04
   </ind:textfilecontent54_object>
973b04
 
973b04
+  
973b04
+  comment="Check for option {{{ ARG_NAME_VALUE }}} in /etc/kernel/cmdline"
973b04
+  check="all" check_existence="all_exist" version="1">
973b04
+    <ind:object object_ref="object_kernel_update_{{{ SANITIZED_ARG_NAME }}}_option" />
973b04
+    <ind:state state_ref="state_bls_{{{ SANITIZED_ARG_NAME }}}_option" />
973b04
+  </ind:textfilecontent54_test>
973b04
+  
973b04
+  version="1">
973b04
+    <ind:filepath>/etc/kernel/cmdline</ind:filepath>
973b04
+    <ind:pattern operation="pattern match">^(.*)$</ind:pattern>
973b04
+    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
973b04
+  </ind:textfilecontent54_object>
973b04
+
973b04
   
973b04
   version="1">
973b04
     <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?{{{ ESCAPED_ARG_NAME_VALUE }}}(?:\s.*)?$</ind:subexpression>
973b04
973b04
From 5b66eff84794b99a4ba7a626c46f1970715b1bcd Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Thu, 9 Jul 2020 14:12:32 +0200
973b04
Subject: [PATCH 03/18] zipl_bls_entries_option: Add Ansible and Bash
973b04
973b04
---
973b04
 .../template_ANSIBLE_zipl_bls_entries_option  | 48 +++++++++++++++++++
973b04
 .../template_BASH_zipl_bls_entries_option     | 12 +++++
973b04
 ssg/templates.py                              |  2 +-
973b04
 3 files changed, 61 insertions(+), 1 deletion(-)
973b04
 create mode 100644 shared/templates/template_ANSIBLE_zipl_bls_entries_option
973b04
 create mode 100644 shared/templates/template_BASH_zipl_bls_entries_option
973b04
973b04
diff --git a/shared/templates/template_ANSIBLE_zipl_bls_entries_option b/shared/templates/template_ANSIBLE_zipl_bls_entries_option
973b04
new file mode 100644
973b04
index 0000000000..c0cb131b82
973b04
--- /dev/null
973b04
+++ b/shared/templates/template_ANSIBLE_zipl_bls_entries_option
973b04
@@ -0,0 +1,48 @@
973b04
+# platform = Red Hat Enterprise Linux 8
973b04
+# reboot = true
973b04
+# strategy = configure
973b04
+# complexity = medium
973b04
+# disruption = low
973b04
+
973b04
+- name: "Ensure BLS boot entries options contain {{{ ARG_NAME_VALUE }}}"
973b04
+  block:
973b04
+    - name: "Check if any boot entry misses {{{ ARG_NAME_VALUE }}}"
973b04
+      find:
973b04
+        paths: "/boot/loader/entries/"
973b04
+        contains: "^options .*{{{ ARG_NAME_VALUE }}}.*$"
973b04
+        patterns: "*.conf"
973b04
+      register: entries_options
973b04
+
973b04
+    - name: "Update boot entries options"
973b04
+      command: grubby --update-kernel=ALL --args="{{{ ARG_NAME_VALUE }}}"
973b04
+      when: entries_options is defined and entries_options.examined != entries_options.matched
973b04
+      # The conditional above assumes that only *.conf files are present in /boot/loader/entries
973b04
+      # Then, the number of conf files is the same as examined files
973b04
+
973b04
+    - name: "Check if /etc/kernel/cmdline exists"
973b04
+      stat:
973b04
+        path: /etc/kernel/cmdline
973b04
+      register: cmdline_stat
973b04
+
973b04
+    - name: "Check if /etc/kernel/cmdline contains {{{ ARG_NAME_VALUE }}}"
973b04
+      find:
973b04
+        paths: "/etc/kernel/"
973b04
+        patterns: "cmdline"
973b04
+        contains: "^.*{{{ ARG_NAME_VALUE }}}.*$"
973b04
+      register: cmdline_find
973b04
+
973b04
+    - name: "Add /etc/kernel/cmdline contains {{{ ARG_NAME_VALUE }}}"
973b04
+      lineinfile:
973b04
+        create: yes
973b04
+        path: "/etc/kernel/cmdline"
973b04
+        line: '{{{ ARG_NAME_VALUE }}}'
973b04
+      when: cmdline_stat is defined and not cmdline_stat.stat.exists
973b04
+
973b04
+    - name: "Append /etc/kernel/cmdline contains {{{ ARG_NAME_VALUE }}}"
973b04
+      lineinfile:
973b04
+        path: "/etc/kernel/cmdline"
973b04
+        backrefs: yes
973b04
+        regexp: "^(.*)$"
973b04
+        line: '\1 {{{ ARG_NAME_VALUE }}}'
973b04
+      when: cmdline_stat is defined and cmdline_stat.stat.exists and cmdline_find is defined and cmdline_find.matched == 0
973b04
+
973b04
diff --git a/shared/templates/template_BASH_zipl_bls_entries_option b/shared/templates/template_BASH_zipl_bls_entries_option
973b04
new file mode 100644
973b04
index 0000000000..9fc8865486
973b04
--- /dev/null
973b04
+++ b/shared/templates/template_BASH_zipl_bls_entries_option
973b04
@@ -0,0 +1,12 @@
973b04
+# platform = Red Hat Enterprise Linux 8
973b04
+
973b04
+# Correct BLS option using grubby, which is a thin wrapper around BLS operations
973b04
+grubby --update-kernel=ALL --args="{{{ ARG_NAME_VALUE }}}"
973b04
+
973b04
+# Ensure new kernels and boot entries retain the boot option
973b04
+if [ ! -f /etc/kernel/cmdline ]; then
973b04
+    echo "{{{ ARG_NAME_VALUE }}}" >> /etc/kernel/cmdline
973b04
+elif ! grep -q '^(.*\s)?{{{ ARG_NAME_VALUE }}}(\s.*)?$' /etc/kernel/cmdline; then
973b04
+    echo " audit=1" >> /etc/kernel/cmdline
973b04
+    sed -Ei 's/^(.*)$/\1 audit=1/' /etc/kernel/cmdline
973b04
+fi
973b04
diff --git a/ssg/templates.py b/ssg/templates.py
973b04
index fc09416abe..a27fbb6cb6 100644
973b04
--- a/ssg/templates.py
973b04
+++ b/ssg/templates.py
973b04
@@ -340,7 +340,7 @@ def bls_entries_option(data, lang):
973b04
     return data
973b04
 
973b04
 
973b04
-@template(["oval"])
973b04
+@template(["ansible", "bash", "oval"])
973b04
 def zipl_bls_entries_option(data, lang):
973b04
     return bls_entries_option(data, lang)
973b04
 
973b04
973b04
From fd2d807f60a4a36ad96f5ac37df9b4651fe3480e Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 3 Jul 2020 15:50:56 +0200
973b04
Subject: [PATCH 04/18] Enable zIPL in argument rules
973b04
973b04
---
973b04
 .../system/bootloader-zipl/zipl_audit_argument/rule.yml     | 6 ++++++
973b04
 .../zipl_audit_backlog_limit_argument/rule.yml              | 6 ++++++
973b04
 .../bootloader-zipl/zipl_page_poison_argument/rule.yml      | 6 ++++++
973b04
 .../guide/system/bootloader-zipl/zipl_pti_argument/rule.yml | 6 ++++++
973b04
 .../bootloader-zipl/zipl_slub_debug_argument/rule.yml       | 6 ++++++
973b04
 .../system/bootloader-zipl/zipl_vsyscall_argument/rule.yml  | 6 ++++++
973b04
 6 files changed, 36 insertions(+)
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml
973b04
index 624b4e7041..894bf7995f 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml
973b04
@@ -28,3 +28,9 @@ ocil: |-
973b04
   No line should be returned, each line returned is a boot entry that doesn't enable audit.
973b04
 
973b04
 platform: machine
973b04
+
973b04
+template:
973b04
+  name: zipl_bls_entries_option
973b04
+  vars:
973b04
+    arg_name: audit
973b04
+    arg_value: '1'
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
index faf114591a..12334c9905 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
@@ -28,3 +28,9 @@ ocil: |-
973b04
   No line should be returned, each line returned is a boot entry that does not extend the log events queue.
973b04
 
973b04
 platform: machine
973b04
+
973b04
+template:
973b04
+  name: zipl_bls_entries_option
973b04
+  vars:
973b04
+    arg_name: audit_backlog_limit
973b04
+    arg_value: '8192'
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml
973b04
index 866664c01b..f5a36ee1b3 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml
973b04
@@ -28,3 +28,9 @@ ocil: |-
973b04
   No line should be returned, each line returned is a boot entry that doesn't enable page poisoning.
973b04
 
973b04
 platform: machine
973b04
+
973b04
+template:
973b04
+  name: zipl_bls_entries_option
973b04
+  vars:
973b04
+    arg_name: page_poison
973b04
+    arg_value: '1'
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml
973b04
index 2f02d9668c..168dae46a1 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml
973b04
@@ -27,3 +27,9 @@ ocil: |-
973b04
   No line should be returned, each line returned is a boot entry that doesn't enable page-table isolation .
973b04
 
973b04
 platform: machine
973b04
+
973b04
+template:
973b04
+  name: zipl_bls_entries_option
973b04
+  vars:
973b04
+    arg_name: pti
973b04
+    arg_value: 'on'
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
index 0cb10d3cd8..84a374e36f 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
@@ -28,3 +28,9 @@ ocil: |-
973b04
   No line should be returned, each line returned is a boot entry that does not enable poisoning.
973b04
 
973b04
 platform: machine
973b04
+
973b04
+template:
973b04
+  name: zipl_bls_entries_option
973b04
+  vars:
973b04
+    arg_name: slub_debug
973b04
+    arg_value: 'P'
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml
973b04
index f79adeb083..c37e8bbefd 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml
973b04
@@ -25,3 +25,9 @@ ocil: |-
973b04
   No line should be returned, each line returned is a boot entry that doesn't disable virtual syscalls.
973b04
 
973b04
 platform: machine
973b04
+
973b04
+template:
973b04
+  name: zipl_bls_entries_option
973b04
+  vars:
973b04
+    arg_name: vsyscall
973b04
+    arg_value: 'none'
973b04
973b04
From 08db1a1d4bb3362195c34e266feb9bac31ba4be8 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Sat, 4 Jul 2020 01:15:49 +0200
973b04
Subject: [PATCH 05/18] zipl_audit_backlog_limit_argument: Fix OCIL typo
973b04
973b04
Fix typo
973b04
---
973b04
 .../bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml  | 2 +-
973b04
 1 file changed, 1 insertion(+), 1 deletion(-)
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
index 12334c9905..15729dc6b6 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
@@ -24,7 +24,7 @@ ocil_clause: 'audit backlog limit is not configured'
973b04
 ocil: |-
973b04
   To check that all boot entries extend the backlog limit;
973b04
   Check that all boot entries extend the log events queue:
973b04
-  
sudo grep -L "^options\s+.*\baudit_backlog_limit=0\b" /boot/loader/entries/*.conf
973b04
+  
sudo grep -L "^options\s+.*\baudit_backlog_limit=8192\b" /boot/loader/entries/*.conf
973b04
   No line should be returned, each line returned is a boot entry that does not extend the log events queue.
973b04
 
973b04
 platform: machine
973b04
973b04
From 779506348675557e204e1d88f214833b313c0f20 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Thu, 9 Jul 2020 12:00:10 +0200
973b04
Subject: [PATCH 06/18] zipl_slub_debug_argument: Fix description
973b04
973b04
Description about how to ensure that new boot entries continue compliant
973b04
was incorrect due to copy-pasta mistake.
973b04
---
973b04
 .../system/bootloader-zipl/zipl_slub_debug_argument/rule.yml    | 2 +-
973b04
 1 file changed, 1 insertion(+), 1 deletion(-)
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
index 84a374e36f..83e043179d 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
@@ -8,7 +8,7 @@ description: |-
973b04
     To enable poisoning of SLUB/SLAB objects,
973b04
     check that all boot entries in <tt>/boot/loader/entries/*.conf</tt> have <tt>slub_debug=P</tt>
973b04
     included in its options.
973b04
-    To ensure that new kernels and boot entries continue to extend the audit log events queue,
973b04
+    To ensure that new kernels and boot entries continue to enable poisoning of SLUB/SLAB objects,
973b04
     add <tt>slub_debug=P</tt> to <tt>/etc/kernel/cmdline</tt>.
973b04
 
973b04
 rationale: |-
973b04
973b04
From 6a3f2f6bdc13188e780f0f3e4f829f6fa79351b2 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Thu, 9 Jul 2020 12:06:56 +0200
973b04
Subject: [PATCH 07/18] Add CCEs to zIPL argument rules
973b04
973b04
---
973b04
 .../system/bootloader-zipl/zipl_audit_argument/rule.yml     | 3 +++
973b04
 .../zipl_audit_backlog_limit_argument/rule.yml              | 3 +++
973b04
 .../bootloader-zipl/zipl_page_poison_argument/rule.yml      | 3 +++
973b04
 .../guide/system/bootloader-zipl/zipl_pti_argument/rule.yml | 3 +++
973b04
 .../bootloader-zipl/zipl_slub_debug_argument/rule.yml       | 3 +++
973b04
 .../system/bootloader-zipl/zipl_vsyscall_argument/rule.yml  | 3 +++
973b04
 7 files changed, 18 insertions(+), 6 deletions(-)
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml
973b04
index 894bf7995f..b1307ef3f2 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/rule.yml
973b04
@@ -20,6 +20,9 @@ rationale: |-
973b04
 
973b04
 severity: medium
973b04
 
973b04
+identifiers:
973b04
+    cce@rhel8: 83321-0
973b04
+
973b04
 ocil_clause: 'auditing is not enabled at boot time'
973b04
 
973b04
 ocil: |-
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
index 15729dc6b6..18391bee6c 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_backlog_limit_argument/rule.yml
973b04
@@ -19,6 +19,9 @@ rationale: |-
973b04
 
973b04
 severity: medium
973b04
 
973b04
+identifiers:
973b04
+    cce@rhel8: 83341-8
973b04
+
973b04
 ocil_clause: 'audit backlog limit is not configured'
973b04
 
973b04
 ocil: |-
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml
973b04
index f5a36ee1b3..7ffea8ce6a 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_page_poison_argument/rule.yml
973b04
@@ -20,6 +20,9 @@ rationale: |-
973b04
 
973b04
 severity: medium
973b04
 
973b04
+identifiers:
973b04
+    cce@rhel8: 83351-7
973b04
+
973b04
 ocil_clause: 'page allocator poisoning is not enabled'
973b04
 
973b04
 ocil: |-
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml
973b04
index 168dae46a1..6fd1082292 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_pti_argument/rule.yml
973b04
@@ -19,6 +19,9 @@ rationale: |-
973b04
 
973b04
 severity: medium
973b04
 
973b04
+identifiers:
973b04
+    cce@rhel8: 83361-6
973b04
+
973b04
 ocil_clause: 'Kernel page-table isolation is not enabled'
973b04
 
973b04
 ocil: |-
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
index 83e043179d..c499140c35 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_slub_debug_argument/rule.yml
973b04
@@ -20,6 +20,9 @@ rationale: |-
973b04
 
973b04
 severity: medium
973b04
 
973b04
+identifiers:
973b04
+    cce@rhel8: 83371-5
973b04
+
973b04
 ocil_clause: 'SLUB/SLAB poisoning is not enabled'
973b04
 
973b04
 ocil: |-
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml b/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml
973b04
index c37e8bbefd..7edd43074f 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_vsyscall_argument/rule.yml
973b04
@@ -17,6 +17,9 @@ rationale: |-
973b04
 
973b04
 severity: medium
973b04
 
973b04
+identifiers:
973b04
+    cce@rhel8: 83381-4
973b04
+
973b04
 ocil_clause: 'vsyscalls are enabled'
973b04
 
973b04
 ocil: |-
973b04
973b04
From a7c33132a8d5f8cdf9c0d5f38b4910376ff1330b Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Thu, 9 Jul 2020 14:36:28 +0200
973b04
Subject: [PATCH 08/18] Select zipl BLS option rules in OSPP Profile
973b04
973b04
These rules check and ensure configuration of BLS boot options used by
973b04
zIPL.
973b04
---
973b04
 rhel8/profiles/ospp.profile | 8 ++++++++
973b04
 rhel8/profiles/stig.profile | 6 ++++++
973b04
 2 files changed, 14 insertions(+)
973b04
973b04
diff --git a/rhel8/profiles/ospp.profile b/rhel8/profiles/ospp.profile
973b04
index 80e4b71fff..d3732fa805 100644
973b04
--- a/rhel8/profiles/ospp.profile
973b04
+++ b/rhel8/profiles/ospp.profile
973b04
@@ -419,3 +419,11 @@ selections:
973b04
     # zIPl specific rules
973b04
     - zipl_bls_entries_only
973b04
     - zipl_bootmap_is_up_to_date
973b04
+    - zipl_audit_argument
973b04
+    - zipl_audit_backlog_limit_argument
973b04
+    - zipl_slub_debug_argument
973b04
+    - zipl_page_poison_argument
973b04
+    - zipl_vsyscall_argument
973b04
+    - zipl_vsyscall_argument.role=unscored
973b04
+    - zipl_vsyscall_argument.severity=info
973b04
+    - zipl_pti_argument
973b04
diff --git a/rhel8/profiles/stig.profile b/rhel8/profiles/stig.profile
973b04
index cfc2160be1..69d5222a32 100644
973b04
--- a/rhel8/profiles/stig.profile
973b04
+++ b/rhel8/profiles/stig.profile
973b04
@@ -49,3 +49,9 @@ selections:
973b04
     # Unselect zIPL rules from OSPP
973b04
     - "!zipl_bls_entries_only"
973b04
     - "!zipl_bootmap_is_up_to_date"
973b04
+    - "!zipl_audit_argument"
973b04
+    - "!zipl_audit_backlog_limit_argument"
973b04
+    - "!zipl_page_poison_argument"
973b04
+    - "!zipl_pti_argument"
973b04
+    - "!zipl_slub_debug_argument"
973b04
+    - "!zipl_vsyscall_argument"
973b04
973b04
From be070d56abed9efc9244b6c989d0a0df1f78b5ff Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Thu, 9 Jul 2020 22:30:25 +0200
973b04
Subject: [PATCH 09/18] Extend Profile resolution to undo rule refinements
973b04
973b04
Just like rule selection, allows rule refinements to be unselected, or "undone".
973b04
---
973b04
 build-scripts/compile_profiles.py | 16 +++++++++++++++-
973b04
 1 file changed, 15 insertions(+), 1 deletion(-)
973b04
973b04
diff --git a/build-scripts/compile_profiles.py b/build-scripts/compile_profiles.py
973b04
index 0967252348..d1ce8984b2 100644
973b04
--- a/build-scripts/compile_profiles.py
973b04
+++ b/build-scripts/compile_profiles.py
973b04
@@ -3,6 +3,7 @@
973b04
 import argparse
973b04
 import sys
973b04
 import os.path
973b04
+from copy import deepcopy
973b04
 from glob import glob
973b04
 
973b04
 import ssg.build_yaml
973b04
@@ -36,7 +37,8 @@ def resolve(self, all_profiles):
973b04
             updated_variables.update(self.variables)
973b04
             self.variables = updated_variables
973b04
 
973b04
-            updated_refinements = dict(extended_profile.refine_rules)
973b04
+            extended_refinements = deepcopy(extended_profile.refine_rules)
973b04
+            updated_refinements = self._subtract_refinements(extended_refinements)
973b04
             updated_refinements.update(self.refine_rules)
973b04
             self.refine_rules = updated_refinements
973b04
 
973b04
@@ -50,6 +52,18 @@ def resolve(self, all_profiles):
973b04
 
973b04
         self.resolved = True
973b04
 
973b04
+    def _subtract_refinements(self, extended_refinements):
973b04
+        """
973b04
+        Given a dict of rule refinements from the extended profile,
973b04
+        "undo" every refinement prefixed with '!' in this profile.
973b04
+        """
973b04
+        for rule, refinements in list(self.refine_rules.items()):
973b04
+            if rule.startswith("!"):
973b04
+                for prop, val in refinements:
973b04
+                    extended_refinements[rule[1:]].remove((prop, val))
973b04
+                del self.refine_rules[rule]
973b04
+        return extended_refinements
973b04
+
973b04
 
973b04
 def create_parser():
973b04
     parser = argparse.ArgumentParser()
973b04
973b04
From 2ea270b1796139f42a1d56cbb31351b3f6ad3a6e Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Thu, 9 Jul 2020 22:32:32 +0200
973b04
Subject: [PATCH 10/18] Undo rule refinements done to zIPL rules
973b04
973b04
Remove the zIPl rule refinementes from STIG profile
973b04
---
973b04
 rhel8/profiles/stig.profile | 2 ++
973b04
 1 file changed, 2 insertions(+)
973b04
973b04
diff --git a/rhel8/profiles/stig.profile b/rhel8/profiles/stig.profile
973b04
index 69d5222a32..53647475aa 100644
973b04
--- a/rhel8/profiles/stig.profile
973b04
+++ b/rhel8/profiles/stig.profile
973b04
@@ -55,3 +55,5 @@ selections:
973b04
     - "!zipl_pti_argument"
973b04
     - "!zipl_slub_debug_argument"
973b04
     - "!zipl_vsyscall_argument"
973b04
+    - "!zipl_vsyscall_argument.role=unscored"
973b04
+    - "!zipl_vsyscall_argument.severity=info"
973b04
973b04
From 90d62ba0cd088eb95aa151fe08a9c3c9fd959a00 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 09:38:57 +0200
973b04
Subject: [PATCH 11/18] Update stable test for OSPP Profile
973b04
973b04
I just copied the resolved profile to profile_stability directory.
973b04
---
973b04
 tests/data/profile_stability/rhel8/ospp.profile | 14 +++++++++++---
973b04
 1 file changed, 11 insertions(+), 3 deletions(-)
973b04
973b04
diff --git a/tests/data/profile_stability/rhel8/ospp.profile b/tests/data/profile_stability/rhel8/ospp.profile
973b04
index 08dcccf24c..5aa3592496 100644
973b04
--- a/tests/data/profile_stability/rhel8/ospp.profile
973b04
+++ b/tests/data/profile_stability/rhel8/ospp.profile
973b04
@@ -168,6 +168,7 @@ selections:
973b04
 - service_rngd_enabled
973b04
 - service_systemd-coredump_disabled
973b04
 - service_usbguard_enabled
973b04
+- ssh_client_rekey_limit
973b04
 - sshd_disable_empty_passwords
973b04
 - sshd_disable_gssapi_auth
973b04
 - sshd_disable_kerb_auth
973b04
@@ -213,8 +214,14 @@ selections:
973b04
 - sysctl_user_max_user_namespaces
973b04
 - timer_dnf-automatic_enabled
973b04
 - usbguard_allow_hid_and_hub
973b04
+- zipl_audit_argument
973b04
+- zipl_audit_backlog_limit_argument
973b04
 - zipl_bls_entries_only
973b04
 - zipl_bootmap_is_up_to_date
973b04
+- zipl_page_poison_argument
973b04
+- zipl_pti_argument
973b04
+- zipl_slub_debug_argument
973b04
+- zipl_vsyscall_argument
973b04
 - var_sshd_set_keepalive=0
973b04
 - var_rekey_limit_size=1G
973b04
 - var_rekey_limit_time=1hour
973b04
@@ -238,11 +245,12 @@ selections:
973b04
 - var_accounts_passwords_pam_faillock_deny=3
973b04
 - var_accounts_passwords_pam_faillock_fail_interval=900
973b04
 - var_accounts_passwords_pam_faillock_unlock_time=never
973b04
+- var_ssh_client_rekey_limit_size=1G
973b04
+- var_ssh_client_rekey_limit_time=1hour
973b04
 - grub2_vsyscall_argument.role=unscored
973b04
 - grub2_vsyscall_argument.severity=info
973b04
 - sysctl_user_max_user_namespaces.role=unscored
973b04
 - sysctl_user_max_user_namespaces.severity=info
973b04
-- ssh_client_rekey_limit
973b04
-- var_ssh_client_rekey_limit_size=1G
973b04
-- var_ssh_client_rekey_limit_time=1hour
973b04
+- zipl_vsyscall_argument.role=unscored
973b04
+- zipl_vsyscall_argument.severity=info
973b04
 title: Protection Profile for General Purpose Operating Systems
973b04
973b04
From b5d5b0f1d4319663aba9f051fc01f5209234da6f Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 15:15:25 +0200
973b04
Subject: [PATCH 12/18] zipl_bls_entries_option: Add test scenarios
973b04
973b04
---
973b04
 .../tests/correct_option.pass.sh                 | 16 ++++++++++++++++
973b04
 .../tests/missing_in_cmdline.fail.sh             | 14 ++++++++++++++
973b04
 .../tests/missing_in_entry.fail.sh               | 14 ++++++++++++++
973b04
 3 files changed, 44 insertions(+)
973b04
 create mode 100644 linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
 create mode 100644 linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
 create mode 100644 linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
new file mode 100644
973b04
index 0000000000..a9bd49dd0b
973b04
--- /dev/null
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
@@ -0,0 +1,16 @@
973b04
+#!/bin/bash
973b04
+# platform = Red Hat Enterprise Linux 8
973b04
+# remediation = none
973b04
+
973b04
+# Make sure boot loader entries contain audit=1
973b04
+for file in /boot/loader/entries/*.conf
973b04
+do
973b04
+    if ! grep -q '^options.*audit=1.*$' "$file" ; then
973b04
+        sed -i '/^options / s/$/audit=1/' "$file"
973b04
+    fi
973b04
+done
973b04
+
973b04
+# Make sure /etc/kernel/cmdline contains audit=1
973b04
+if ! grep -q '^(.*\s)?audit=1(\s.*)?$' /etc/kernel/cmdline ; then
973b04
+    echo "audit=1" >> /etc/kernel/cmdline
973b04
+fi
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
new file mode 100644
973b04
index 0000000000..d4d1d978c8
973b04
--- /dev/null
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
@@ -0,0 +1,14 @@
973b04
+#!/bin/bash
973b04
+# platform = Red Hat Enterprise Linux 8
973b04
+# remediation = none
973b04
+
973b04
+# Make sure boot loader entries contain audit=1
973b04
+for file in /boot/loader/entries/*.conf
973b04
+do
973b04
+    if ! grep -q '^options.*audit=1.*$' "$file" ; then
973b04
+        sed -i '/^options / s/$/audit=1/' "$file"
973b04
+    fi
973b04
+done
973b04
+
973b04
+# Make sure /etc/kernel/cmdline doesn't contain audit=1
973b04
+sed -Ei 's/(^.*)audit=1(.*?)$/\1\2/' /etc/kernel/cmdline || true
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
new file mode 100644
973b04
index 0000000000..3e412c0542
973b04
--- /dev/null
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
@@ -0,0 +1,14 @@
973b04
+#!/bin/bash
973b04
+# platform = Red Hat Enterprise Linux 8
973b04
+# remediation = none
973b04
+
973b04
+# Remove audit=1 from all boot entries
973b04
+sed -Ei 's/(^options.*\s)audit=1(.*?)$/\1\2/' /boot/loader/entries/*
973b04
+# But make sure one boot loader entry contains audit=1
973b04
+sed -i '/^options / s/$/audit=1/' /boot/loader/entries/*rescue.conf
973b04
+sed -Ei 's/(^options.*\s)\$kernelopts(.*?)$/\1\2/' /boot/loader/entries/*rescue.conf
973b04
+
973b04
+# Make sure /etc/kernel/cmdline contains audit=1
973b04
+if ! grep -q '^(.*\s)?audit=1(\s.*)?$' /etc/kernel/cmdline ; then
973b04
+    echo "audit=1" >> /etc/kernel/cmdline
973b04
+fi
973b04
973b04
From 3b52ab44e043adb289ef0a96798cffaf3e1f35a1 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 15:34:52 +0200
973b04
Subject: [PATCH 13/18] zipl_bls_entries_option: Remove hardcoded values
973b04
973b04
The template shouldn't have any hardcoded values.
973b04
---
973b04
 shared/templates/template_BASH_zipl_bls_entries_option | 3 +--
973b04
 1 file changed, 1 insertion(+), 2 deletions(-)
973b04
973b04
diff --git a/shared/templates/template_BASH_zipl_bls_entries_option b/shared/templates/template_BASH_zipl_bls_entries_option
973b04
index 9fc8865486..dde8c948f7 100644
973b04
--- a/shared/templates/template_BASH_zipl_bls_entries_option
973b04
+++ b/shared/templates/template_BASH_zipl_bls_entries_option
973b04
@@ -7,6 +7,5 @@ grubby --update-kernel=ALL --args="{{{ ARG_NAME_VALUE }}}"
973b04
 if [ ! -f /etc/kernel/cmdline ]; then
973b04
     echo "{{{ ARG_NAME_VALUE }}}" >> /etc/kernel/cmdline
973b04
 elif ! grep -q '^(.*\s)?{{{ ARG_NAME_VALUE }}}(\s.*)?$' /etc/kernel/cmdline; then
973b04
-    echo " audit=1" >> /etc/kernel/cmdline
973b04
-    sed -Ei 's/^(.*)$/\1 audit=1/' /etc/kernel/cmdline
973b04
+    sed -Ei 's/^(.*)$/\1 {{{ ARG_NAME_VALUE }}}/' /etc/kernel/cmdline
973b04
 fi
973b04
973b04
From 68bff71c7f60a7c68cf0bd9aa153f8a78ec02b7d Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 16:08:26 +0200
973b04
Subject: [PATCH 14/18] Improve conditional check for the grubby command
973b04
973b04
Let's not trust that /boot/loader/entries/ only contains *.conf files.
973b04
Count the number of conf files and how many set the propper options.
973b04
---
973b04
 .../template_ANSIBLE_zipl_bls_entries_option       | 14 +++++++++-----
973b04
 1 file changed, 9 insertions(+), 5 deletions(-)
973b04
973b04
diff --git a/shared/templates/template_ANSIBLE_zipl_bls_entries_option b/shared/templates/template_ANSIBLE_zipl_bls_entries_option
973b04
index c0cb131b82..bccad2267c 100644
973b04
--- a/shared/templates/template_ANSIBLE_zipl_bls_entries_option
973b04
+++ b/shared/templates/template_ANSIBLE_zipl_bls_entries_option
973b04
@@ -6,18 +6,22 @@
973b04
 
973b04
 - name: "Ensure BLS boot entries options contain {{{ ARG_NAME_VALUE }}}"
973b04
   block:
973b04
-    - name: "Check if any boot entry misses {{{ ARG_NAME_VALUE }}}"
973b04
+    - name: "Check how many boot entries exist "
973b04
+      find:
973b04
+        paths: "/boot/loader/entries/"
973b04
+        patterns: "*.conf"
973b04
+      register: n_entries
973b04
+
973b04
+    - name: "Check how many boot entries set {{{ ARG_NAME_VALUE }}}"
973b04
       find:
973b04
         paths: "/boot/loader/entries/"
973b04
         contains: "^options .*{{{ ARG_NAME_VALUE }}}.*$"
973b04
         patterns: "*.conf"
973b04
-      register: entries_options
973b04
+      register: n_entries_options
973b04
 
973b04
     - name: "Update boot entries options"
973b04
       command: grubby --update-kernel=ALL --args="{{{ ARG_NAME_VALUE }}}"
973b04
-      when: entries_options is defined and entries_options.examined != entries_options.matched
973b04
-      # The conditional above assumes that only *.conf files are present in /boot/loader/entries
973b04
-      # Then, the number of conf files is the same as examined files
973b04
+      when: n_entries is defined and n_entries_options is defined and n_entries.matched != n_entries_options.matched
973b04
 
973b04
     - name: "Check if /etc/kernel/cmdline exists"
973b04
       stat:
973b04
973b04
From 79c60bb40288c17381bf1e4a84e6cfd300bd8446 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 16:17:27 +0200
973b04
Subject: [PATCH 15/18] zipl_bls_entries_option: Fix sed in test scenario
973b04
973b04
Append "audit=1" space from last option.
973b04
---
973b04
 .../zipl_audit_argument/tests/correct_option.pass.sh            | 2 +-
973b04
 .../zipl_audit_argument/tests/missing_in_cmdline.fail.sh        | 2 +-
973b04
 .../zipl_audit_argument/tests/missing_in_entry.fail.sh          | 2 +-
973b04
 3 files changed, 3 insertions(+), 3 deletions(-)
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
index a9bd49dd0b..5fcbcc5667 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
@@ -6,7 +6,7 @@
973b04
 for file in /boot/loader/entries/*.conf
973b04
 do
973b04
     if ! grep -q '^options.*audit=1.*$' "$file" ; then
973b04
-        sed -i '/^options / s/$/audit=1/' "$file"
973b04
+        sed -i '/^options / s/$/ audit=1/' "$file"
973b04
     fi
973b04
 done
973b04
 
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
index d4d1d978c8..b75165f904 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
@@ -6,7 +6,7 @@
973b04
 for file in /boot/loader/entries/*.conf
973b04
 do
973b04
     if ! grep -q '^options.*audit=1.*$' "$file" ; then
973b04
-        sed -i '/^options / s/$/audit=1/' "$file"
973b04
+        sed -i '/^options / s/$/ audit=1/' "$file"
973b04
     fi
973b04
 done
973b04
 
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
index 3e412c0542..e3d342d533 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
@@ -5,7 +5,7 @@
973b04
 # Remove audit=1 from all boot entries
973b04
 sed -Ei 's/(^options.*\s)audit=1(.*?)$/\1\2/' /boot/loader/entries/*
973b04
 # But make sure one boot loader entry contains audit=1
973b04
-sed -i '/^options / s/$/audit=1/' /boot/loader/entries/*rescue.conf
973b04
+sed -i '/^options / s/$/ audit=1/' /boot/loader/entries/*rescue.conf
973b04
 sed -Ei 's/(^options.*\s)\$kernelopts(.*?)$/\1\2/' /boot/loader/entries/*rescue.conf
973b04
 
973b04
 # Make sure /etc/kernel/cmdline contains audit=1
973b04
973b04
From d513177d2cea39db364a0ff39a599ded36a25395 Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 16:29:06 +0200
973b04
Subject: [PATCH 16/18] Extend scenarios platform and allow remediation
973b04
973b04
These test scenarios can be run on any OS that supports BLS and provides
973b04
grubby.
973b04
But it will evaluate to not applicable if the OS doesn't use zIPL (i.e.:
973b04
has s390utils-base installed).
973b04
---
973b04
 .../zipl_audit_argument/tests/correct_option.pass.sh           | 3 +--
973b04
 .../zipl_audit_argument/tests/missing_in_cmdline.fail.sh       | 3 +--
973b04
 .../zipl_audit_argument/tests/missing_in_entry.fail.sh         | 3 +--
973b04
 3 files changed, 3 insertions(+), 6 deletions(-)
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
index 5fcbcc5667..73ed0eae0f 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
@@ -1,6 +1,5 @@
973b04
 #!/bin/bash
973b04
-# platform = Red Hat Enterprise Linux 8
973b04
-# remediation = none
973b04
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
973b04
 
973b04
 # Make sure boot loader entries contain audit=1
973b04
 for file in /boot/loader/entries/*.conf
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
index b75165f904..3af83d30d8 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_cmdline.fail.sh
973b04
@@ -1,6 +1,5 @@
973b04
 #!/bin/bash
973b04
-# platform = Red Hat Enterprise Linux 8
973b04
-# remediation = none
973b04
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
973b04
 
973b04
 # Make sure boot loader entries contain audit=1
973b04
 for file in /boot/loader/entries/*.conf
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
index e3d342d533..142f75ba60 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
@@ -1,6 +1,5 @@
973b04
 #!/bin/bash
973b04
-# platform = Red Hat Enterprise Linux 8
973b04
-# remediation = none
973b04
+# platform = multi_platform_fedora,Red Hat Enterprise Linux 8
973b04
 
973b04
 # Remove audit=1 from all boot entries
973b04
 sed -Ei 's/(^options.*\s)audit=1(.*?)$/\1\2/' /boot/loader/entries/*
973b04
973b04
From 2e841722d30551c86f14558ff39bdaa5dda55711 Mon Sep 17 00:00:00 2001
973b04
From: Watson Yuuma Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 16:35:55 +0200
973b04
Subject: [PATCH 17/18] Update comment in OVAL zipl_bls_entries_option
973b04
973b04
Co-authored-by: vojtapolasek <krecoun@gmail.com>
973b04
---
973b04
 shared/templates/template_OVAL_zipl_bls_entries_option | 2 +-
973b04
 1 file changed, 1 insertion(+), 1 deletion(-)
973b04
973b04
diff --git a/shared/templates/template_OVAL_zipl_bls_entries_option b/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
index 9af1bcfbee..502d5e7d9a 100644
973b04
--- a/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
+++ b/shared/templates/template_OVAL_zipl_bls_entries_option
973b04
@@ -7,7 +7,7 @@
973b04
     </metadata>
973b04
     <criteria operator="AND">
973b04
       
973b04
-      comment="Check if {{{ ARG_NAME_VALUE }}} is present in the 'options' line in /boot/loader/entries/*" />
973b04
+      comment="Check if {{{ ARG_NAME_VALUE }}} is present in the 'options' line in /boot/loader/entries/*.conf" />
973b04
       
973b04
       comment="Make sure that newly installed kernels will retain {{{ ARG_NAME_VALUE }}} option" />
973b04
     </criteria>
973b04
973b04
From 9bd0afbde47ef368444ba1785da593980e6e00aa Mon Sep 17 00:00:00 2001
973b04
From: Watson Sato <wsato@redhat.com>
973b04
Date: Fri, 10 Jul 2020 17:15:46 +0200
973b04
Subject: [PATCH 18/18] zipl_bls_entries_option: Supress grep error messages
973b04
973b04
/etc/kernel/cmdline is not always present. Lest suppress any error
973b04
message about absent file in the test scenarios.
973b04
---
973b04
 .../zipl_audit_argument/tests/correct_option.pass.sh            | 2 +-
973b04
 .../zipl_audit_argument/tests/missing_in_entry.fail.sh          | 2 +-
973b04
 2 files changed, 2 insertions(+), 2 deletions(-)
973b04
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
index 73ed0eae0f..7a828837fe 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/correct_option.pass.sh
973b04
@@ -10,6 +10,6 @@ do
973b04
 done
973b04
 
973b04
 # Make sure /etc/kernel/cmdline contains audit=1
973b04
-if ! grep -q '^(.*\s)?audit=1(\s.*)?$' /etc/kernel/cmdline ; then
973b04
+if ! grep -qs '^(.*\s)?audit=1(\s.*)?$' /etc/kernel/cmdline ; then
973b04
     echo "audit=1" >> /etc/kernel/cmdline
973b04
 fi
973b04
diff --git a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
index 142f75ba60..5650cc0a74 100644
973b04
--- a/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
+++ b/linux_os/guide/system/bootloader-zipl/zipl_audit_argument/tests/missing_in_entry.fail.sh
973b04
@@ -8,6 +8,6 @@ sed -i '/^options / s/$/ audit=1/' /boot/loader/entries/*rescue.conf
973b04
 sed -Ei 's/(^options.*\s)\$kernelopts(.*?)$/\1\2/' /boot/loader/entries/*rescue.conf
973b04
 
973b04
 # Make sure /etc/kernel/cmdline contains audit=1
973b04
-if ! grep -q '^(.*\s)?audit=1(\s.*)?$' /etc/kernel/cmdline ; then
973b04
+if ! grep -qs '^(.*\s)?audit=1(\s.*)?$' /etc/kernel/cmdline ; then
973b04
     echo "audit=1" >> /etc/kernel/cmdline
973b04
 fi