Documentation
¶
Overview ¶
Package verify checks OCI artifact signatures for the mirror: upstream provenance per a manifest's verifyUpstream rules (keyless with an identity regexp, or a published public key), and the mirror's own signatures (the exact certificate identity or KMS key it signs with, as the publish-idempotency self-check).
Verification drives the same code paths the cosign CLI drives: sigstore bundles attached via OCI referrers are discovered first, with fallback to legacy .sig tags, and a rule may point at a dedicated signature repository for publishers that store signatures away from the artifact. A rule with an attestationType verifies a signed in-toto attestation of that predicate type instead, for publishers that attest rather than sign. Keyless verification fetches the public trust roots (TUF); key-based verification is offline.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Verify ¶
func Verify(ctx context.Context, runner ToolRunner, s Subject) error
Verify checks the subject by shelling out to the cosign binary. Its bundle-format default discovers sigstore bundles via referrers when present and legacy .sig tags otherwise (upstreams may still publish those). The CLI also checks claims (--check-claims defaults to true).
A subject with an AttestationType runs cosign verify-attestation instead, which requires a signed attestation of exactly that predicate type over the artifact. Since cosign v3.1.6, cosign verify accepts only bundles carrying the cosign signing predicate, so an attestation bundle no longer counts as a signature, and referrers that hold attestations alone also stop discovery from falling back to an older .sig tag.
Types ¶
type Subject ¶
type Subject struct {
// Ref is the artifact to verify (tag or digest reference).
Ref string
// KeyRef verifies against a public key (a path, URL or KMS URI);
// empty means keyless.
KeyRef string
// HashAlgorithm overrides the payload digest for key verification
// ("", "sha256", "sha384" or "sha512"; some publishers sign with
// sha512).
HashAlgorithm string
// IdentityRegexp matches the certificate identity for keyless
// verification (mutually exclusive with Identity).
IdentityRegexp string
// Identity pins the exact certificate identity (the mirror's own
// signatures).
Identity string
// Issuer is the OIDC issuer for keyless verification.
Issuer string
// SignatureRepository reads signatures from a dedicated repository
// instead of alongside the artifact.
SignatureRepository string
// IgnoreTlog skips transparency-log verification (key-based rules
// and offline self-checks).
IgnoreTlog bool
// AllowHTTPRegistry permits plain-HTTP registries (tests, local
// mirrors).
AllowHTTPRegistry bool
// AttestationType, when set, verifies a signed in-toto attestation
// of this predicate type (cosign verify-attestation --type) instead
// of an image signature.
AttestationType string
}
Subject is one verification: what to check and against which trust.
func MirrorSubject ¶
MirrorSubject translates the mirror's own signing config into the self-verification for ref: the exact identity keyless signing produces, or the KMS key's public half.
func UpstreamSubject ¶
func UpstreamSubject(ref string, rule spec.VerifyRule) (Subject, error)
UpstreamSubject translates a manifest verifyUpstream rule for ref. Provider none is the caller's business: it is a documented gap, never a verification.
type ToolRunner ¶ added in v0.11.0
type ToolRunner interface {
// Run executes name with args and extra environment, returning stdout.
Run(ctx context.Context, name string, args, env []string) (stdout []byte, err error)
// Look reports whether the binary is available.
Look(name string) bool
}
ToolRunner executes the cosign binary. It is an interface so tests can record its invocations and return canned results. scan.ExecRunner satisfies it.