Skip to content

Add arg_minimal_value variable to grub2_bootloader_argument template#14626

Draft
macko1 wants to merge 3 commits intoComplianceAsCode:masterfrom
macko1:fix_13923
Draft

Add arg_minimal_value variable to grub2_bootloader_argument template#14626
macko1 wants to merge 3 commits intoComplianceAsCode:masterfrom
macko1:fix_13923

Conversation

@macko1
Copy link
Copy Markdown
Collaborator

@macko1 macko1 commented Apr 7, 2026

Description:

  • Add an operation parameter to the grub2_bootloader_argument
    template so rules can use numeric comparisons (currently only
    "greater than or equal" is supported)
  • Update grub2_audit_backlog_limit_argument rule to use the
    new operation parameter.
  • Update test scenarios to be more modular by passing custom testing values with template.py instead of embedding the hardcoded values in the test itself.
  • Added tests for "greater than or equal" scenarios.
  • Document the new parameter in template_reference.md.

Rationale:

Review Hints:

  • Review commits in order: template.py first (preprocessing), then
    oval.template + tests (the OVAL plumbing), then rule.yml + docs.
  • Build and test with:
./build_product rhel9 --datastream-only
  • Test with automatus.py - this needs to be run in a VM, not a container.
    Using multiple parallel VMs is recommended (--slice automatus argument).
./automatus.py rule --libvirt qemu:///session <vm> --datastream ../build/ssg-rhel9-ds.xml grub2_audit_backlog_limit_argument
  • The oval.template has extensive inline comments explaining the
    numeric branching — the header TOC (lines 1–72) is a good
    starting point.
  • The RHEL8 entries_numeric test+object (section 4a) is the
    trickiest part — it exists because the wide-capture object must
    stay for $kernelopts detection.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Apr 7, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 7, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
OVAL for rule 'xccdf_org.ssgproject.content_rule_grub2_audit_backlog_limit_argument' differs.
--- oval:ssg-grub2_audit_backlog_limit_argument:def:1
+++ oval:ssg-grub2_audit_backlog_limit_argument:def:1
@@ -1,6 +1,6 @@
 criteria OR
 criteria AND
-criterion oval:ssg-test_grub2_audit_backlog_limit_entries_expanded_or_referenced:tst:1
+criterion oval:ssg-test_grub2_audit_backlog_limit_entries_numeric:tst:1
 criteria OR
 criterion oval:ssg-test_grub2_audit_backlog_limit_at_least_one_entry_referenced:tst:1
 criteria OR

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Change in Ansible shell module found.

Please consider using more suitable Ansible module than shell if possible.

@macko1 macko1 force-pushed the fix_13923 branch 2 times, most recently from 5d68582 to 117ce41 Compare April 8, 2026 12:30
@macko1 macko1 changed the title DRAFT: take2 DRAFT: #13923 Apr 8, 2026
@macko1 macko1 force-pushed the fix_13923 branch 2 times, most recently from d72131a to 315103b Compare April 8, 2026 22:04
@vojtapolasek vojtapolasek self-assigned this Apr 9, 2026
@macko1 macko1 changed the title DRAFT: #13923 Add arg_minimal_value variable to grub2_bootloader_argument template Apr 9, 2026
@vojtapolasek
Copy link
Copy Markdown
Collaborator

Hello @macko1 and thank you.
I have two remarks. First is technical, could you please split the PR into multiple commits? For example, one for documentation, one modifying tests... it makes reviewing easier.
Then I have a remark regarding the main purpose of the PR. As I understand it, your PR makes it possible to define the Grub2 value in three ways:

  • arg_value - checks equality of the value against hardcoded value
  • arg_variable - checks equality with a value represented by an XCCDF variable
  • newly defined arg_minimal_value - checks if the value is greater or equal to a hardcoded value
    If I understand it correctly, then I think this is not an optimal implementation.
    Because what if in the future you would like to check if a value is greater or equal to something defined with XCCDF variable? It would require another round of reimplementation.
    I think it would be better to add a different parameter, which would signify the operation between the checked value and the hardcoded / variable provided value. In this way, we could check for equality, greater than, lesser than... whatever is supported.
    I had only a quick glance into templates, but it seems we already support this for example in the accounts_password template or pam_options template. Do you think this concept could be used in this case as well?

@macko1 macko1 force-pushed the fix_13923 branch 3 times, most recently from 5359579 to 13a4ebc Compare April 16, 2026 14:40
macko1 added 3 commits April 17, 2026 00:19
…mparison

- audit_backlog_limit needs >= comparison
- Test scenarios now use TEST_CORRECT_VALUE/TEST_WRONG_VALUE
  instead of hardcoded strings.
…parison

- See inline documentation in the oval.template for more details.
- Test scenarios now use TEST_CORRECT_VALUE/TEST_WRONG_VALUE
  instead of hardcoded strings.
- Two new numeric test scenarios added:
  arg_value_meets_minimal.pass.sh and arg_value_below_minimal.fail.sh.
- Add operation "greater than or equal" to the rule so the OVAL
check accepts any value meeting the threshold, not just the
exact default.
- Document the operation parameter in template_reference.md.
@macko1
Copy link
Copy Markdown
Collaborator Author

macko1 commented Apr 16, 2026

@vojtapolasek you were right, thanks for pointing this out. I've re-implemented the check, and made it extensible - "greater than or equal" can be extended with more OVAL operations in the future, when needed.

I have divided the changes into several commits, as you have asked, I hope this will make it more readable.

PR description updated.

Thanks for a review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xccdf_org.ssgproject.content_rule_audit_backlog_limit resets backlog limit even if set to valid value

2 participants