Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bash conditional for checking system architecture #12815

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/applicability/aarch64_arch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cpe:/a:aarch64_arch
title: System architecture is AARCH64
check_id: proc_sys_kernel_osrelease_arch_aarch64
bash_conditional: 'grep -q aarch64 /proc/sys/kernel/{osrelease,arch}'
bash_conditional: {{{ bash_arch_conditional("aarch64") }}}
ansible_conditional: 'ansible_architecture == "aarch64"'
2 changes: 1 addition & 1 deletion shared/applicability/not_aarch64_arch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cpe:/a:not_aarch64_arch
title: System architecture is not AARCH64
check_id: proc_sys_kernel_osrelease_arch_not_aarch64
bash_conditional: '! grep -q aarch64 /proc/sys/kernel/{osrelease,arch}'
bash_conditional: '! {{{ bash_arch_conditional("aarch64") }}}'
ansible_conditional: 'ansible_architecture != "aarch64"'
2 changes: 1 addition & 1 deletion shared/applicability/not_s390x_arch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cpe:/a:not_s390x_arch
title: System architecture is not S390X
check_id: proc_sys_kernel_osrelease_arch_not_s390x
bash_conditional: '! grep -q s390x /proc/sys/kernel/{osrelease,arch}'
bash_conditional: '! {{{ bash_arch_conditional("s390x") }}}'
ansible_conditional: 'ansible_architecture != "s390x"'
2 changes: 1 addition & 1 deletion shared/applicability/ppc64le_arch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "cpe:/a:ppc64le_arch"
title: "System architecture is ppc64le"
check_id: proc_sys_kernel_osrelease_arch_ppc64le
bash_conditional: 'grep -q ppc64le /proc/sys/kernel/{osrelease,arch}'
bash_conditional: {{{ bash_arch_conditional("ppc64le") }}}
ansible_conditional: 'ansible_architecture == "ppc64le"'
2 changes: 1 addition & 1 deletion shared/applicability/s390x_arch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cpe:/a:s390x_arch
title: System architecture is S390X
check_id: proc_sys_kernel_osrelease_arch_s390x
bash_conditional: 'grep -q s390x /proc/sys/kernel/{osrelease,arch}'
bash_conditional: {{{ bash_arch_conditional("s390x") }}}
ansible_conditional: 'ansible_architecture == "s390x"'
2 changes: 1 addition & 1 deletion shared/applicability/x86_64_arch.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cpe:/a:x86_64_arch
title: System architecture is x86_64
check_id: proc_sys_kernel_osrelease_arch_x86_64
bash_conditional: 'grep -q x86_64 /proc/sys/kernel/{osrelease,arch}'
bash_conditional: {{{ bash_arch_conditional("x86_64") }}}
ansible_conditional: 'ansible_architecture == "x86_64"'
11 changes: 11 additions & 0 deletions shared/macros/10-bash.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2668,3 +2668,14 @@ if the remediation is not performed during a build of a bootable container image
{{%- macro bash_not_bootc_build() -%}}
[[ "$OSCAP_BOOTC_BUILD" != "YES" ]]
{{%- endmacro -%}}


{{#
This macro creates a Bash conditional which checks the system architecture in /proc/sys/kernel/{osrelease,arch}

:param arch: system architecture (x86_64, aarch64, s90x, ppc64le, ...)
:type arch: str
#}}
{{%- macro bash_arch_conditional(arch) -%}}
( grep -sqE "^.*\.{{{ arch }}}$" /proc/sys/kernel/osrelease || grep -sqE "^{{{ arch }}}$" /proc/sys/kernel/arch; )
{{%- endmacro -%}}
1 change: 1 addition & 0 deletions shared/macros/10-oval.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,7 @@ The macros generates the OVAL test including the dependent OVAL object and OVAL
Macro for checking the system architecture in /proc/sys/kernel/{osrelease,arch}

:param arch: system architecture (x86_64, aarch64, s90x, ppc64le, ...)
:type arch: str
#}}
{{%- macro oval_check_proc_sys_kernel_osrelease_arch(arch) -%}}
<def-group>
Expand Down
Loading