|
|
f386a0 |
From c4ce06ce707529c14376ca8bb6e2b03f072e81fd Mon Sep 17 00:00:00 2001
|
|
|
f386a0 |
From: Evgeny Kolesnikov <ekolesni@redhat.com>
|
|
|
f386a0 |
Date: Wed, 10 Aug 2022 13:20:29 +0200
|
|
|
f386a0 |
Subject: [PATCH 11/12] Merge pull request #9204 from
|
|
|
f386a0 |
matejak/applicability_var_tmp
|
|
|
f386a0 |
|
|
|
f386a0 |
Patch-name: scap-security-guide-0.1.64-add_platform_partition_exists-PR_9204.patch
|
|
|
f386a0 |
Patch-status: Introduce and apply the "partition exists" platform
|
|
|
f386a0 |
---
|
|
|
f386a0 |
.../mount_option_var_tmp_nodev/rule.yml | 3 ++-
|
|
|
f386a0 |
.../tests/notapplicable.pass.sh | 5 +++++
|
|
|
f386a0 |
shared/applicability/general.yml | 14 +++++++++++++
|
|
|
f386a0 |
.../checks/oval/installed_env_mounts_tmp.xml | 10 ++++++++++
|
|
|
f386a0 |
.../oval/installed_env_mounts_var_tmp.xml | 10 ++++++++++
|
|
|
f386a0 |
shared/macros/10-ansible.jinja | 5 +++++
|
|
|
f386a0 |
shared/macros/10-bash.jinja | 5 +++++
|
|
|
f386a0 |
shared/macros/10-oval.jinja | 20 +++++++++++++++++++
|
|
|
f386a0 |
8 files changed, 71 insertions(+), 1 deletion(-)
|
|
|
f386a0 |
create mode 100644 linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/tests/notapplicable.pass.sh
|
|
|
f386a0 |
create mode 100644 shared/checks/oval/installed_env_mounts_tmp.xml
|
|
|
f386a0 |
create mode 100644 shared/checks/oval/installed_env_mounts_var_tmp.xml
|
|
|
f386a0 |
|
|
|
f386a0 |
diff --git a/linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/rule.yml b/linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/rule.yml
|
|
|
f386a0 |
index 8ee8c8b12e..741d097328 100644
|
|
|
f386a0 |
--- a/linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/rule.yml
|
|
|
f386a0 |
+++ b/linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/rule.yml
|
|
|
f386a0 |
@@ -38,7 +38,8 @@ references:
|
|
|
f386a0 |
stigid@ol8: OL08-00-040132
|
|
|
f386a0 |
stigid@rhel8: RHEL-08-040132
|
|
|
f386a0 |
|
|
|
f386a0 |
-platform: machine
|
|
|
f386a0 |
+platforms:
|
|
|
f386a0 |
+ - machine and partition-var-tmp
|
|
|
f386a0 |
|
|
|
f386a0 |
template:
|
|
|
f386a0 |
name: mount_option
|
|
|
f386a0 |
diff --git a/linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/tests/notapplicable.pass.sh b/linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/tests/notapplicable.pass.sh
|
|
|
f386a0 |
new file mode 100644
|
|
|
f386a0 |
index 0000000000..241c0103d8
|
|
|
f386a0 |
--- /dev/null
|
|
|
f386a0 |
+++ b/linux_os/guide/system/permissions/partitions/mount_option_var_tmp_nodev/tests/notapplicable.pass.sh
|
|
|
f386a0 |
@@ -0,0 +1,5 @@
|
|
|
f386a0 |
+#!/bin/bash
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+. $SHARED/partition.sh
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+clean_up_partition /var/tmp # Remove the partition from the system, and unmount it
|
|
|
f386a0 |
diff --git a/shared/applicability/general.yml b/shared/applicability/general.yml
|
|
|
f386a0 |
index 2d23d75314..e2f5d04ce0 100644
|
|
|
f386a0 |
--- a/shared/applicability/general.yml
|
|
|
f386a0 |
+++ b/shared/applicability/general.yml
|
|
|
f386a0 |
@@ -77,6 +77,20 @@ cpes:
|
|
|
f386a0 |
bash_conditional: {{{ bash_pkg_conditional("pam") }}}
|
|
|
f386a0 |
ansible_conditional: {{{ ansible_pkg_conditional("pam") }}}
|
|
|
f386a0 |
|
|
|
f386a0 |
+ - partition-var-tmp:
|
|
|
f386a0 |
+ name: "cpe:/a:partition-var-tmp"
|
|
|
f386a0 |
+ title: "There is a /var/tmp partition"
|
|
|
f386a0 |
+ check_id: installed_env_mounts_var_tmp
|
|
|
f386a0 |
+ bash_conditional: {{{ bash_partition_conditional("/var/tmp") }}}
|
|
|
f386a0 |
+ ansible_conditional: {{{ ansible_partition_conditional("/var/tmp") }}}
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+ - partition-tmp:
|
|
|
f386a0 |
+ name: "cpe:/a:partition-tmp"
|
|
|
f386a0 |
+ title: "There is a /tmp partition"
|
|
|
f386a0 |
+ check_id: installed_env_mounts_tmp
|
|
|
f386a0 |
+ bash_conditional: {{{ bash_partition_conditional("/tmp") }}}
|
|
|
f386a0 |
+ ansible_conditional: {{{ ansible_partition_conditional("/tmp") }}}
|
|
|
f386a0 |
+
|
|
|
f386a0 |
- polkit:
|
|
|
f386a0 |
name: "cpe:/a:polkit"
|
|
|
f386a0 |
title: "Package polkit is installed"
|
|
|
f386a0 |
diff --git a/shared/checks/oval/installed_env_mounts_tmp.xml b/shared/checks/oval/installed_env_mounts_tmp.xml
|
|
|
f386a0 |
new file mode 100644
|
|
|
f386a0 |
index 0000000000..edd8ad050f
|
|
|
f386a0 |
--- /dev/null
|
|
|
f386a0 |
+++ b/shared/checks/oval/installed_env_mounts_tmp.xml
|
|
|
f386a0 |
@@ -0,0 +1,10 @@
|
|
|
f386a0 |
+<def-group>
|
|
|
f386a0 |
+ <definition class="inventory" id="installed_env_mounts_tmp" version="1">
|
|
|
f386a0 |
+ {{{ oval_metadata("", title="Partition /tmp exists", affected_platforms=[full_name]) }}}
|
|
|
f386a0 |
+ <criteria>
|
|
|
f386a0 |
+ {{{ partition_exists_criterion("/tmp") }}}
|
|
|
f386a0 |
+ </criteria>
|
|
|
f386a0 |
+ </definition>
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+ {{{ partition_exists_test_object("/tmp") }}}
|
|
|
f386a0 |
+</def-group>
|
|
|
f386a0 |
diff --git a/shared/checks/oval/installed_env_mounts_var_tmp.xml b/shared/checks/oval/installed_env_mounts_var_tmp.xml
|
|
|
f386a0 |
new file mode 100644
|
|
|
f386a0 |
index 0000000000..cf9aafbdb0
|
|
|
f386a0 |
--- /dev/null
|
|
|
f386a0 |
+++ b/shared/checks/oval/installed_env_mounts_var_tmp.xml
|
|
|
f386a0 |
@@ -0,0 +1,10 @@
|
|
|
f386a0 |
+<def-group>
|
|
|
f386a0 |
+ <definition class="inventory" id="installed_env_mounts_var_tmp" version="1">
|
|
|
f386a0 |
+ {{{ oval_metadata("", title="Partition /var/tmp exists", affected_platforms=[full_name]) }}}
|
|
|
f386a0 |
+ <criteria>
|
|
|
f386a0 |
+ {{{ partition_exists_criterion("/var/tmp") }}}
|
|
|
f386a0 |
+ </criteria>
|
|
|
f386a0 |
+ </definition>
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+ {{{ partition_exists_test_object("/var/tmp") }}}
|
|
|
f386a0 |
+</def-group>
|
|
|
f386a0 |
diff --git a/shared/macros/10-ansible.jinja b/shared/macros/10-ansible.jinja
|
|
|
f386a0 |
index 20dc2020e4..5e40fe4aa2 100644
|
|
|
f386a0 |
--- a/shared/macros/10-ansible.jinja
|
|
|
f386a0 |
+++ b/shared/macros/10-ansible.jinja
|
|
|
f386a0 |
@@ -1432,3 +1432,8 @@ Part of the grub2_bootloader_argument_absent template.
|
|
|
f386a0 |
when:
|
|
|
f386a0 |
- result_pam_file_present.stat.exists
|
|
|
f386a0 |
{{%- endmacro -%}}
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+{{%- macro ansible_partition_conditional(path) -%}}
|
|
|
f386a0 |
+"ansible_facts.ansible_mounts | json_query(\"[?mount=='{{{ path }}}'].mount\") | length == 1"
|
|
|
f386a0 |
+{{%- endmacro -%}}
|
|
|
f386a0 |
diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja
|
|
|
f386a0 |
index 41d9e18a1e..b0f7f3cf4a 100644
|
|
|
f386a0 |
--- a/shared/macros/10-bash.jinja
|
|
|
f386a0 |
+++ b/shared/macros/10-bash.jinja
|
|
|
f386a0 |
@@ -2073,3 +2073,8 @@ else
|
|
|
f386a0 |
echo "{{{ pam_file }}} was not found" >&2
|
|
|
f386a0 |
fi
|
|
|
f386a0 |
{{%- endmacro -%}}
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+{{%- macro bash_partition_conditional(path) -%}}
|
|
|
f386a0 |
+'findmnt --mountpoint "{{{ path }}}" > /dev/null'
|
|
|
f386a0 |
+{{%- endmacro -%}}
|
|
|
f386a0 |
diff --git a/shared/macros/10-oval.jinja b/shared/macros/10-oval.jinja
|
|
|
f386a0 |
index c8d7bbeffb..f302091f7d 100644
|
|
|
f386a0 |
--- a/shared/macros/10-oval.jinja
|
|
|
f386a0 |
+++ b/shared/macros/10-oval.jinja
|
|
|
f386a0 |
@@ -926,3 +926,23 @@ Generates the :code:`<affected>` tag for OVAL check using correct product platfo
|
|
|
f386a0 |
{{%- else %}}
|
|
|
f386a0 |
{{%- set user_list="nobody" %}}
|
|
|
f386a0 |
{{%- endif %}}
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+{{%- macro partition_exists_criterion(path) %}}
|
|
|
f386a0 |
+{{%- set escaped_path = path | escape_id %}}
|
|
|
f386a0 |
+ <criterion comment="The path {{{ path }}} is a partition's mount point" test_ref="test_partition_{{{ escaped_path }}}_exists" />
|
|
|
f386a0 |
+{{%- endmacro %}}
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+{{%- macro partition_exists_test_object(path) %}}
|
|
|
f386a0 |
+{{%- set escaped_path = path | escape_id %}}
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+ comment="Partition {{{ path }}} exists"
|
|
|
f386a0 |
+ id="test_partition_{{{ escaped_path }}}_exists"
|
|
|
f386a0 |
+ version="1">
|
|
|
f386a0 |
+ <linux:object object_ref="object_partition_{{{ escaped_path }}}_exists" />
|
|
|
f386a0 |
+ </linux:partition_test>
|
|
|
f386a0 |
+
|
|
|
f386a0 |
+ <linux:partition_object id="object_partition_{{{ escaped_path }}}_exists" version="1">
|
|
|
f386a0 |
+ <linux:mount_point>{{{ path }}}</linux:mount_point>
|
|
|
f386a0 |
+ </linux:partition_object>
|
|
|
f386a0 |
+{{%- endmacro %}}
|
|
|
f386a0 |
--
|
|
|
f386a0 |
2.37.1
|
|
|
f386a0 |
|