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

Add "is_substring" variable to grub2_bootloader_argument template #12308

Merged
merged 3 commits into from
Aug 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ template:
vars:
arg_name: slub_debug
arg_variable: var_slub_debug_options
is_substring@ol8: "true"

fixtext: |-
{{{ describe_grub2_argument("slub_debug=" ~ xccdf_value("var_slub_debug_options")) | indent(4) }}}
Expand Down
6 changes: 6 additions & 0 deletions shared/templates/grub2_bootloader_argument/oval.template
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,13 @@
datatype="string" version="1">
<concat>
<literal_component>^(?:.*\s)?{{{ ARG_NAME }}}=</literal_component>
{{% if IS_SUBSTRING == "true" %}}
<literal_component>\S*</literal_component>
{{% endif %}}
<variable_component var_ref="{{{ ARG_VARIABLE }}}" />
{{% if IS_SUBSTRING == "true" %}}
<literal_component>\S*</literal_component>
{{% endif %}}
<literal_component>(?:\s.*)?$</literal_component>
</concat>
</local_variable>
Expand Down
3 changes: 3 additions & 0 deletions shared/templates/grub2_bootloader_argument/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def preprocess(data, lang):
else:
data["arg_name_value"] = data["arg_name"] + "=" + data["arg_value"]

if 'is_substring' not in data:
data["is_substring"] = "false"

if lang == "oval":
# escape dot, this is used in oval regex
data["escaped_arg_name_value"] = data["arg_name_value"].replace(".", "\\.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
{{% if IS_SUBSTRING != "true" %}}
# platform = Not Applicable
{{% else %}}
# platform = multi_platform_all
{{% endif %}}
{{%- if 'ubuntu' in product %}}
# packages = grub2
{{%- else %}}
# packages = grub2,grubby
{{%- endif %}}

{{%- if ARG_VARIABLE %}}
# variables = {{{ ARG_VARIABLE }}}=correct_value
{{%- set ARG_NAME_VALUE= ARG_NAME ~ "=correct_value" %}}
{{%- endif %}}

{{%- set ARG_NAME_VALUE= ARG_NAME_VALUE ~ "A" %}}

source common.sh

{{{ grub2_bootloader_argument_remediation(ARG_NAME, ARG_NAME_VALUE) }}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
{{% if IS_SUBSTRING != "true" %}}
# platform = Not Applicable
{{% else %}}
# platform = multi_platform_all
{{% endif %}}
{{%- if 'ubuntu' in product %}}
# packages = grub2
{{%- else %}}
# packages = grub2,grubby
{{%- endif %}}

{{%- if ARG_VARIABLE %}}
# variables = {{{ ARG_VARIABLE }}}=correct_value
{{%- set ARG_NAME_VALUE= ARG_NAME ~ "=correct_value" %}}
{{%- endif %}}

{{%- set ARG_NAME_VALUE = (ARG_NAME_VALUE | replace("=","=A")) %}}

source common.sh

{{{ grub2_bootloader_argument_remediation(ARG_NAME, ARG_NAME_VALUE) }}}
Loading