Skip to content

feat(machine-validation): require SHA256 digest on container images#4058

Open
ianderson-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
ianderson-nvidia:machine_validation_images_sha256
Open

feat(machine-validation): require SHA256 digest on container images#4058
ianderson-nvidia wants to merge 1 commit into
NVIDIA:mainfrom
ianderson-nvidia:machine_validation_images_sha256

Conversation

@ianderson-nvidia

Copy link
Copy Markdown
Contributor

Reject any img_name that lacks a pinned @sha256: component. Any tag value (including :latest) is accepted as long as a valid digest is present. Validation runs at two layers:

  • Handler (add/update): validate_img_name verifies the digest is exactly 32 bytes and that the reference has exactly one '@' segment.
  • Admin CLI: mirrors the same rules via a clap value_parser on the img_name field.

Related issues

#2962
#3655

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

@ianderson-nvidia
ianderson-nvidia requested a review from a team as a code owner July 23, 2026 23:29
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 80023038-e2e0-41a2-b963-aaf44bd1f279

📥 Commits

Reviewing files that changed from the base of the PR and between d816a76 and 3e2d3c4.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • crates/admin-cli/Cargo.toml
  • crates/admin-cli/src/machine_validation/tests.rs
  • crates/admin-cli/src/machine_validation/tests_cmd/args.rs
  • crates/api-core/src/handlers/machine_validation.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/admin-cli/src/machine_validation/tests_cmd/args.rs
  • crates/admin-cli/src/machine_validation/tests.rs
  • crates/api-core/src/handlers/machine_validation.rs

Summary by CodeRabbit

  • Bug Fixes

    • Machine validation test image references now require a valid SHA-256 digest.
    • Added clear validation for missing names, invalid formats, malformed hexadecimal digests, and incorrect digest lengths.
    • Consistent validation is applied when creating or updating machine validation tests.
  • Tests

    • Added coverage for valid pinned image references, optional image names, and rejected formats.

Walkthrough

Machine validation image names are now restricted to 32-byte hexadecimal SHA256-pinned references. The admin CLI validates add and update arguments, while API handlers validate provided values before persistence. Parsing and handler tests cover valid and invalid references.

Changes

Image Digest Validation

