feat(machine-validation): require SHA256 digest on container images#4058
feat(machine-validation): require SHA256 digest on container images#4058ianderson-nvidia wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
Summary by CodeRabbit
WalkthroughMachine 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. ChangesImage Digest Validation
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
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
crates/admin-cli/Cargo.tomlcrates/admin-cli/src/machine_validation/tests.rscrates/admin-cli/src/machine_validation/tests_cmd/args.rscrates/api-core/src/handlers/machine_validation.rs
8b7a68c to
0316414
Compare
|
@coderabbitai can you full_review again? I think Ian took care of it all. Thanks! |
|
🐇🔍 ✅ Action performedFull review finished. |
0316414 to
d816a76
Compare
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
crates/admin-cli/Cargo.tomlcrates/admin-cli/src/machine_validation/tests.rscrates/admin-cli/src/machine_validation/tests_cmd/args.rscrates/api-core/src/handlers/machine_validation.rscrates/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
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.
d816a76 to
3e2d3c4
Compare
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:
Related issues
#2962
#3655
Type of Change
Testing
Additional Notes