|
| 1 | +#!/bin/bash |
| 2 | +{{#- |
| 3 | + Test: arg_value_below_minimal — expected result: FAIL |
| 4 | + |
| 5 | + Scenario: |
| 6 | + The kernel argument (e.g. audit_backlog_limit) is set to a value that is |
| 7 | + BELOW the required minimum. The OVAL check uses "greater than or equal", |
| 8 | + so below-minimum is a failing case. |
| 9 | + |
| 10 | + What happens: |
| 11 | + 1. The XCCDF variable (e.g. var_audit_backlog_limit) is set to 8192. |
| 12 | + 2. The remediation macro writes ARG_NAME=100 into all GRUB locations |
| 13 | + (grubby, /etc/default/grub, grub.cfg — depending on the product). |
| 14 | + 3. The OVAL object captures "100" (the digits after ARG_NAME=). |
| 15 | + 4. The OVAL state compares: 100 >= 8192 → false → FAIL. |
| 16 | + |
| 17 | + Applicability: |
| 18 | + Only runs for rules that use arg_minimal_value (e.g. audit_backlog_limit). |
| 19 | + Rules using arg_value or arg_variable skip this test (platform = Not Applicable). |
| 20 | +-#}} |
| 21 | + |
| 22 | +{{#- This test only makes sense for rules using arg_minimal_value. |
| 23 | + If the rule does NOT use arg_minimal_value (i.e. it uses arg_value or |
| 24 | + arg_variable instead), emit "platform = Not Applicable" so Automatus |
| 25 | + skips it. Otherwise, run on all platforms. |
| 26 | + ("# platform = ..." is an Automatus directive parsed from the rendered |
| 27 | + script — bash sees it as a comment, but Automatus uses it to decide |
| 28 | + whether to run the test.) -#}} |
| 29 | +{{% if not ARG_MINIMAL_VALUE %}} |
| 30 | +# platform = Not Applicable |
| 31 | +{{% else %}} |
| 32 | +# platform = multi_platform_all |
| 33 | +{{% endif %}} |
| 34 | + |
| 35 | +{{#- Ubuntu only needs the grub2 package. |
| 36 | + All other products also need grubby (used by the remediation macro to |
| 37 | + write kernel arguments into /boot/loader/entries/*.conf). |
| 38 | + ("# packages = ..." is an Automatus directive — it installs these |
| 39 | + packages on the test VM before running the script.) -#}} |
| 40 | +{{%- if 'ubuntu' in product %}} |
| 41 | +# packages = grub2 |
| 42 | +{{%- else %}} |
| 43 | +# packages = grub2,grubby |
| 44 | +{{%- endif %}} |
| 45 | + |
| 46 | +{{#- When arg_minimal_value is set, tell Automatus which XCCDF variable to |
| 47 | + use and what value to assign it. "# variables = ..." is an Automatus |
| 48 | + directive that sets the variable before the OVAL scan runs. |
| 49 | + Here we set the minimum to 8192. -#}} |
| 50 | +{{%- if ARG_MINIMAL_VALUE %}} |
| 51 | +# variables = {{{ ARG_MINIMAL_VALUE }}}=8192 |
| 52 | +{{%- endif %}} |
| 53 | + |
| 54 | +{{#- common.sh sets up the GRUB environment for the test (creates necessary |
| 55 | + files, cleans previous state, etc.). -#}} |
| 56 | +source common.sh |
| 57 | + |
| 58 | +{{#- Write ARG_NAME=100 into all GRUB config locations. |
| 59 | + Value is below the minimum (100 < 8192) → the check should FAIL. -#}} |
| 60 | +{{{ grub2_bootloader_argument_remediation(ARG_NAME, ARG_NAME ~ "=100") }}} |
0 commit comments