Add --skip-att-sig-check flag#3267
Conversation
📝 WalkthroughWalkthroughThe PR adds support for independently skipping attestation signature verification during image validation via a new ChangesAttestation Signature Check Skip Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Making it a draft because it has no Jira (yet anyway). |
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
8d30082 to
a77249d
Compare
|
This isn't in the sprint currently, so maybe review it only after you reviewed everything else. |
Implement --skip-att-sig-check flag to skip attestation signature validation checks, mirroring the existing --skip-image-sig-check flag. When enabled, attestation signature verification is bypassed during image validation. Why? Often I'm debugging/troubleshooting something and I get given an image ref to look at. We can use cosign download attestation to inspect the attestation, which is very useful, but if we want to try running Conforma against it, we must either guess, find, or ask to be provided with the public key. Sometimes that's not so difficult, but other times it may be very difficult or even impossible. (Consider for example if the image was built on an ephemeral cluster and the signing secret used is gone forever.) Now we can use --skip-image-sig-check and --skip-att-sig-check and carry on with the debugging. Note that we added the --skip-image-sig-check recently for other reasons, see https://redhat.atlassian.net/browse/EC-1647. The --skip-att-sig-check is a little more complicated because we needed to add a new function that can download the attestation without verifying it. The argument against this is that it may encourage less secure practices, but I would say it's acceptable because we're not changing the default behavior, which is always to require signature verification. Ref: https://redhat.atlassian.net/browse/EC-1815 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
a77249d to
767ffe0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/evaluation_target/application_snapshot_image/application_snapshot_image.go (1)
280-314: ⚡ Quick winDeduplicate attestation parsing to avoid behavior drift
Line 280 through Line 314 duplicates the non-bundle parsing path from
ValidateAttestationSignature. A future change in one path can silently desync the other and produce inconsistent attestation handling.🤖 Prompt for 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. In `@internal/evaluation_target/application_snapshot_image/application_snapshot_image.go` around lines 280 - 314, This block duplicates the non-bundle attestation parsing logic found in ValidateAttestationSignature; extract the parsing/appending logic into a single helper (or call the existing ValidateAttestationSignature parsing routine) so both paths use the same code path: for each signature from layers.Get() call the shared function that runs ProvenanceFromSignature, switches on PredicateType and converts to SLSA v0.2/v1 or generic attestation via SLSAProvenanceFromSignature, SLSAProvenanceFromSignatureV1 and appends the result to a.attestations; remove the duplicated switch in the current loop and replace it with a call to that helper to avoid divergence.
🤖 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.go`:
- Around line 87-90: The attestation fetch error is being suppressed in the
validation path; change the behavior in the block that calls
a.FetchAttestationsWithoutVerification(ctx) so that instead of only logging and
continuing (the log.Debugf("Failed to fetch attestations without verification:
%v", err) path) you return or propagate a wrapped error to abort this
component's validation; locate the call to
a.FetchAttestationsWithoutVerification and replace the silent-continue with an
immediate return of the error (or fmt.Errorf/Wrap with context) so callers see
the registry fetch failure.
---
Nitpick comments:
In
`@internal/evaluation_target/application_snapshot_image/application_snapshot_image.go`:
- Around line 280-314: This block duplicates the non-bundle attestation parsing
logic found in ValidateAttestationSignature; extract the parsing/appending logic
into a single helper (or call the existing ValidateAttestationSignature parsing
routine) so both paths use the same code path: for each signature from
layers.Get() call the shared function that runs ProvenanceFromSignature,
switches on PredicateType and converts to SLSA v0.2/v1 or generic attestation
via SLSAProvenanceFromSignature, SLSAProvenanceFromSignatureV1 and appends the
result to a.attestations; remove the duplicated switch in the current loop and
replace it with a call to that helper to avoid divergence.
🪄 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: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 1da8673f-6dfe-44f1-a84d-a6396b58f8cb
📒 Files selected for processing (5)
cmd/validate/image.godocs/modules/ROOT/pages/ec_validate_image.adocinternal/evaluation_target/application_snapshot_image/application_snapshot_image.gointernal/image/validate.gointernal/policy/policy.go
| if err := a.FetchAttestationsWithoutVerification(ctx); err != nil { | ||
| log.Debugf("Failed to fetch attestations without verification: %v", err) | ||
| // Continue with validation even if attestation fetch fails | ||
| } |
There was a problem hiding this comment.
Don’t suppress attestation fetch failures in skip mode
Line 87 currently swallows registry fetch errors and continues, which can surface misleading downstream results instead of the real retrieval failure. Surface this failure in output and stop this component’s validation path.
Proposed change
if p.SkipAttSigCheck() {
log.Debug("Attestation signature check skipped, fetching attestations without verification")
if err := a.FetchAttestationsWithoutVerification(ctx); err != nil {
- log.Debugf("Failed to fetch attestations without verification: %v", err)
- // Continue with validation even if attestation fetch fails
+ out.SetAttestationSyntaxCheckFromError(fmt.Errorf("unable to fetch attestations without verification: %w", err))
+ return out, nil
}
} else {🤖 Prompt for 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.
In `@internal/image/validate.go` around lines 87 - 90, The attestation fetch error
is being suppressed in the validation path; change the behavior in the block
that calls a.FetchAttestationsWithoutVerification(ctx) so that instead of only
logging and continuing (the log.Debugf("Failed to fetch attestations without
verification: %v", err) path) you return or propagate a wrapped error to abort
this component's validation; locate the call to
a.FetchAttestationsWithoutVerification and replace the silent-continue with an
immediate return of the error (or fmt.Errorf/Wrap with context) so callers see
the registry fetch failure.
Implement --skip-att-sig-check flag to skip attestation signature validation checks, mirroring the existing --skip-image-sig-check flag. When enabled, attestation signature verification is bypassed during image validation.
Why? Often I'm debugging/troubleshooting something and I get given an image ref to look at. We can use cosign download attestation to inspect the attestation, which is very useful, but if we want to try running Conforma against it, we must either guess, find, or ask to be provided with the public key. Sometimes that's not so difficult, but other times it may be very difficult or even impossible. (Consider for example if the image was built on an ephemeral cluster and the signing secret used is gone forever.)
Now we can use --skip-image-sig-check and --skip-att-sig-check and carry on with the debugging. Note that we added the --skip-image-sig-check recently for other reasons, see https://redhat.atlassian.net/browse/EC-1647. The
--skip-att-sig-check is perhaps a little more complicated because we need to add a function that can download the attestation without verifying it.
The argument against this is that it may encourage less secure practices, but I would say it's acceptable because we're not changing the default behavior, which is always to require signature verification.
Ref: https://redhat.atlassian.net/browse/EC-1815