File: oval.template

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (362 lines) | stat: -rw-r--r-- 20,992 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
{{#-
  We set defaults to "off", and products should enable relevant ones depending on how the product configures grub.
   - /boot/loader/entries/* may not exist.
   - If they exist, they can reference variables defined in grubenv, or they can contain literal args
   - The grub cfg may either use those loader entries, or it can contain literal values as well
   - Kernel opts can be stored in /etc/default/grub so they are persistent between kernel upgrades
-#}}
{{% set system_with_expanded_kernel_options_in_loader_entries = false -%}}
{{% set system_with_kernel_options_in_grubenv = false -%}}
{{% set system_with_expanded_kernel_options_in_loader_entries_or_with_options_in_grubenv = false -%}}
{{% set system_with_kernel_options_in_etc_default_grub = true -%}}
{{% set system_with_kernel_options_in_etc_default_grub_d = false -%}}
{{% set system_with_expanded_kernel_options_in_grub_cfg = false -%}}
{{% set system_with_bios_and_uefi_support = false -%}}

{{% if product in ["fedora", "ol9", "rhel9", "rhel10"] -%}}
{{% set system_with_expanded_kernel_options_in_loader_entries = true %}}
{{%- endif -%}}

{{% if product in ["ol8", "rhel8"] -%}}
{{% set system_with_expanded_kernel_options_in_loader_entries_or_with_options_in_grubenv = true -%}}
{{%- endif -%}}

{{% if product in ["ol7"] or 'ubuntu' in product -%}}
{{% set system_with_expanded_kernel_options_in_grub_cfg = true %}}
{{%- endif -%}}

{{% if 'ubuntu' in product -%}}
{{% set system_with_kernel_options_in_etc_default_grub_d = true -%}}
{{%- endif -%}}

{{% if grub2_uefi_boot_path and grub2_uefi_boot_path != grub2_boot_path -%}}
{{% set system_with_bios_and_uefi_support = true %}}
{{%- endif -%}}

<def-group>
  <definition class="compliance" id="{{{ _RULE_ID }}}" version="2">
    {{{ oval_metadata("Ensure " + ARG_NAME_VALUE + " is configured in the kernel line in /etc/default/grub.") }}}
    <criteria operator="OR">
    <criteria operator="AND">
      {{% if bootable_containers_supported == "true" %}}
        <extend_definition comment="The system is RHEL Image Mode" definition_ref="bootc" negate="true" />
      {{% endif %}}
      {{% if system_with_expanded_kernel_options_in_loader_entries_or_with_options_in_grubenv %}}
      <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_entries_expanded_or_referenced"
      comment="Check /boot/loader/entries/*.conf files if they contain direct reference to {{{ ARG_NAME_VALUE }}} or if they contain $kernelopts" />
      <criteria operator="OR"
      comment="Expressing implication">
        <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_at_least_one_entry_referenced" negate="true"
        comment="Negate the result of the test if there exists at least one $kernelopts in /boot/loader/entries" />
        {{% if system_with_bios_and_uefi_support -%}}
        <criteria operator="OR">
        {{%- endif %}}
        <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_grub_env"
        comment="Check if {{{ ARG_NAME_VALUE }}} is present in the GRUB2 environment variable block in {{{ grub2_boot_path }}}/grubenv" />
      {{% if system_with_bios_and_uefi_support -%}}
        <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_grub_env_uefi"
        comment="Check if {{{ ARG_NAME_VALUE }}} is present in the GRUB2 environment variable block in {{{ grub2_uefi_boot_path }}}/grubenv" />
        </criteria>
        {{%- endif %}}
      </criteria>
      {{% elif system_with_kernel_options_in_grubenv -%}}
        <extend_definition comment="check kernel command line parameters for referenced boot entries reference the $kernelopts variable" definition_ref="grub2_entries_reference_kernelopts" />
      {{% if system_with_bios_and_uefi_support -%}}
      <criteria operator="OR">
      {{%- endif %}}
        <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_grub_env"
        comment="Check if {{{ ARG_NAME_VALUE }}} is present in the GRUB2 environment variable block in {{{ grub2_boot_path }}}/grubenv" />
      {{% if system_with_bios_and_uefi_support -%}}
        <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_grub_env_uefi"
        comment="Check if {{{ ARG_NAME_VALUE }}} is present in the GRUB2 environment variable block in {{{ grub2_uefi_boot_path }}}/grubenv" />
      </criteria>
      {{%- endif %}}
      {{% elif system_with_expanded_kernel_options_in_loader_entries -%}}
          <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_entries"
                     comment="Check if {{{ ARG_NAME_VALUE }}} is present in the boot parameters in the /boot/loader/entries/*.conf" />
      {{%- endif %}}
      {{% if system_with_expanded_kernel_options_in_grub_cfg -%}}
          {{% if system_with_bios_and_uefi_support -%}}
          <criteria operator="OR">
          {{%- endif %}}
          <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_grub_cfg"
          comment="Check if {{{ ARG_NAME_VALUE }}} is present in the boot parameters in the {{{ grub2_boot_path }}}/grub.cfg for all kernels" />
          {{% if system_with_bios_and_uefi_support -%}}
          <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_grub_cfg_uefi"
          comment="Check if {{{ ARG_NAME_VALUE }}} is present in the boot parameters in the {{{ grub2_uefi_boot_path }}}/grub.cfg for all kernels" />
          </criteria>
          {{%- endif %}}
      {{%- endif %}}
      {{% if system_with_kernel_options_in_etc_default_grub -%}}
        <criteria operator="OR">
          <criteria operator="OR">
            <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument"
            comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub via GRUB_CMDLINE_LINUX" />
            {{% if system_with_kernel_options_in_etc_default_grub_d -%}}
            <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_configdir"
            comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub.d/*cfg via GRUB_CMDLINE_LINUX" />
            {{%- endif %}}
          </criteria>
          <criteria operator="AND">
            <criteria operator="OR">
              <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default"
              comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub via GRUB_CMDLINE_LINUX_DEFAULT" />
              {{% if system_with_kernel_options_in_etc_default_grub_d -%}}
              <criterion test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default_configdir"
              comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub.d/*cfg via GRUB_CMDLINE_LINUX_DEFAULT" />
              {{%- endif %}}
            </criteria>
            <extend_definition definition_ref="bootloader_disable_recovery_set_to_true"
            comment="Check GRUB_DISABLE_RECOVERY=true in /etc/default/grub" />
          </criteria>
        </criteria>
      {{%- endif %}}
    </criteria>
    {{% if bootable_containers_supported == "true" %}}
      <criteria operator="AND">
        <extend_definition comment="The system is RHEL Image Mode" definition_ref="bootc" />
        <criterion comment="The {{{ ARG_NAME_VALUE }}} is present in the /usr/lib/bootc/kargs.d/*.toml files"  test_ref="test_grub2_{{{ SANITIZED_ARG_NAME }}}_usr_lib_bootc_kargs_d" />
      </criteria>
    {{% endif %}}
    </criteria>
  </definition>

{{% if system_with_expanded_kernel_options_in_loader_entries_or_with_options_in_grubenv %}}
  <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_entries_expanded_or_referenced"
  comment="check all /boot/loader/entries/*.conf for expanded entries of  {{{ ARG_NAME_VALUE }}}. Leave out rescue boot entries. Accept also references to $kernelopts."
  state_operator="OR" check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="obj_grub2_{{{ SANITIZED_ARG_NAME }}}_entries_expanded_or_referenced" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_is_kernelopts" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="obj_grub2_{{{ SANITIZED_ARG_NAME }}}_entries_expanded_or_referenced" version="1">
    <ind:path>/boot/loader/entries/</ind:path>
    <ind:filename operation="pattern match">^.*\.conf$</ind:filename>
    <ind:pattern operation="pattern match">^options (.*)$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
    <filter action="exclude">state_grub2_rescue_entry_for_{{{ _RULE_ID }}}</filter>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_state id="state_grub2_rescue_entry_for_{{{ _RULE_ID }}}" version="1">
    <ind:filename operation="pattern match">.*rescue\.conf$</ind:filename>
  </ind:textfilecontent54_state>

  <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_at_least_one_entry_referenced"
  comment="check all /boot/loader/entries/*.conf files if there is at least one entry referencing $kernelopts. Leave out rescue entries."
  check="all" check_existence="at_least_one_exists" version="1">
    <ind:object object_ref="obj_grub2_{{{ SANITIZED_ARG_NAME }}}_entries_expanded_or_referenced" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_is_kernelopts" />
  </ind:textfilecontent54_test>
{{% endif %}}


{{%- if system_with_kernel_options_in_etc_default_grub %}}
  <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument"
  comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub via GRUB_CMDLINE_LINUX"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" version="1">
    <ind:filepath>/etc/default/grub</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default"
  comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub via GRUB_CMDLINE_LINUX_DEFAULT"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default"
  version="1">
    <ind:filepath>/etc/default/grub</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX_DEFAULT="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
{{%- endif %}}

{{% if system_with_kernel_options_in_etc_default_grub_d -%}}
  <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_configdir"
  comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub.d/*cfg via GRUB_CMDLINE_LINUX"
  check="at least one" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_configdir" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default_configdir"
  comment="check for {{{ ARG_NAME_VALUE }}} in /etc/default/grub via GRUB_CMDLINE_LINUX_DEFAULT"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default_configdir" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_configdir" version="1">
    <ind:filepath operation="pattern match">/etc/default/grub.d/[^/]+\.cfg</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_object id="object_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_default_configdir"
  version="1">
    <ind:filepath>/etc/default/grub.d/*.cfg</ind:filepath>
    <ind:pattern operation="pattern match">^\s*GRUB_CMDLINE_LINUX_DEFAULT="(.*)"$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
{{%- endif %}}

{{%- if system_with_kernel_options_in_grubenv or system_with_expanded_kernel_options_in_loader_entries_or_with_options_in_grubenv %}}
{{%- macro test_and_object_for_kernel_options_grub_env(base_name, path) %}}
  <ind:textfilecontent54_test id="test_{{{ base_name }}}"
  comment="check for kernel command line parameters {{{ ARG_NAME_VALUE }}} in {{{ path }}} for all kernels"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_{{{ base_name }}}" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_{{{ base_name }}}"
  version="1">
    <ind:filepath>{{{ path }}}</ind:filepath>
    <ind:pattern operation="pattern match">^kernelopts=(.*)$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
{{%- endmacro %}}

{{{ test_and_object_for_kernel_options_grub_env("grub2_" ~ SANITIZED_ARG_NAME ~ "_argument_grub_env", grub2_boot_path ~ "/grubenv") }}}
{{% if system_with_bios_and_uefi_support -%}}
{{{ test_and_object_for_kernel_options_grub_env("grub2_" ~ SANITIZED_ARG_NAME ~ "_argument_grub_env_uefi", grub2_uefi_boot_path ~ "/grubenv") }}}
{{%- endif %}}
{{%- endif %}}

{{%- if system_with_expanded_kernel_options_in_loader_entries %}}
    <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_entries"
                                comment="check kernel command line parameters for {{{ ARG_NAME_VALUE }}} for all boot entries."
                                check="all" check_existence="all_exist" version="1">
      <ind:object object_ref="obj_grub2_{{{ SANITIZED_ARG_NAME }}}_entries" />
      <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
    </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="obj_grub2_{{{ SANITIZED_ARG_NAME }}}_entries" version="1">
    <ind:path>/boot/loader/entries/</ind:path>
    <ind:filename operation="pattern match">^.*\.conf$</ind:filename>
    <ind:pattern operation="pattern match">^options (.*)$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
    <filter action="exclude">state_grub2_rescue_entry_for_{{{ _RULE_ID }}}</filter>
  </ind:textfilecontent54_object>

  <ind:textfilecontent54_state id="state_grub2_rescue_entry_for_{{{ _RULE_ID }}}" version="1">
    <ind:filename operation="pattern match">.*rescue\.conf$</ind:filename>
  </ind:textfilecontent54_state>
{{%- endif %}}

{{%- if system_with_expanded_kernel_options_in_grub_cfg %}}
{{%- macro test_and_object_for_kernel_options_grub_cfg(base_name, path) %}}
  <ind:textfilecontent54_test id="test_{{{ base_name }}}"
  comment="check kernel command line parameters for {{{ ARG_NAME_VALUE }}} in {{{ path }}} for all kernels"
  check="all" check_existence="all_exist" version="1">
    <ind:object object_ref="object_{{{ base_name }}}" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument" />
  </ind:textfilecontent54_test>

  <ind:textfilecontent54_object id="object_{{{ base_name }}}"
  version="1">
    <ind:filepath>{{{ path }}}</ind:filepath>
    {{% if product in ["ol7"] or 'ubuntu' in product %}}
      <ind:pattern operation="pattern match">^.*/vmlinuz.*(root=.*)$</ind:pattern>
    {{% else %}}
      <ind:pattern operation="pattern match">^set default_kernelopts=(.*)$</ind:pattern>
    {{% endif %}}
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
{{%- endmacro %}}

{{{ test_and_object_for_kernel_options_grub_cfg("grub2_" + SANITIZED_ARG_NAME + "_argument_grub_cfg", grub2_boot_path ~ "/grub.cfg") }}}
{{% if system_with_bios_and_uefi_support -%}}
{{{ test_and_object_for_kernel_options_grub_cfg("grub2_" + SANITIZED_ARG_NAME + "_argument_grub_cfg_uefi", grub2_uefi_boot_path ~ "/grub.cfg") }}}
{{%- endif %}}
{{%- endif %}}

{{% if system_with_expanded_kernel_options_in_loader_entries_or_with_options_in_grubenv %}}
  <ind:textfilecontent54_state id="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument_is_kernelopts"
  version="1">
    <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?\$kernelopts(?:\s.*)?$</ind:subexpression>
  </ind:textfilecontent54_state>
{{% endif %}}

{{% if ARG_VALUE %}}
  <ind:textfilecontent54_state id="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument"
  version="1">
    <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?{{{ ESCAPED_ARG_NAME_VALUE }}}(?:\s.*)?$</ind:subexpression>
  </ind:textfilecontent54_state>
{{% else %}}
  <ind:textfilecontent54_state id="state_grub2_{{{ SANITIZED_ARG_NAME }}}_argument"
  version="1">
    <ind:subexpression datatype="string" operation="pattern match" var_ref="local_var_regex_{{{ SANITIZED_ARG_NAME }}}_{{{ ARG_VARIABLE }}}" />
  </ind:textfilecontent54_state>

  <local_variable id="local_var_regex_{{{ SANITIZED_ARG_NAME }}}_{{{ ARG_VARIABLE }}}"
  comment="Regex that matches {{{ ARG_NAME }}} with value {{{ ARG_VARIABLE }}}"
  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>

  <external_variable comment="Variable defining the value the argument should have" datatype="string" id="{{{ ARG_VARIABLE }}}" version="1" />
{{% endif %}}

{{% if bootable_containers_supported == "true" %}}
  <ind:textfilecontent54_test id="test_grub2_{{{ SANITIZED_ARG_NAME }}}_usr_lib_bootc_kargs_d"
                              comment="check kernel command line parameters for {{{ ARG_NAME_VALUE }}} for all boot entries."
                              check="at least one" check_existence="at_least_one_exists" version="1">
    <ind:object object_ref="object_grub2_{{{ SANITIZED_ARG_NAME }}}_usr_lib_bootc_kargs_d" />
    <ind:state state_ref="state_grub2_{{{ SANITIZED_ARG_NAME }}}_usr_lib_bootc_kargs_d" />
  </ind:textfilecontent54_test>
  <ind:textfilecontent54_object id="object_grub2_{{{ SANITIZED_ARG_NAME }}}_usr_lib_bootc_kargs_d" version="1">
    <ind:path>/usr/lib/bootc/kargs.d/</ind:path>
    <ind:filename operation="pattern match">^.*\.toml$</ind:filename>
    <ind:pattern operation="pattern match">^kargs = \[([^\]]+)\]$</ind:pattern>
    <ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
  </ind:textfilecontent54_object>
{{% if ARG_VALUE %}}
  <ind:textfilecontent54_state id="state_grub2_{{{ SANITIZED_ARG_NAME }}}_usr_lib_bootc_kargs_d" version="1">
    <ind:subexpression operation="pattern match">^.*"{{{ ESCAPED_ARG_NAME_VALUE }}}".*$</ind:subexpression>
  </ind:textfilecontent54_state>
{{% else %}}
  <ind:textfilecontent54_state id="state_grub2_{{{ SANITIZED_ARG_NAME }}}_usr_lib_bootc_kargs_d" version="1">
    <ind:subexpression operation="pattern match" var_ref="local_var_regex_{{{ SANITIZED_ARG_NAME }}}_{{{ ARG_VARIABLE }}}_bootc_kargs" />
  </ind:textfilecontent54_state>

  <local_variable id="local_var_regex_{{{ SANITIZED_ARG_NAME }}}_{{{ ARG_VARIABLE }}}_bootc_kargs"
  comment="Regex that matches {{{ ARG_NAME }}} with value {{{ ARG_VARIABLE }}}"
  datatype="string" version="1">
    <concat>
      <literal_component>^.*"{{{ 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>".*$</literal_component>
    </concat>
  </local_variable>

  <external_variable comment="Variable defining the value the argument should have" datatype="string" id="{{{ ARG_VARIABLE }}}" version="1" />
{{% endif %}}
{{% endif %}}

</def-group>