trusted_task_rules: Add per-allow-rule signature verification#1680
trusted_task_rules: Add per-allow-rule signature verification#1680arewm wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@simonbaird @joejstuart , is this something that you are interested in? |
f066bc2 to
d757058
Compare
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAllow-rule matching for Tekton trusted tasks now enforces Sigstore signature verification when a rule includes a ChangesSignature Verification for Trusted Tasks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
policy/lib/tekton/trusted.rego (1)
337-353: 💤 Low valueDenial-reason branch logic looks correct, but consider deduplicating the matching predicate.
The new
signature_verification_failedbranch is reached only when no deny rule matches, some allow rule matches pattern+version, and_task_matches_allow_rulestill fails — i.e., signature verification is the only remaining failure cause. Git-resolved refs continue to short-circuit through_signature_verified_for_rule(ref, _) if { not ref.bundle }, so they do not surface this denial reason.One minor refactor opportunity: the pattern+version matching block here duplicates the predicate inside
_task_matches_allow_ruleminus the signature check. Extracting a helper like_task_matches_allow_rule_without_signature(ref, rule, bundle_manifests)would keep the two call sites aligned if pattern/version semantics ever evolve. Optional under the chill profile.🤖 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 `@policy/lib/tekton/trusted.rego` around lines 337 - 353, The denial branch for "signature_verification_failed" duplicates the pattern+version matching logic that also exists inside _task_matches_allow_rule; extract that shared predicate into a helper (e.g., _task_matches_allow_rule_without_signature(ref, rule, bundle_manifests)) and replace the duplicated checks in the signature_verification_failed branch and inside _task_matches_allow_rule so both call the new helper and only differ by the signature verification step (keeping existing short-circuit behavior from _signature_verified_for_rule(ref, _) when not ref.bundle intact).
🤖 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 `@policy/lib/tekton/trusted.rego`:
- Around line 405-441: The current _sigstore_opts_for_rule(rule) returns opts
with certificate/issuer keys set to empty strings which makes
signature_verification: {} permissive; update _sigstore_opts_for_rule to remove
any keys whose value is "" (and/or false when appropriate) before returning so
ec.sigstore.verify_image(bundle, opts) only receives explicitly configured
constraints, and/or add schema changes to require at least one identity and at
least one issuer field in signature_verification; ensure references to
_sigstore_opts_for_rule, _signature_verified_for_rule,
_sigstore_verify_has_errors and ec.sigstore.verify_image are updated to use the
stripped/validated opts.
---
Nitpick comments:
In `@policy/lib/tekton/trusted.rego`:
- Around line 337-353: The denial branch for "signature_verification_failed"
duplicates the pattern+version matching logic that also exists inside
_task_matches_allow_rule; extract that shared predicate into a helper (e.g.,
_task_matches_allow_rule_without_signature(ref, rule, bundle_manifests)) and
replace the duplicated checks in the signature_verification_failed branch and
inside _task_matches_allow_rule so both call the new helper and only differ by
the signature verification step (keeping existing short-circuit behavior from
_signature_verified_for_rule(ref, _) when not ref.bundle intact).
🪄 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: f7470a8e-3be9-4ee1-9d4a-b86852829975
📒 Files selected for processing (4)
policy/lib/tekton/trusted.regopolicy/lib/tekton/trusted_test.regopolicy/release/trusted_task/trusted_task.regopolicy/release/trusted_task/trusted_task_test.rego
d757058 to
47e49fc
Compare
Add optional `signature_verification` configuration to allow rules in trusted_task_rules, enabling sigstore-based signature verification as an additional trust dimension for task bundles. When an allow rule includes `signature_verification`, matching bundles must also pass sigstore verification with the configured identity/key. Rules without the field continue to work as before (pattern-only trust). Git-resolved tasks are exempt since ec.sigstore.verify_image only works on OCI refs. A new denial reason type `signature_verification_failed` is surfaced when a task matches an allow rule's pattern/version constraints but fails signature verification. Ref: EC-1545 Assisted-by: Claude Code (Opus 4.6)
Deduplicate the pattern+version matching logic shared between _task_matches_allow_rule and the signature_verification_failed denial_reason branch into _task_matches_allow_rule_pattern_version. No behavior change — pure refactor. Assisted-by: Claude Code (Opus 4.6)
An empty `signature_verification: {}` block would silently become
permissive because empty-string defaults are treated as "no constraint"
by Sigstore. Fix this in two ways:
- _sigstore_opts_for_rule now passes through only explicitly-set
non-default values instead of emitting empty-string defaults
- Schema requires at least one of certificate_identity,
certificate_identity_regexp, or public_key via anyOf, and enforces
minLength: 1 on all string fields
Assisted-by: Claude Code (Opus 4.6)
8b470e8 to
0221318
Compare
|
Gave it a fresh rebase. My plan is to re-review with the goal of getting it merged. Maybe we'll get some agentic reviews triggered also. |
|
🤖 Finished Review · ✅ Success · Started 4:01 PM UTC · Completed 4:12 PM UTC |
|
I'm not certain, but I think we want to merge conforma/cli#3136 before merging this. |
ReviewFindingsMedium
Low
Info
|
|
It shouldn't matter whether this or the CLI change is merged first. This rule shouldn't be hit yet so it shouldn't be required to have the CLI fix in. Before leveraging this rule, however, we should make sure that the CLI is updated. |
Summary
Today,
trusted_task_rulestrusts task bundles based solely on URL pattern matching — if the bundle ref matchesoci://quay.io/konflux-ci/tekton-catalog/*, it's trusted. This PR adds an optionalsignature_verificationfield on allow rules so that matching bundles must also have a verified sigstore signature from a specific identity.This is per-allow-rule because different catalogs may be signed by different parties (e.g., Konflux catalog vs. a third-party catalog). Rules without the field work exactly as before.
Changes:
signature_verificationconfig to allow rules intrusted_task_rulesec.sigstore.verify_imageonly works on OCI refs)signature_verification_faileddenial reason type with proper error formattingCompanion CLI PR: conforma/cli#3136 (caches
ec.sigstore.verify_imageresults across component evaluations for performance).Ref: EC-1545
Test plan