Skip to content

Add case for checking default secure db#705

Merged
linl-rh merged 2 commits intovirt-s1:masterfrom
linl-rh:master
Apr 2, 2026
Merged

Add case for checking default secure db#705
linl-rh merged 2 commits intovirt-s1:masterfrom
linl-rh:master

Conversation

@linl-rh
Copy link
Copy Markdown
Collaborator

@linl-rh linl-rh commented Apr 2, 2026

Summary by Sourcery

Add a new general check to validate Secure Boot configuration and certificates, and fix minor formatting in an existing product key test.

Tests:

  • Add a test that verifies Secure Boot is enabled and validates shim package, DB certs, PK, and KEK values.
  • Tidy whitespace in the product key release-setting test command.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 2, 2026

Reviewer's Guide

Add a new secure boot validation test that runs mokutil- and rpm-based checks when Secure Boot is enabled, alongside a minor whitespace fix in an existing test.

File-Level Changes

Change Details Files
Add an automated test that validates Secure Boot status and default UEFI secure boot databases using mokutil and shim package checks.
  • Introduce test_check_secureboot with full case metadata (tags, maintainer, description, steps, expectations).
  • Run mokutil --sb-state and skip the test early when Secure Boot is not enabled.
  • Verify shim is installed via rpm query when Secure Boot is enabled.
  • Check default secure boot DB, PK, and KEK entries via mokutil invocations with concise output filters.
os_tests/tests/test_general_check.py
Normalize formatting in an existing product key test.
  • Remove trailing whitespace in subscription-manager release command in test_check_product_key docstring.
os_tests/tests/test_general_check.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new test case, test_check_secureboot, to verify Secure Boot status and its associated certificates (DB, PK, KEK) along with the shim package. A review comment identifies an issue where a shell pipeline in the PK check could mask command failures, suggesting a more robust approach using expect_kw to verify output content directly.


utils_lib.run_cmd(self, "sudo rpm -qa | grep shim", expect_ret=0, msg="Check installed shim package")
utils_lib.run_cmd(self, "sudo mokutil --db --short", expect_ret=0, msg="Check default certs in DB")
utils_lib.run_cmd(self, "sudo mokutil --pk | grep -E '(Subject:|Not After)' | head -2", expect_ret=0, msg="Check default PK value")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The shell pipeline sudo mokutil --pk | grep -E '(Subject:|Not After)' | head -2 masks potential failures from the mokutil command. In a standard shell execution, the exit status of a pipeline is the exit status of the last command (head -2), which will almost always return 0 even if mokutil fails or grep finds no matches. Consequently, expect_ret=0 does not effectively verify that the PK value was successfully retrieved. It is more robust to run the command directly and use expect_kw to verify that the expected fields are present in the output.

Suggested change
utils_lib.run_cmd(self, "sudo mokutil --pk | grep -E '(Subject:|Not After)' | head -2", expect_ret=0, msg="Check default PK value")
utils_lib.run_cmd(self, "sudo mokutil --pk", expect_ret=0, expect_kw="Subject,Not After", msg="Check default PK value")

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In test_check_secureboot, consider adding expect_ret=0 to the initial mokutil --sb-state call (and handling failure) so the test clearly fails or skips when mokutil is missing or the command errors instead of silently proceeding with an unexpected output string.
  • The check for the shim package using rpm -qa | grep shim could be made more robust by querying the specific package name via rpm -q shim* or similar, avoiding potential false positives from unrelated packages with 'shim' in their name.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `test_check_secureboot`, consider adding `expect_ret=0` to the initial `mokutil --sb-state` call (and handling failure) so the test clearly fails or skips when `mokutil` is missing or the command errors instead of silently proceeding with an unexpected output string.
- The check for the shim package using `rpm -qa | grep shim` could be made more robust by querying the specific package name via `rpm -q shim*` or similar, avoiding potential false positives from unrelated packages with 'shim' in their name.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@linl-rh linl-rh merged commit 47a72de into virt-s1:master Apr 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant