Documentation
¶
Index ¶
- Constants
- Variables
- type BuildTypeParamsUnsetError
- type ControlResult
- type Option
- type Options
- type Result
- type Status
- type UnconfiguredControl
- type VerificationOption
- func WithBuildTypeControls(enabled bool) VerificationOption
- func WithExpectedSigner(id *sapi.Identity) VerificationOption
- func WithExpectedSigners(ids []*sapi.Identity) VerificationOption
- func WithGitDigestAliases(enabled bool) VerificationOption
- func WithMinLevel(level int) VerificationOption
- func WithParam(name string, value any) VerificationOption
- func WithParams(params map[string]any) VerificationOption
- func WithRequireSignatures(required bool) VerificationOption
- func WithSkipBuildTypeChecks(skip bool) VerificationOption
- func WithSpecVersion(version string) VerificationOption
- func WithSubjects(expected []*subject.Expected) VerificationOption
- func WithTrack(track controls.Track) VerificationOption
- func WithUserControlList(list []*controls.Control) VerificationOption
- func WithUserControls(enabled bool) VerificationOption
- func WithVerifierID(id string) VerificationOption
- type VerificationOptions
- type Verifier
- type VerifierImplementation
Constants ¶
const BuilderBindingControlID = "builder-identity-bound"
BuilderBindingControlID identifies the core result of binding the provenance's builder.id to the identity that signed the statement.
Variables ¶
var ErrBuildTypeParamsUnset = errors.New("buildType checks need parameters that were not set")
ErrBuildTypeParamsUnset is returned by Verify when the catalog has checks for the statement's buildType that take parameters and the caller set none of them: the catalog knows how to check this builder's provenance and no expectation was stated. Set at least one of the listed parameters, or skip the buildType checks explicitly.
var ErrIdentityMismatch = errors.New("slsa: verified signer does not match any expected --signer")
ErrIdentityMismatch is returned by CheckIdentities when the statement is signed and verified but no expected signer matches the verified identities.
var ErrNotImplemented = errors.New("slsa: not implemented")
var ErrSignatureRequired = errors.New("slsa: statement is not signed or signature did not verify")
ErrSignatureRequired is returned when the statement carries no verified signature in a context that requires one (RequireSignatures or a non-empty ExpectedSigners list).
var ErrSignatureUnverified = errors.New("slsa: statement signature did not verify")
ErrSignatureUnverified is returned by VerifySignatures — whether or not signatures are required — when the statement's signature was checked and did not verify: unsigned means no claim of integrity, refuted means a claim of integrity that is false.
Functions ¶
This section is empty.
Types ¶
type BuildTypeParamsUnsetError ¶
type BuildTypeParamsUnsetError struct {
BuildType string
Controls []UnconfiguredControl
}
BuildTypeParamsUnsetError carries the detail behind ErrBuildTypeParamsUnset: the buildType and, per control, the parameters its applicable check accepts.
func (*BuildTypeParamsUnsetError) Error ¶
func (e *BuildTypeParamsUnsetError) Error() string
func (*BuildTypeParamsUnsetError) Unwrap ¶
func (e *BuildTypeParamsUnsetError) Unwrap() error
type ControlResult ¶
ControlResult captures the outcome of evaluating a single control.
type Option ¶
Option is a functional option applied at Verifier construction time.
func WithBuilders ¶
WithBuilders sets the builder registry the verifier will use, replacing the embedded one.
func WithCatalog ¶
WithCatalog sets the control catalog the verifier will use, replacing the embedded one.
func WithDefaultVerificationOptions ¶
func WithDefaultVerificationOptions(o *VerificationOptions) Option
WithDefaultVerificationOptions sets the verification options that apply to every Verify call unless overridden by the iptions.
func WithImplementation ¶
func WithImplementation(impl VerifierImplementation) Option
WithImplementation overrides the verifier implementation. Primarily used in tests to inject a counterfeiter-generated fake.
type Options ¶
type Options struct {
// Catalog is the set of controls available to the verifier. When nil,
// the verifier loads the embedded catalog at construction time.
Catalog *controls.Catalog
// Builders is the registry binding builders to their signing
// identities. When nil, the verifier loads the embedded registry at
// construction time.
Builders *builders.Registry
}
Options holds construction-time settings for a Verifier.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns a zero-value Options struct used when no options are provided to New.
type Result ¶
type Result struct {
// Status is the aggregate outcome derived from all evaluated controls.
Status Status
// SLSALevel is the highest SLSA level whose required core controls all passed.
SLSALevel int
// Message explains a failing Status that is not attributable to a
// single control, such as the computed level falling short of the
// required minimum. Empty otherwise.
Message string
// VerifierID is the identity of the entity that performed the
// verification, copied from VerificationOptions.VerifierID. It is used
// as verifier.id when a VSA is emitted from this result.
VerifierID string
// SpecVersion is the SLSA spec version whose criteria the statement
// was evaluated against which is the version the requested SpecVersion
// resolved to in the catalog (eg "1.2"). It surfaces as
// slsaVersion when a VSA is emitted from this result.
SpecVersion string
// CoreResults holds per-control results for the SLSA spec-defined controls.
CoreResults []*ControlResult
// BuildTypeResults holds per-control results for custom buildType controls.
BuildTypeResults []*ControlResult
// UserResults holds per-control results for user-supplied controls.
UserResults []*ControlResult
// Subjects holds the outcome of binding the statement to the
// artifacts the caller holds, one entry per expected subject in the
// order given (see WithSubjects). Empty when no subjects were
// expected. Any unmatched entry makes Status a FAIL.
Subjects []subject.Match
}
Result is the final verification outcome returned to callers.
type Status ¶
type Status string
Status enumerates the high-level outcome of a verification or a single control.
const ( // StatusPass means the verification or control evaluation succeeded. StatusPass Status = "PASS" // StatusFail means the verification or control evaluation failed. StatusFail Status = "FAIL" // StatusError means the control evaluation produced an error during evaluation // (distinct from a clean false outcome). StatusError Status = "ERROR" // StatusSkipped means none of the control's checks applied to the // statement (predicate type or buildTypes mismatch). Skipped // controls do not contribute to PASS/FAIL or SLSA-level computation. StatusSkipped Status = "SKIP" )
type UnconfiguredControl ¶
type UnconfiguredControl struct {
ID string
Title string
Parameters []string
OptionalParameters []string
}
UnconfiguredControl is a buildType control whose check applies to the statement but has none of its parameters set.
type VerificationOption ¶
type VerificationOption func(*VerificationOptions) error
VerificationOption is a functional option applied to a Verify call.
func WithBuildTypeControls ¶
func WithBuildTypeControls(enabled bool) VerificationOption
WithBuildTypeControls toggles evaluation of custom buildType controls.
func WithExpectedSigner ¶
func WithExpectedSigner(id *sapi.Identity) VerificationOption
WithExpectedSigner appends an expected signer identity. Calling this option multiple times accumulates entries (OR 'ed).
func WithExpectedSigners ¶
func WithExpectedSigners(ids []*sapi.Identity) VerificationOption
WithExpectedSigners replaces the expected signer list with ids.
func WithGitDigestAliases ¶
func WithGitDigestAliases(enabled bool) VerificationOption
WithGitDigestAliases controls whether an expected sha1 or sha256 digest matches a statement subject carrying it as a git object digest, and the other way around. On by default; pass false to require the exact algorithm names.
func WithMinLevel ¶
func WithMinLevel(level int) VerificationOption
WithMinLevel sets the SLSA level the attestation must reach for the verification to pass: a computed level below it fails the run. Core controls declared above the minimum level become informative: when they fail they cap the computed SLSA level without failing the run. Zero (the default) requires every applicable control to pass regardless of level.
func WithParam ¶
func WithParam(name string, value any) VerificationOption
WithParam sets a single parameter on the params map exposed to CEL. Calling WithParam multiple times accumulates entries.
func WithParams ¶
func WithParams(params map[string]any) VerificationOption
WithParams replaces the params map with the provided one.
func WithRequireSignatures ¶
func WithRequireSignatures(required bool) VerificationOption
WithRequireSignatures toggles whether the verifier fails when the statement is unsigned or its signature did not verify.
func WithSkipBuildTypeChecks ¶
func WithSkipBuildTypeChecks(skip bool) VerificationOption
WithSkipBuildTypeChecks skips buildType controls whose parameters were not set, reporting them as skipped, instead of returning ErrBuildTypeParamsUnset when the caller set none of the parameters the catalog's checks for the statement's buildType accept.
func WithSpecVersion ¶
func WithSpecVersion(version string) VerificationOption
WithSpecVersion selects the SLSA spec version whose verification criteria the statement is evaluated against (e.g. "1.2" or "v1.2"). The newest catalog at or below the requested version applies. An empty string (default) selects the latest available.
func WithSubjects ¶
func WithSubjects(expected []*subject.Expected) VerificationOption
WithSubjects sets the artifacts the statement must be about: each one must match a statement subject (sharing at least one digest algorithm and agreeing on every shared one) or the verification fails. The list replaces any previous one; nil clears it.
func WithTrack ¶
func WithTrack(track controls.Track) VerificationOption
WithTrack forces the verifier to evaluate the statement against the given track regardless of how the catalog classifies the predicate type. The empty value means "auto" and falls back to catalog-driven resolution. Pass controls.TrackBuild or controls.TrackSource (or any future track) explicitly.
func WithUserControlList ¶
func WithUserControlList(list []*controls.Control) VerificationOption
WithUserControlList sets the list of user-supplied controls to evaluate.
func WithUserControls ¶
func WithUserControls(enabled bool) VerificationOption
WithUserControls toggles evaluation of user-supplied controls.
func WithVerifierID ¶
func WithVerifierID(id string) VerificationOption
WithVerifierID sets the identity of the entity performing the verification. It is recorded on the Result and used as verifier.id when a VSA is emitted. Consumer applications embedding the verifier should set their own identity here, the CLI sets the slsa-verifier project URL.
type VerificationOptions ¶
type VerificationOptions struct {
// RunBuildTypeControls toggles execution of custom buildType controls.
RunBuildTypeControls bool
// RunUserControls toggles execution of user supplied controls.
RunUserControls bool
// SkipBuildTypeChecks skips buildType controls whose parameters were
// not set instead of failing the run with ErrBuildTypeParamsUnset.
// BuildType controls that take no parameters still run.
SkipBuildTypeChecks bool
// RequireSignatures, when true, fails verification if the statement
// does not carry a verified signature (ie loaded as a plain in-toto envelope
// or failed to verify).
RequireSignatures bool
// UserControls is the list of user-supplied controls evaluated when
// RunUserControls is true.
UserControls []*controls.Control
// ExpectedSigners is the set of identities alloed to sign the statement.
// When set, CheckIdentities will only accept the statement if at
// least one verified signer matches one of these (OR'ed). An empty list
// is the default and skips identity matching.
ExpectedSigners []*sapi.Identity
// Subjects are the artifacts the caller holds and expects the
// statement to be about. When non-empty, every one of them must
// match a subject of the statement or the verification fails. Empty
// (the default) binds the statement to nothing: it is verified on
// its content alone.
Subjects []*subject.Expected
// NoGitDigestAliases requires exact digest algorithm names when
// matching Subjects. By default git object digests (gitCommit,
// gitTree, …) are interchangeable with the sha1 or sha256 hash they
// are. See subject.WithGitDigestAliases.
NoGitDigestAliases bool
// ForceTrack overrides the catalog's predicate-type to track
// resolution. Empty means "auto" (the catalog must associate the
// predicate type with exactly one track). When set to a track
// constant (TrackBuild/TrackSource), the verifier evaluates
// against that track and errors if the catalog does not classify the
// predicate type under it.
ForceTrack controls.Track
// Params is the parameter map exposed to CEL expressions as `params`.
// Values are typically string or []string, matching what the --param
// CLI flag produces.
Params map[string]any
// VerifierID identifies the entity performing the verification. It is
// recorded on the Result and surfaces as verifier.id when a VSA is
// emitted from the outcome. The CLI sets it from --verifier-id,
// defaulting to the SLSA verifier project URL; applications embedding
// the verifier should set their own identity. Empty by default.
VerifierID string
// SpecVersion selects the SLSA spec version whose verification
// criteria (control catalog) the statement is evaluated against,
// eg "1.2". Criteria carry forward across releases, so the newest
// catalog at or below the requested version applies. Empty (the
// default) means the latest version the catalog defines for the
// resolved track.
SpecVersion string
// MinLevel is the SLSA level the attestation is required to reach.
// When set (> 0), the run fails unless the computed level reaches
// it, and core controls declared above it are informative: their
// failure caps the computed level but does not fail the run. Zero
// (the default) keeps the strict semantics where every applicable
// control must pass. Controls without a declared level, buildType
// controls and user controls are always required.
MinLevel int
}
VerificationOptions holds per-call settings for Verifier.Verify.
func DefaultVerificationOptions ¶
func DefaultVerificationOptions() VerificationOptions
DefaultVerificationOptions returns the default per-call options.
type Verifier ¶
type Verifier struct {
Options Options
// contains filtered or unexported fields
}
Verifier is the SLSA attestation verifier. It orchestrates the layered verification flow described in the project design, delegating the per-layer logic to the configured verifierImplementation.
func New ¶
New constructs a Verifier with the embedded control catalog and the default verifierImplementation. Pass options to override either.
func (*Verifier) Verify ¶
func (v *Verifier) Verify(ctx context.Context, statement attestation.Statement, opts ...VerificationOption) (*Result, error)
Verify runs the layered verification flow against the given statement and returns a Result describing the outcome.
type VerifierImplementation ¶
type VerifierImplementation interface {
// VerifySignatures verifies the integrity of the statement's envelope
// (layer 1).
VerifySignatures(ctx context.Context, opts *VerificationOptions, statement attestation.Statement) error
// CheckIdentities matches the verified identities against the expected
// signer identities (layer 2). Currently a placeholder; identity-match
// flags will be added later.
CheckIdentities(ctx context.Context, opts *VerificationOptions, statement attestation.Statement) error
// CheckSubjects binds the statement to the artifacts the caller
// holds: every opts.Subjects entry must match a statement subject.
// Returns one match per expected subject, in order, so callers can
// report each; an empty list when nothing was asked.
CheckSubjects(ctx context.Context, opts *VerificationOptions, statement attestation.Statement) ([]subject.Match, error)
// CheckBuilder binds the provenance's builder.id to the statement's
// verified signer using the builder registry and reports the outcome
// as a core control result; nil for statements without a builder.
CheckBuilder(ctx context.Context, opts *VerificationOptions, registry *builders.Registry, statement attestation.Statement) (*ControlResult, error)
// ResolveCategory selects which catalog category to apply by looking
// up the statement's predicate-type track in the catalog (layer 3
// split build vs source). Honours opts.ForceTrack when set.
ResolveCategory(opts *VerificationOptions, catalog *controls.Catalog, statement attestation.Statement) (controls.Category, error)
// SelectCoreControls chooses the core SLSA controls to evaluate from
// the catalog given the resolved category (layer 4).
SelectCoreControls(opts *VerificationOptions, catalog *controls.Catalog, category controls.Category) []*controls.Control
// SelectBuildTypeControls chooses the custom buildType controls
// applicable to the given statement (layer 5).
SelectBuildTypeControls(opts *VerificationOptions, catalog *controls.Catalog, statement attestation.Statement) []*controls.Control
// SelectUserControls returns the user-supplied controls (layer 6).
SelectUserControls(opts *VerificationOptions) []*controls.Control
// RunControls evaluates a list of controls against the statement and
// returns one result per control.
RunControls(ctx context.Context, opts *VerificationOptions, ctrls []*controls.Control, statement attestation.Statement) ([]*ControlResult, error)
// ComputeResult condenses the per-layer outcomes into the final
// verification result, including the SLSA level (layer 7).
ComputeResult(opts *VerificationOptions, coreResults, buildTypeResults, userResults []*ControlResult) (*Result, error)
}
VerifierImplementation is the contract Verifier delegates to. It maps the verification layers described in the project design (signature, identity, predicate routing, control selection, control evaluation, result computation) onto discrete, independently testable methods.
A counterfeiter-generated fake of this interface lives in the slsafakes sub-package and is injected via WithImplementation.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package builders holds the registry of build platforms the verifier can bind to their signing identity: for each known builder, who must have signed the provenance for its builder.id to count as proven rather than merely claimed.
|
Package builders holds the registry of build platforms the verifier can bind to their signing identity: for each known builder, who must have signed the provenance for its builder.id to count as proven rather than merely claimed. |
|
Package predicate registers SLSA-only attestation.PredicateParser implementations as the collector's global predicate parser registry.
|
Package predicate registers SLSA-only attestation.PredicateParser implementations as the collector's global predicate parser registry. |
|
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
|
Package verifiers holds the registry of VSA issuers the verifier can bind to their signing identity: for each known verifier.id, who must have signed the VSA for the id to count as proven rather than merely claimed.
|
Package verifiers holds the registry of VSA issuers the verifier can bind to their signing identity: for each known verifier.id, who must have signed the VSA for the id to count as proven rather than merely claimed. |
|
Package vsa provides a version-neutral in-memory representation of SLSA Verification Summary Attestations and the adapters that map the on-the-wire proto types (vsa/v0.2, vsa/v1, …) onto it.
|
Package vsa provides a version-neutral in-memory representation of SLSA Verification Summary Attestations and the adapters that map the on-the-wire proto types (vsa/v0.2, vsa/v1, …) onto it. |