Layer / File(s) Summary
CLI image validation
crates/admin-cli/Cargo.toml, crates/admin-cli/src/machine_validation/tests_cmd/args.rs, crates/admin-cli/src/machine_validation/tests.rs
Adds the hex dependency, validates --img-name values using the @sha256:<digest> format, applies validation to add and update commands, and tests accepted, omitted, and rejected inputs.
API image validation
crates/api-core/src/handlers/machine_validation.rs
Validates image names during machine validation test creation and updates, converts failures to gRPC errors, and tests valid and invalid digest references.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AdminCLI
  participant ClapParser
  participant MachineValidationHandlers
  participant Database
  AdminCLI->>ClapParser: Parse --img-name
  ClapParser->>ClapParser: Validate `@sha256` digest
  ClapParser-->>AdminCLI: Return parsed image reference or error
  AdminCLI->>MachineValidationHandlers: Submit add or update request
  MachineValidationHandlers->>MachineValidationHandlers: Validate provided image name
  MachineValidationHandlers->>Database: Persist validated test
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: enforcing SHA256 digests on machine-validation container images.
Description check ✅ Passed The description accurately covers the handler and CLI validation changes reflected in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/admin-cli/src/machine_validation/tests_cmd/args.rs`:
- Around line 119-120: The pinned image syntax lacks worked help examples.
Attach command-level after_long_help with an EXAMPLES section to
UpdateTestOptions at
crates/admin-cli/src/machine_validation/tests_cmd/args.rs:119-120, including a
copy-pasteable pinned-image update command; add equivalent help to
AddTestOptions at
crates/admin-cli/src/machine_validation/tests_cmd/args.rs:180-181 with a minimal
pinned-image add command.
- Around line 25-28: The image-reference validators must reject an empty
image-name component before accepting the digest. In
crates/admin-cli/src/machine_validation/tests_cmd/args.rs:25-28, retain the
name_part from parse_img_name and validate it is non-empty; apply the same check
in crates/api-core/src/handlers/machine_validation.rs:812-817. Add boundary
tests at both sites covering valid named references and rejection of the
empty-name form.

In `@crates/admin-cli/src/machine_validation/tests.rs`:
- Around line 244-245: Correct the comment describing img_name validation in the
tests add/update parsing flow to state that :latest is accepted when accompanied
by a valid pinned sha256 digest, rather than rejected.

In `@crates/api-core/src/handlers/machine_validation.rs`:
- Around line 1302-1351: Consolidate the nine validator tests around
validate_img_name into one table-driven test using the project’s
scenarios!/Outcome or check_cases pattern. Represent each accepted and rejected
image reference as a table entry, preserving the existing digest, algorithm,
hex-length, and multiple-at-sign coverage and expected Result outcomes. Remove
the separate accepts_* and rejects_* test functions after consolidating their
cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 82ec310b-00d8-42fc-8d87-f2d113220a0b

📥 Commits

Reviewing files that changed from the base of the PR and between 80d0b8b and 8b7a68c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • crates/admin-cli/Cargo.toml
  • crates/admin-cli/src/machine_validation/tests.rs
  • crates/admin-cli/src/machine_validation/tests_cmd/args.rs
  • crates/api-core/src/handlers/machine_validation.rs

Comment thread crates/admin-cli/src/machine_validation/tests_cmd/args.rs
Comment thread crates/admin-cli/src/machine_validation/tests_cmd/args.rs
Comment thread crates/admin-cli/src/machine_validation/tests.rs Outdated
Comment thread crates/api-core/src/handlers/machine_validation.rs Outdated
@ianderson-nvidia
ianderson-nvidia force-pushed the machine_validation_images_sha256 branch from 8b7a68c to 0316414 Compare July 23, 2026 23:51
@chet

chet commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai can you full_review again? I think Ian took care of it all. Thanks!

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@chet: Understood — I’ll perform a fresh full review of #4058, including the updates Ian made.

🐇🔍

✅ Action performed

Full review finished.

@ianderson-nvidia
ianderson-nvidia force-pushed the machine_validation_images_sha256 branch from 0316414 to d816a76 Compare July 24, 2026 16:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/machine-validation/scripts/seed_go_health_validation.sql`:
- Line 33: Replace the :latest image reference in the seed SQL entries with an
immutable `@sha256` digest containing 64 hexadecimal characters, or require a
deployment-provided digest and fail when it is missing. Ensure all affected
image references comply with the required digest contract and use the configured
deployment image values.
- Around line 109-110: Update the seed entry’s supported_platforms value from
the empty placeholder in the SQL seed to the actual target host SKU strings
required for discovery. Do not leave the catalog entry insertable with an empty
array; if the target SKUs are unavailable, make the seed fail instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dc41f702-2c78-4076-879a-0d1e66445332

📥 Commits

Reviewing files that changed from the base of the PR and between 0316414 and d816a76.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • crates/admin-cli/Cargo.toml
  • crates/admin-cli/src/machine_validation/tests.rs
  • crates/admin-cli/src/machine_validation/tests_cmd/args.rs
  • crates/api-core/src/handlers/machine_validation.rs
  • crates/machine-validation/scripts/seed_go_health_validation.sql
🚧 Files skipped from review as they are similar to previous changes (4)
  • crates/admin-cli/Cargo.toml
  • crates/admin-cli/src/machine_validation/tests_cmd/args.rs
  • crates/admin-cli/src/machine_validation/tests.rs
  • crates/api-core/src/handlers/machine_validation.rs

Comment thread crates/machine-validation/scripts/seed_go_health_validation.sql Outdated
Comment thread crates/machine-validation/scripts/seed_go_health_validation.sql Outdated
Reject any img_name that lacks a pinned @sha256:<digest> component.
Any tag value (including :latest) is accepted as long as a valid digest
is present. Validation runs at two layers:

- Handler (add/update): validate_img_name verifies
  the digest is exactly 32 bytes and that the reference has exactly
  one '@' segment.
- Admin CLI: mirrors the same rules via a clap value_parser on the
  img_name field.
@ianderson-nvidia
ianderson-nvidia force-pushed the machine_validation_images_sha256 branch from d816a76 to 3e2d3c4 Compare July 24, 2026 16:57
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.

2 participants