Skip to content

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

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

Add --skip-att-sig-check flag#3267
simonbaird wants to merge 3 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

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a configurable --skip-att-sig-check CLI flag wired into policy options, implements a verification-free attestation fetch path, conditions image validation on the flag, and updates unit and integration tests plus docs and feature scenario.

Changes

Attestation signature verification skip flag

Layer / File(s) Summary
Policy interface and configuration
internal/policy/policy.go, internal/policy/policy_test.go
Adds SkipAttSigCheck() bool to Policy, skipAttSigCheck to policy, SkipAttSigCheck to Options, wires option into NewPolicy, and tests default/true behavior.
CLI flag and documentation
cmd/validate/image.go, docs/modules/ROOT/pages/ec_validate_image.adoc
Adds --skip-att-sig-check flag, stores value in imageData.skipAttSigCheck, wires into policy.Options.SkipAttSigCheck during PreRunE, and documents the option (default: false).
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
Adds ociremote import and FetchAttestationsWithoutVerification(ctx), chooses bundle vs signature parsing, updates parseAttestationsFromSignatures predicate handling for SLSA v0.2/v1/SPDX/unknown, and adds unit test TestParseAttestationsFromSignatures.
Image validation conditional logic
internal/image/validate.go, internal/image/validate_test.go
ValidateImage branches on policy.SkipAttSigCheck(): when true, calls fetch-without-verification and records the attestation check result; when false, runs standard validation. Tests verify presence/absence of AttestationSignatureCheck.Result and inclusion in Violations()/Successes().
End-to-end feature scenario
features/validate_image.feature
Adds "happy day with skip-att-sig-check flag" scenario that runs validation with the flag and expects builtin.attestation.signature_check omitted 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 directly and concisely describes the main change: adding a new CLI flag for skipping attestation signature verification.
Description check ✅ Passed The description provides clear context about the feature, its motivation, and implementation approach, all directly related to the changeset.
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.

Copy link
Copy Markdown
Contributor

@st3penta st3penta left a comment

Choose a reason for hiding this comment

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

Main concerns: error visibility when the fetch fails in skip mode, the new method bypasses the oci.Client abstraction centralized in #3269, and test coverage for the new code path needs work.

Comment thread internal/image/validate.go
Comment on lines +84 to 96
// Handle attestation signature validation
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
}
} else {
out.SetAttestationSignatureCheckFromError(a.ValidateAttestationSignature(ctx))
if !out.AttestationSignatureCheck.Passed {
return out, nil
}
}
Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

When this path is taken, AttestationSignatureCheck in the output is {passed: false, result: null} -- indistinguishable from "never reached." An explicit "skipped" result would make the output unambiguous for downstream consumers and audit trails. (Same gap exists for --skip-image-sig-check, but out of scope here.)

Also: combining both skip flags silently disables all crypto verification with no indication in the output. A Warn log when both are active would help catch accidental misuse.

return out, nil
// Handle attestation signature validation
if p.SkipAttSigCheck() {
log.Debug("Attestation signature check skipped, fetching attestations without verification")
Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

Skipping a security check is operationally significant -- if this flag is accidentally left in a CI config, operators should be able to spot it without enabling Debug verbosity. Consider log.Warn here.

}

remoteOpts := oci.CreateRemoteOptions(ctx)
signedEntity, err := ociremote.SignedEntity(a.reference, ociremote.WithRemoteOptions(remoteOpts...))
Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

This calls ociremote.SignedEntity directly, bypassing the oci.Client abstraction every other OCI operation in this file uses. That import was deliberately removed in #3269 to centralize OCI access. Adding a method to oci.Client would keep the pattern consistent and make this testable with fake.FakeClient.

Comment on lines +211 to +244
func (a *ApplicationSnapshotImage) FetchAttestationsWithoutVerification(ctx context.Context) error {
if trace.IsEnabled() {
region := trace.StartRegion(ctx, "ec:fetch-attestations-without-verification")
defer region.End()
}

remoteOpts := oci.CreateRemoteOptions(ctx)
signedEntity, err := ociremote.SignedEntity(a.reference, ociremote.WithRemoteOptions(remoteOpts...))
if err != nil {
return fmt.Errorf("failed to fetch signed entity: %w", err)
}

layers, err := signedEntity.Attestations()
if err != nil {
return fmt.Errorf("failed to fetch attestations: %w", err)
}

// Check if using bundles
useBundles := a.hasBundles(ctx)
if useBundles {
sigs, err := layers.Get()
if err != nil {
return fmt.Errorf("failed to get attestation signatures: %w", err)
}
return a.parseAttestationsFromBundles(sigs)
}

sigs, err := layers.Get()
if err != nil {
return fmt.Errorf("failed to get attestation signatures: %w", err)
}

return a.parseAttestationsFromSignatures(sigs)
}
Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

This method has four error paths and a bundle/non-bundle branch, none tested at the unit level. The integration test does not mock this path either, so the fetch silently fails there. Routing through oci.Client (per the comment above) would make it straightforward to test with the existing fake infrastructure.

Comment on lines +712 to +731
func TestValidateImageSkipAttSigCheck(t *testing.T) {
tests := []struct {
name string
skipAttSigCheck bool
expectAttSigResult bool
expectImageSigCheckCall bool
}{
{
name: "skip attestation signature check disabled (default)",
skipAttSigCheck: false,
expectAttSigResult: true,
expectImageSigCheckCall: true,
},
{
name: "skip attestation signature check enabled",
skipAttSigCheck: true,
expectAttSigResult: false,
expectImageSigCheckCall: true,
},
}
Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

No mocks are set up for ociremote.SignedEntity, so FetchAttestationsWithoutVerification always fails silently in the skip-enabled case. This validates "error was swallowed" rather than "attestations were fetched without verification" -- a regression that ignores the flag entirely would still pass.

Comment on lines +59 to 86
Scenario: happy day with skip-att-sig-check flag
Given a key pair named "known"
Given an image named "acceptance/ec-happy-day"
Given a valid image signature of "acceptance/ec-happy-day" image signed by the "known" key
Given a valid attestation of "acceptance/ec-happy-day" signed by the "known" key
Given a git repository named "happy-day-policy" with
| main.rego | examples/happy_day.rego |
Given policy configuration named "ec-policy" with specification
"""
{
"sources": [
{
"policy": [
"git::https://${GITHOST}/git/happy-day-policy.git"
]
}
]
}
"""
When ec command is run with "validate image --image ${REGISTRY}/acceptance/ec-happy-day --policy acceptance/ec-policy --public-key ${known_PUBLIC_KEY} --skip-att-sig-check --rekor-url ${REKOR} --show-successes --output json"
Then the exit status should be 0
# The only difference to the happy day scenario is that
# builtin.attestation.signature_check is not found in the success output
Then the output should match the snapshot

Scenario: happy day with git config and yaml
Given a key pair named "known"
Given an image named "acceptance/ec-happy-day"
Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

The attestation here is signed with the correct key, so the skip flag is redundant. The --skip-image-sig-check has a companion scenario at line 214 with an invalid signature that proves the flag is needed. An equivalent scenario with a wrong attestation key would catch a regression that silently ignores this flag.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I was being lazy here main to satisfy Codecov stats. 😅

Comment on lines +231 to +242
sigs, err := layers.Get()
if err != nil {
return fmt.Errorf("failed to get attestation signatures: %w", err)
}
return a.parseAttestationsFromBundles(sigs)
}

sigs, err := layers.Get()
if err != nil {
return fmt.Errorf("failed to get attestation signatures: %w", err)
}

Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

layers.Get() is identical in both branches -- could hoist it above the conditional.

sigs, err := layers.Get()
if err != nil {
    return fmt.Errorf("failed to get attestation signatures: %%w", err)
}

if useBundles {
    return a.parseAttestationsFromBundles(sigs)
}
return a.parseAttestationsFromSignatures(sigs)

name string
skipAttSigCheck bool
expectAttSigResult bool
expectImageSigCheckCall bool
Copy link
Copy Markdown
Contributor

@st3penta st3penta May 19, 2026

Choose a reason for hiding this comment

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

expectImageSigCheckCall is populated in both cases but never asserted. Remove it or add the intended check.

return a.parseAttestationsFromSignatures(sigs)
}

func (a *ApplicationSnapshotImage) parseAttestationsFromSignatures(sigs []cosignOCI.Signature) error {
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.

ValidateAttestationSyntax docstring references ValidateAttestationSignature as the required prefill, but this function is now also a valid prefill path. Worth updating the docstring to mention both.

expectAttSigResult: false,
expectImageSigCheckCall: true,
},
}
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.

Consider adding a case with both --skip-image-sig-check and --skip-att-sig-check enabled -- that is the expected real-world debugging usage per the PR description.

Co-authored-by: Stefano Pentassuglia <spentass@redhat.com>
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

🤖 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`:
- Line 89: The file uses fmt.Errorf in the call to
out.SetAttestationSignatureCheckFromError but does not import the fmt package;
add "fmt" to the import block in internal/image/validate.go so fmt.Errorf can be
resolved (locate the use at
out.SetAttestationSignatureCheckFromError(fmt.Errorf(...)) and update the
imports accordingly).
🪄 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: 5089e64a-4278-4072-8ad6-b64e2ae89fee

📥 Commits

Reviewing files that changed from the base of the PR and between bc7ed38 and 5b6e064.

📒 Files selected for processing (1)
  • internal/image/validate.go

log.Debug("Attestation signature check skipped, fetching attestations without verification")
if err := a.FetchAttestationsWithoutVerification(ctx); err != nil {
log.Warnf("Failed to fetch attestations without verification: %v", err)
out.SetAttestationSignatureCheckFromError(fmt.Errorf("failed to fetch attestations (signature check skipped): %w", err))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
from pathlib import Path

p = Path("internal/image/validate.go").read_text()
imports = p.split("import (", 1)[1].split(")", 1)[0]

print("fmt.Errorf used:", "fmt.Errorf(" in p)
print('fmt imported:', '"fmt"' in imports)

if "fmt.Errorf(" in p and '"fmt"' not in imports:
    raise SystemExit("verification_failed: fmt.Errorf is used without importing fmt")
PY

Repository: conforma/cli

Length of output: 178


Add the missing fmt import before merging.

Line 89 uses fmt.Errorf, but this file does not import fmt, which prevents the package from compiling.

Proposed fix
 import (
 	"context"
 	"encoding/json"
+	"fmt"
 	"runtime/trace"
 	"sort"
 	"time"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
out.SetAttestationSignatureCheckFromError(fmt.Errorf("failed to fetch attestations (signature check skipped): %w", err))
import (
"context"
"encoding/json"
"fmt"
"runtime/trace"
"sort"
"time"
🧰 Tools
🪛 golangci-lint (2.12.2)

[error] 89-89: : # github.com/conforma/cli/internal/image [github.com/conforma/cli/internal/image.test]
internal/image/validate.go:89:46: undefined: fmt

(typecheck)

🤖 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` at line 89, The file uses fmt.Errorf in the call
to out.SetAttestationSignatureCheckFromError but does not import the fmt
package; add "fmt" to the import block in internal/image/validate.go so
fmt.Errorf can be resolved (locate the use at
out.SetAttestationSignatureCheckFromError(fmt.Errorf(...)) and update the
imports accordingly).

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.

2 participants