Use ValidateVSAAndComparePolicy for ec validate image VSA skip - #3489
Use ValidateVSAAndComparePolicy for ec validate image VSA skip#3489st3penta wants to merge 1 commit into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe ChangesVSA validation flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant ValidateImageWithVSACheck
participant UploadBackedRetriever
participant ValidateVSAAndComparePolicy
participant ImageValidation
CLI->>ValidateImageWithVSACheck: pass VSAValidationConfig
ValidateImageWithVSACheck->>UploadBackedRetriever: retrieve VSA envelope
UploadBackedRetriever-->>ValidateImageWithVSACheck: return envelope or retrieval error
ValidateImageWithVSACheck->>ValidateVSAAndComparePolicy: validate VSA
ValidateVSAAndComparePolicy-->>ValidateImageWithVSACheck: return validation result
ValidateImageWithVSACheck->>ImageValidation: continue when VSA validation fails or is unavailable
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🤖 Review · Commit: |
PR Summary by QodoHarden
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@internal/image/validate_test.go`:
- Around line 451-457: Update createPassingVSAEnvelope to define a PolicySpec
with the expected source and policy, assign it to the returned validation data,
and build the predicate.policy from that same specification so the passing test
exercises policy comparison.
🪄 Autofix
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: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: e34f50d2-f28d-4e42-9640-91153a2911eb
📒 Files selected for processing (4)
cmd/validate/image.gocmd/validate/image_test.gointernal/image/validate.gointernal/image/validate_test.go
|
🤖 Finished Review · ✅ Success · Started 9:10 AM UTC · Completed 9:27 AM UTC Commit: |
ReviewFindingsHigh
Medium
Low
Next steps:
Previous runReviewFindingsHigh
Medium
Low
Labels: PR is a security fix with a breaking CLI change affecting VSA validation. 'bug' reflects the security vulnerability fix (EC-1842). 'major' reflects the documented breaking change to --vsa-upload requiring --vsa-public-key. Next steps:
Previous run (2)ReviewFindingsHigh
Medium
Low
Labels: PR introduces breaking CLI change and has multiple documentation gaps for a security-relevant feature Next steps:
Previous run (3)ReviewFindingsLow
Previous run (4)ReviewFindingsHigh
Medium
Low
Next steps:
Previous run (5)ReviewFindingsHigh
Medium
Low
Next steps:
Previous run (6)ReviewFindingsMedium
Low
Previous run (7)ReviewFindingsMedium
Low
Previous run (8)ReviewFindingsMedium
Low
Labels: PR modifies CLI flag validation for VSA security hardening and addresses a red team finding about VSA bypass |
|
🤖 Finished Review · ✅ Success · Started 9:29 AM UTC · Completed 9:49 AM UTC Commit: |
|
🤖 Review · Commit: |
|
🤖 Finished Review · ✅ Success · Started 10:26 AM UTC · Completed 10:47 AM UTC Commit: |
|
🤖 Review · ❌ Terminated · Started 10:50 AM UTC · Ended 11:11 AM UTC Commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@internal/image/validate_test.go`:
- Around line 529-532: Strengthen fallback validation assertions in
internal/image/validate_test.go at lines 529-532 and 571-573: when expectSkip is
false, assert that the output from ValidateImageWithVSACheck is non-nil,
retaining the returned out value at lines 571-573 before asserting it. Keep the
existing error assertions and skip behavior unchanged.
🪄 Autofix
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: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: a88a7a2b-e0e6-4c73-b138-4cd4a468e64b
📒 Files selected for processing (1)
internal/image/validate_test.go
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
🤖 Finished Review · ✅ Success · Started 10:50 AM UTC · Completed 11:11 AM UTC Commit: |
|
🤖 Finished Review · ✅ Success · Started 1:00 PM UTC · Completed 1:17 PM UTC Commit: |
|
🤖 Finished Review · ✅ Success · Started 2:27 PM UTC · Completed 2:43 PM UTC Commit: |
Superseded by updated review
| cmd.Flags().BoolVar(&data.vsaEnabled, "vsa", false, "Generate a Verification Summary Attestation (VSA) for each validated image.") | ||
| cmd.Flags().StringVar(&data.attestationFormat, "attestation-format", "dsse", "Attestation output format: dsse (signed envelope), predicate (raw JSON)") | ||
| cmd.Flags().StringVar(&data.vsaSigningKey, "vsa-signing-key", "", "Path to the private key for signing the VSA. Supports file paths and Kubernetes secret references (k8s://namespace/secret-name/key-field).") | ||
| cmd.Flags().StringVar(&data.vsaPublicKey, "vsa-public-key", "", "Path to the public key for VSA signature verification. Required when --vsa-upload is set.") |
There was a problem hiding this comment.
In reviewing this and working with Claude, the following was alluded to which should be traced:
The --vsa-public-key help text (and the generated ec_validate_image.adoc) says "Required when --vsa-upload is set," but the actual guard requires it only when --vsa-upload is set and --vsa-expiration > 0 (see L299-L301) — matching the error message. We should align the help text with the guard so --vsa-expiration=0 (upload-only) users aren't told they need a key they don't.
Minor: the guard keys off len(vsaUpload) > 0 as a proxy for "skip path active," but the skip path only runs when CreateRetrieverFromUploadFlags returns non-nil. These diverge for the local@ backend — a user gets forced to supply a key that's then never used. Gating the guard on the retriever being constructable would make the requirement exact, though the current form is a safe over-approximation.
There was a problem hiding this comment.
Updated the help text.
About the guard: I'm leaving it as is. The only backend where the two diverge is local@, which is dev/test only with no real deployment use.
I also squashed all the commits into one, but the only diff from this comment is the help text
|
🤖 Review · Commit: |
|
🤖 Finished Review · ✅ Success · Started 11:08 AM UTC · Completed 11:26 AM UTC Commit: |
|
🤖 Finished Review · ✅ Success · Started 3:29 PM UTC · Completed 4:08 PM UTC Commit: |
|
/fs-fix rebase on top of main |
|
🤖 Review · Commit: |
IsValidVSA only checked Found && !Expired, so forged VSAs could skip the entire validation pipeline (EC-1842). ValidateVSAAndComparePolicy already handles this for ec validate vsa: it verifies signatures, checks predicate status, and compares policy. Wire it into the image path too. Add --vsa-public-key to ec validate image. Change ValidateImageWithVSACheck to take *vsa.VSAValidationConfig instead of *vsa.VSAChecker + time.Duration. The key is required when --vsa-upload is set and --vsa-expiration > 0, i.e. only when the skip path is active. Upload-only callers (--vsa-expiration=0, as the Konflux task now sets) are unaffected. Flag help and the generated adoc match this guard. Includes an acceptance test covering the missing --vsa-public-key error. Ref: https://issues.redhat.com/browse/EC-1998 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 12:53 PM UTC · Completed 1:12 PM UTC Commit: |
IsValidVSA only checked
Found && !Expired, so forged VSAs could skipthe entire validation pipeline (EC-1842).
ValidateVSAAndComparePolicyalready handles this for
ec validate vsa: it verifies signatures,checks predicate status, and compares policy. Wire it into the image
path too.
Add
--vsa-public-keytoec validate image, required when--vsa-uploadis set. Change
ValidateImageWithVSACheckto take*vsa.VSAValidationConfiginstead of
*vsa.VSAChecker+time.Duration.Breaking change:
--vsa-uploadusers need to also pass--vsa-public-key.Default Konflux pipelines are unaffected.
Ref: https://issues.redhat.com/browse/EC-1998
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com