Skip to content

Add --skip-att-sig-check flag#3267

Open
simonbaird wants to merge 2 commits into
conforma:mainfrom
simonbaird:skip-att-sig-check
Open

Add --skip-att-sig-check flag#3267
simonbaird wants to merge 2 commits into
conforma:mainfrom
simonbaird:skip-att-sig-check

Conversation

@simonbaird
Copy link
Copy Markdown
Member

@simonbaird simonbaird commented Apr 28, 2026

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: bcfc162a-50ea-4c55-8cc8-563045940829

📥 Commits

Reviewing files that changed from the base of the PR and between 87f5671 and bc7ed38.

⛔ Files ignored due to path filters (1)
  • features/__snapshots__/validate_image.snap is excluded by !**/*.snap
📒 Files selected for processing (9)
  • cmd/validate/image.go
  • docs/modules/ROOT/pages/ec_validate_image.adoc
  • features/validate_image.feature
  • internal/evaluation_target/application_snapshot_image/application_snapshot_image.go
  • internal/evaluation_target/application_snapshot_image/application_snapshot_image_test.go
  • internal/image/validate.go
  • internal/image/validate_test.go
  • internal/policy/policy.go
  • internal/policy/policy_test.go
✅ Files skipped from review due to trivial changes (1)
  • docs/modules/ROOT/pages/ec_validate_image.adoc
🚧 Files skipped from review as they are similar to previous changes (6)
  • internal/image/validate.go
  • internal/image/validate_test.go
  • internal/policy/policy_test.go
  • cmd/validate/image.go
  • internal/policy/policy.go
  • internal/evaluation_target/application_snapshot_image/application_snapshot_image.go

📝 Walkthrough

Walkthrough

This PR introduces a new --skip-att-sig-check flag to the ec validate image command, enabling users to skip attestation signature verification while still validating the image itself. The flag flows through policy configuration into conditional attestation retrieval, then integrates into the validation pipeline and is covered by unit and integration tests.

Changes

Attestation signature verification skip flag

Layer / File(s) Summary
Policy interface and configuration
internal/policy/policy.go, internal/policy/policy_test.go
Policy interface adds SkipAttSigCheck() bool method. New skipAttSigCheck field in policy struct and SkipAttSigCheck field in Options struct are wired into NewPolicy. Tests verify the method returns false by default and true when configured.
CLI flag and documentation
cmd/validate/image.go, docs/modules/ROOT/pages/ec_validate_image.adoc
New --skip-att-sig-check boolean flag is added to the command with an imageData.skipAttSigCheck field. The flag value is wired into policy.Options.SkipAttSigCheck during PreRunE. Documentation describes the option's default (false) and purpose.
Attestation fetching without verification
internal/evaluation_target/application_snapshot_image/application_snapshot_image.go, internal/evaluation_target/application_snapshot_image/application_snapshot_image_test.go
New FetchAttestationsWithoutVerification method retrieves attestations via OCI remote APIs without signature verification, populating attestations by selecting bundle or signature parsing based on presence. ValidateAttestationSignature updated to use parseAttestationsFromSignatures for the non-bundle path. parseAttestationsFromSignatures now explicitly handles SLSA v0.2, SLSA v1, SPDX, and unknown predicate types. OCI remote import added. Tests exercise predicate-type parsing across statement variants.
Image validation conditional logic
internal/image/validate.go, internal/image/validate_test.go
ValidateImage conditionally branches on SkipAttSigCheck(): when enabled, logs the skip and fetches attestations without verification (continuing on fetch errors); when disabled, performs standard verification. Tests cover both flag states and verify AttestationSignatureCheck.Result presence/absence and inclusion in Violations()/Successes().
End-to-end feature scenario
features/validate_image.feature
New "happy day with skip-att-sig-check flag" scenario runs validation with the flag and expects successful exit status with builtin.attestation.signature_check absent from success output.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add --skip-att-sig-check flag' directly and clearly summarizes the main change in the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose, motivation, and implementation approach for the new --skip-att-sig-check flag.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@simonbaird
Copy link
Copy Markdown
Member Author

Making it a draft because it has no Jira (yet anyway).

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 76.31579% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ation_snapshot_image/application_snapshot_image.go 62.50% 9 Missing ⚠️
Flag Coverage Δ
acceptance 55.63% <73.68%> (+0.02%) ⬆️
generative 17.77% <0.00%> (-0.06%) ⬇️
integration 26.51% <7.89%> (-0.06%) ⬇️
unit 69.01% <44.73%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/validate/image.go 91.42% <100.00%> (+0.06%) ⬆️
internal/image/validate.go 76.76% <100.00%> (+5.95%) ⬆️
internal/policy/policy.go 91.74% <100.00%> (+0.07%) ⬆️
...ation_snapshot_image/application_snapshot_image.go 82.60% <62.50%> (-2.18%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@simonbaird simonbaird force-pushed the skip-att-sig-check branch from 8d30082 to a77249d Compare May 7, 2026 20:52
@simonbaird
Copy link
Copy Markdown
Member Author

This isn't in the sprint currently, so maybe review it only after you reviewed everything else.

@simonbaird simonbaird force-pushed the skip-att-sig-check branch from a77249d to 767ffe0 Compare May 14, 2026 18:35
@simonbaird simonbaird marked this pull request as ready for review May 14, 2026 19:17
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/evaluation_target/application_snapshot_image/application_snapshot_image.go (1)

280-314: ⚡ Quick win

Deduplicate 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3743934 and 767ffe0.

📒 Files selected for processing (5)
  • cmd/validate/image.go
  • docs/modules/ROOT/pages/ec_validate_image.adoc
  • internal/evaluation_target/application_snapshot_image/application_snapshot_image.go
  • internal/image/validate.go
  • internal/policy/policy.go

Comment thread internal/image/validate.go
@github-actions github-actions Bot added size: XL and removed size: M labels May 18, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
internal/evaluation_target/application_snapshot_image/application_snapshot_image_test.go (1)

1158-1231: ⚡ Quick win

Add malformed DSSE payload coverage for the unverified parsing path.

This test only covers happy paths. Since --skip-att-sig-check relies on parsing unverified attestations, add at least one malformed DSSE/base64/statement case to lock down failure behavior and prevent regressions in this security-sensitive path.

internal/image/validate_test.go (1)

746-750: ⚡ Quick win

Assert VerifyImageAttestations call behavior for skip vs non-skip.

The test checks output shaping, but not whether attestation verification was actually bypassed. Add explicit mock call assertions so the flag contract is enforced (called when false, not called when true).

Suggested assertion pattern
 			output, err := ValidateImage(ctx, comp, snap, updatedPolicy, evaluators, false)

 			require.NoError(t, err)
 			require.NotNil(t, output)
+
+			if tt.skipAttSigCheck {
+				fakeClient.AssertNotCalled(t, "VerifyImageAttestations", refNoTag, mock.Anything)
+			} else {
+				fakeClient.AssertCalled(t, "VerifyImageAttestations", refNoTag, mock.Anything)
+			}

Also applies to: 783-826

🤖 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_test.go` around lines 746 - 750, Add explicit mock
expectations in the test around the VerifyImageAttestations (and similarly
VerifyImageSignatures) calls so the skip flag contract is enforced: when the
skip-attestations flag is false assert
fakeClient.AssertCalled/AssertNumberOfCalls for
VerifyImageAttestations(refNoTag, mock.Anything) (and for VerifyImageSignatures
when relevant), and when the skip flag is true assert fakeClient.AssertNotCalled
for VerifyImageAttestations; apply the same pattern for the other test variants
referenced (around the blocks using fakeClient.On("Head", ref)... and the other
cases in the 783-826 range) to ensure attestations are invoked only when not
skipped.
🤖 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 712-718: This file fails gci import/format checks; run the
repository formatting/import toolchain to reorder and format imports and code in
the test file containing TestValidateImageSkipAttSigCheck and the tests struct,
then re-run gci/static checks to ensure the file is properly formatted before
committing.

---

Nitpick comments:
In `@internal/image/validate_test.go`:
- Around line 746-750: Add explicit mock expectations in the test around the
VerifyImageAttestations (and similarly VerifyImageSignatures) calls so the skip
flag contract is enforced: when the skip-attestations flag is false assert
fakeClient.AssertCalled/AssertNumberOfCalls for
VerifyImageAttestations(refNoTag, mock.Anything) (and for VerifyImageSignatures
when relevant), and when the skip flag is true assert fakeClient.AssertNotCalled
for VerifyImageAttestations; apply the same pattern for the other test variants
referenced (around the blocks using fakeClient.On("Head", ref)... and the other
cases in the 783-826 range) to ensure attestations are invoked only when not
skipped.
🪄 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: 8c50c02f-863b-4993-9b4a-6ed41ef86795

📥 Commits

Reviewing files that changed from the base of the PR and between 767ffe0 and a80cb60.

📒 Files selected for processing (4)
  • internal/evaluation_target/application_snapshot_image/application_snapshot_image.go
  • internal/evaluation_target/application_snapshot_image/application_snapshot_image_test.go
  • internal/image/validate_test.go
  • internal/policy/policy_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/evaluation_target/application_snapshot_image/application_snapshot_image.go

Comment thread internal/image/validate_test.go
@simonbaird simonbaird force-pushed the skip-att-sig-check branch from a80cb60 to 87f5671 Compare May 18, 2026 19:31
simonbaird and others added 2 commits May 18, 2026 15:46
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>
Also refactor some duplicated code

Co-authored-by: Claude Code <noreply@anthropic.com>
@simonbaird simonbaird force-pushed the skip-att-sig-check branch from 87f5671 to bc7ed38 Compare May 18, 2026 19:57
@simonbaird
Copy link
Copy Markdown
Member Author

Doing some extra work to get the Codecov check green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant