Skip to content

Filter attestation retrieval by predicate type - #193

Closed
bdehamer wants to merge 2 commits into
mainfrom
bdehamer-filter-attestation-retrieval
Closed

Filter attestation retrieval by predicate type#193
bdehamer wants to merge 2 commits into
mainfrom
bdehamer-filter-attestation-retrieval

Conversation

@bdehamer

Copy link
Copy Markdown
Contributor

Summary

Previously the provider called the OCI Referrers API and then downloaded every Sigstore bundle attached to an image. For images with many referring artifacts, this meant one registry download per attestation.

This PR adds an optional predicate-type filter. When set, retrieval is limited to the first referrer whose dev.sigstore.bundle.predicateType annotation matches the configured value — downloading a single attestation instead of all of them. When empty (the default), behavior is unchanged and all bundles are fetched, so this is fully backward compatible.

The goal is to significantly cut registry API traffic for the common case where we know up front which attestation we want (e.g. SLSA build provenance).

Changes

  • pkg/fetcher/bundle.go: new PredicateType config var + PredicateTypeAnnotation constant. Selection is extracted into a pure, unit-tested selectBundleDescriptors helper that filters the referrers manifest before any blob download.
  • cmd/aaop: new -predicate-type flag, wired through configureBundleFetcher.
  • cmd/cver: same -predicate-type flag on the debug CLI.
  • Helm chart: new predicateType value (empty default); the -predicate-type arg is only rendered when set.
  • Docs/tests: README section, selectBundleDescriptors table tests, and updated configureBundleFetcher tests.

Usage

--set predicateType=https://slsa.dev/provenance/v1

Design note

The spec lists the bundle artifactType as application/vnd.dev.sigstore.bundle.v0.3+json. This PR keeps the existing version-agnostic prefix match (application/vnd.dev.sigstore.bundle) as the "is this a Sigstore bundle" gate and layers the predicate-type annotation on top, so it won't silently break on a future bundle version. The annotation is the real discriminator.

Filtering relies on the dev.sigstore.bundle.predicateType annotation being present on the referrer, which GitHub's attestation tooling (actions/attest, actions/publish-immutable-action) populates.

Testing

  • go test ./... -race — all pass
  • golangci-lint run ./... — 0 issues
  • helm template verified: arg present when predicateType is set, omitted when empty

Previously the provider called the OCI Referrers API and then downloaded
every Sigstore bundle attached to an image. For images with many
referring artifacts this meant one registry download per attestation.

Add an optional predicate-type filter. When the new -predicate-type flag
(chart value predicateType) is set, retrieval is limited to the first
referrer whose dev.sigstore.bundle.predicateType annotation matches the
configured value, downloading a single attestation instead of all of
them. When empty (the default) behavior is unchanged and all bundles are
fetched, so this is fully backward compatible.

The selection logic is extracted into a pure selectBundleDescriptors
helper and unit tested. Also wire the flag into the cver debug CLI and
document the option in the README and Helm chart.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

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.

Pull request overview

Adds configurable predicate-type filtering to reduce attestation registry downloads.

Changes:

  • Filters Sigstore referrers by predicate annotation.
  • Adds CLI and Helm configuration.
  • Adds documentation and unit tests.
Show a summary per file
File Description
README.md Documents filtering usage.
pkg/fetcher/bundle.go Implements descriptor selection.
pkg/fetcher/bundle_test.go Tests selection behavior.
cmd/cver/cver.go Adds debug CLI flag.
cmd/aaop/aaop.go Configures the provider filter.
cmd/aaop/aaop_test.go Tests fetcher configuration.
charts/artifact-attestations-opa-provider/values.yaml Adds the Helm value.
charts/artifact-attestations-opa-provider/templates/deployment.yaml Conditionally renders the flag.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread pkg/fetcher/bundle.go
Comment on lines +292 to +293
if desc.Annotations[PredicateTypeAnnotation] == predicateType {
return []v1.Descriptor{desc}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, this is totally valid. Intentionally ignoring this for the moment to see if this even helps reduce the incidence of errors in our tests.

piceri
piceri previously approved these changes Aug 13, 2026
Signed-off-by: Brian DeHamer <bdehamer@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants