attestation

package
v0.16.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package attestation verifies GitHub build-provenance attestations for Starmap catalog release artifacts.

The package separates two responsibilities. The Sigstore engine (github.com/sigstore/sigstore-go) validates the bundle, the certificate chain, the transparency evidence, the observer timestamps, and the artifact digest. This package owns the Starmap trust policy. The policy binds the verified certificate and statement to one repository, one workflow, one OIDC issuer, one predicate type, and one artifact digest.

Verify does not use the network. The caller supplies the bundle bytes, the artifact digest, and the trusted-root document. A connected caller refreshes the trusted root through TUF and passes the result here.

Index

Constants

View Source
const (
	// GitHubOIDCIssuer is the OIDC issuer of every GitHub Actions workload
	// identity.
	GitHubOIDCIssuer = "https://token.actions.githubusercontent.com"

	// BuildProvenancePredicateType is the in-toto predicate type that
	// actions/attest-build-provenance writes.
	BuildProvenancePredicateType = "https://slsa.dev/provenance/v1"

	// HostedRunnerEnvironment is the value that a GitHub-hosted runner
	// reports. A self-hosted runner reports a different value.
	HostedRunnerEnvironment = "github-hosted"

	// DigestAlgorithm is the only artifact digest algorithm the policy accepts.
	DigestAlgorithm = "sha256"
)

Variables

This section is empty.

Functions

func DefaultTrustedRootJSON

func DefaultTrustedRootJSON() []byte

DefaultTrustedRootJSON returns a caller-owned copy of the compiled Sigstore public-good trusted root.

The compiled root is a fixed snapshot. Sigstore rotates its keys, so a long-lived process should refresh the root through TUF and override it.

Types

type Policy

type Policy struct {
	// Repository is the owner and name of the signing repository, such as
	// "agentstation/starmap".
	Repository string

	// Workflow is the repository-relative path of the signing workflow, such
	// as ".github/workflows/catalog-generation.yaml".
	Workflow string

	// Issuer is the expected OIDC issuer. Use GitHubOIDCIssuer.
	Issuer string

	// PredicateType is the expected in-toto predicate type. Use
	// BuildProvenancePredicateType.
	PredicateType string

	// TrustedRootJSON is a Sigstore trusted-root document. The caller reads
	// and refreshes it.
	TrustedRootJSON []byte

	// DenySelfHostedRunners rejects an attestation that a self-hosted runner
	// produced.
	DenySelfHostedRunners bool
}

Policy binds a verified attestation to one Starmap publisher identity. Verify requires every field.

type Result

type Result struct {
	// PredicateType is the verified in-toto predicate type.
	PredicateType string

	// SignerIdentity is the verified certificate subject alternative name.
	SignerIdentity string

	// SourceRepositoryURI is the verified source repository.
	SourceRepositoryURI string

	// SourceRepositoryDigest is the verified commit that built the artifact.
	SourceRepositoryDigest string

	// RunnerEnvironment is the verified runner environment.
	RunnerEnvironment string

	// ObservedAt is the earliest verified observer timestamp.
	ObservedAt time.Time
}

Result reports the publisher facts that verification proved.

func Verify

func Verify(ctx context.Context, bundleJSON []byte, artifactDigest string, policy Policy) (Result, error)

Verify checks one Sigstore bundle against the policy and the artifact digest. The digest is a lowercase hexadecimal SHA-256 digest without an algorithm prefix.

Verify returns a *errors.ValidationError for an unusable argument, a *errors.ParseError for an undecodable document, and a *TrustError when the evidence does not satisfy the policy.

type TrustError

type TrustError struct {
	// Stage names the policy check that failed.
	Stage string

	// Expected is the value the policy requires, when the stage compares one.
	Expected string

	// Actual is the value the attestation carried, when the stage compares one.
	Actual string

	// Message describes the failure.
	Message string

	// Err is the underlying engine error, when one exists.
	Err error
}

TrustError reports evidence that does not satisfy the Starmap policy.

func (*TrustError) Error

func (e *TrustError) Error() string

Error implements the error interface.

func (*TrustError) Unwrap

func (e *TrustError) Unwrap() error

Unwrap implements errors.Unwrap.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL