bundle

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleOptsFunc added in v0.3.0

type BundleOptsFunc func(*DefaultVerifier) error

func WithSigstoreRootsData added in v0.3.0

func WithSigstoreRootsData(data []byte) BundleOptsFunc

WithSigstoreRootsData sets the raw json data holding the sigstore instances configuration

func WithSpiffeVerifier added in v0.5.0

func WithSpiffeVerifier(sv SpiffeVerifier) BundleOptsFunc

WithSpiffeVerifier installs the verifier used when a bundle carries a SPIFFE-shaped identity (leaf cert with a spiffe:// URI SAN).

type CredentialProvider added in v0.5.0

type CredentialProvider interface {
	// Prepare acquires credentials, keys, and certificates. Called once
	// before the first sign; implementations are expected to be idempotent.
	Prepare(ctx context.Context) error

	// Keypair returns the signing keypair used by sign.Bundle.
	Keypair() sign.Keypair

	// CertificateProvider returns the provider sign.Bundle will call to
	// populate VerificationMaterial, together with any provider-specific
	// options (e.g. an OIDC ID token for Fulcio).
	CertificateProvider() (sign.CertificateProvider, *sign.CertificateProviderOptions)

	// Intermediates returns the certificates between the leaf and the trust
	// anchor, in order from leaf-adjacent to root-adjacent. The root itself
	// must NOT be included — verifiers supply it out-of-band.
	//
	// Returns nil when there are no intermediates to embed (the sigstore
	// case, where the chain is reconstructed from TUF at verify time). When
	// the return value is non-empty, the outer Signer rewrites the bundle's
	// VerificationMaterial to carry [leaf, ...intermediates] so the verifier
	// can build a path to its pinned trust anchor.
	Intermediates() []*x509.Certificate
}

CredentialProvider produces the signing material used to populate a bundle. Implementations own the lifecycle of the keypair and the certificate provider that sign.Bundle calls to build VerificationMaterial.

type DefaultSigner

type DefaultSigner struct{}

DefaultSigner implements the BundleSigner interface for the signer

func (*DefaultSigner) BuildBundleOptions added in v0.5.0

func (bs *DefaultSigner) BuildBundleOptions(opts *options.Signer, cp CredentialProvider) (*sign.BundleOptions, error)

BuildBundleOptions assembles the sign.BundleOptions used by SignBundle. The certificate provider is supplied by the given CredentialProvider. TSA and Rekor endpoints, when requested, come from the sigstore signing config — SigningConfig is only required when those features are turned on, so SPIFFE (which carries no sigstore config and never wants TSA/Rekor today) flows through with no sigstore data leaking into the bundle.

func (*DefaultSigner) BuildMessage

func (bs *DefaultSigner) BuildMessage(data []byte) *sign.PlainData

BuildMessage is the alternative to WrapData.

func (*DefaultSigner) SignBundle

func (bs *DefaultSigner) SignBundle(content sign.Content, keypair sign.Keypair, opts *sign.BundleOptions) (*protobundle.Bundle, error)

SignBundle signs the DSSE envelop and returns the new bundle

func (*DefaultSigner) VerifyAttestationContent

func (bs *DefaultSigner) VerifyAttestationContent(_ *options.Signer, data []byte) error

VerifyContent checka that the attestation is in good shape to sign

func (*DefaultSigner) WrapData

func (bs *DefaultSigner) WrapData(payloadType string, data []byte) *sign.DSSEData

type DefaultVerifier

type DefaultVerifier struct {
	Verifiers []VerifyCapable

	// SPIFFE, when set, handles bundles whose leaf certificate carries a
	// spiffe:// URI SAN. Constructed outside this package (typically in
	// signer.NewVerifier) to avoid a bundle -> spiffe import dependency.
	SPIFFE SpiffeVerifier
}

DefaultVerifier implements the BundleVerifier interface.

func (*DefaultVerifier) BuildSigstoreVerifier

func (bv *DefaultVerifier) BuildSigstoreVerifier(conf *sigstore.InstanceConfig) (VerifyCapable, error)

BuildSigstoreVerifier creates a configured sigstore verifier from the configured options. TODO(puerco): Abstract the returned verifier

func (*DefaultVerifier) OpenBundle

func (bv *DefaultVerifier) OpenBundle(path string) (*bundle.Bundle, error)

OpenBundle opens a bundle file

func (*DefaultVerifier) RunVerification

func (bv *DefaultVerifier) RunVerification(
	opts *options.SigstoreVerification, sigstoreVerifier VerifyCapable, bndl *bundle.Bundle,
) (*verify.VerificationResult, error)

RunVerification verifies an artifact using the provided verifier

func (*DefaultVerifier) Verify added in v0.3.0

Verify is the main verification function to check bundles. Dispatches to the SPIFFE verifier when the bundle carries a spiffe:// URI SAN; otherwise iterates the configured sigstore instances.

type Signer

type Signer interface {
	VerifyAttestationContent(*options.Signer, []byte) error
	WrapData(payloadType string, data []byte) *sign.DSSEData
	BuildMessage(data []byte) *sign.PlainData
	BuildBundleOptions(*options.Signer, CredentialProvider) (*sign.BundleOptions, error)
	SignBundle(content sign.Content, keypair sign.Keypair, opts *sign.BundleOptions) (*protobundle.Bundle, error)
}

BundleSigner abstracts the signer implementation to make it easy to mock

func NewSigner added in v0.3.1

func NewSigner() Signer

type SpiffeVerifier added in v0.5.0

type SpiffeVerifier interface {
	Verify(*options.Verification, *bundle.Bundle) (*verify.VerificationResult, error)
}

SpiffeVerifier verifies bundles signed against a SPIFFE/SPIRE trust domain. Implemented by spiffe.Verifier; typed as an interface here so the bundle package doesn't have to import the spiffe package.

type Verifier

BundleVerifier abstracts the verification implementation to make it easy to mock for testing.

func New added in v0.3.0

func New(funcs ...BundleOptsFunc) Verifier

New creates a new verifier. Initialization errors are logged to stderr but not returned. Use NewWithError if you need to handle errors.

func NewWithError added in v0.4.3

func NewWithError(funcs ...BundleOptsFunc) (Verifier, error)

NewWithError creates a new verifier and returns any initialization error.

type VerifyCapable

type VerifyCapable interface {
	Verify(verify.SignedEntity, verify.PolicyBuilder) (*verify.VerificationResult, error)
}

VerifyCapable abstracts the verifier to mock

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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