slsa

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttestationKey

func AttestationKey(artifactKey string) string

AttestationKey returns the attestation key for an artifact key

func SimulateContextCancellation

func SimulateContextCancellation() func(ctx context.Context, artifactPath, attestationPath string) error

SimulateContextCancellation creates a verification function that respects context cancellation

func SimulateVerificationFailure

func SimulateVerificationFailure(failingArtifacts ...string) func(ctx context.Context, artifactPath, attestationPath string) error

SimulateVerificationFailure creates a verification function that fails for specific artifacts

Types

type MockVerifier

type MockVerifier struct {
	// VerifyFunc allows customizing verification behavior in tests
	VerifyFunc func(ctx context.Context, artifactPath, attestationPath string) error

	// CallLog tracks verification calls for test assertions
	CallLog []VerifyCall

	// DefaultResult controls the default verification result when VerifyFunc is nil
	DefaultResult error
}

MockVerifier implements VerifierInterface for testing

func NewMockVerifier

func NewMockVerifier() *MockVerifier

NewMockVerifier creates a new mock verifier for testing

func (*MockVerifier) GetCallCount

func (m *MockVerifier) GetCallCount() int

GetCallCount returns the number of verification calls made

func (*MockVerifier) GetLastCall

func (m *MockVerifier) GetLastCall() *VerifyCall

GetLastCall returns the most recent verification call, or nil if no calls were made

func (*MockVerifier) Reset

func (m *MockVerifier) Reset()

Reset clears the call log and resets the mock state

func (*MockVerifier) SetVerifyFunc

func (m *MockVerifier) SetVerifyFunc(fn func(ctx context.Context, artifactPath, attestationPath string) error)

SetVerifyFunc sets a custom verification function

func (*MockVerifier) SetVerifyResult

func (m *MockVerifier) SetVerifyResult(err error)

SetVerifyResult sets a simple success/failure result for all verifications

func (*MockVerifier) VerifyArtifact

func (m *MockVerifier) VerifyArtifact(ctx context.Context, artifactPath, attestationPath string) error

VerifyArtifact implements the VerifierInterface

func (*MockVerifier) WasCalledWith

func (m *MockVerifier) WasCalledWith(artifactPath, attestationPath string) bool

WasCalledWith checks if the verifier was called with specific paths

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

Verifier handles SLSA attestation verification using Go API

func NewVerifier

func NewVerifier(sourceURI string, trustedRoots []string) *Verifier

NewVerifier creates a new SLSA verifier instance

func (*Verifier) VerifyArtifact

func (v *Verifier) VerifyArtifact(ctx context.Context, artifactPath, attestationPath string) error

VerifyArtifact verifies an artifact against its SLSA attestation using Go API This follows the same pattern as the official slsa-verifier CLI implementation

type VerifierInterface

type VerifierInterface interface {
	VerifyArtifact(ctx context.Context, artifactPath, attestationPath string) error
}

VerifierInterface defines the interface for SLSA verification

type VerifyCall

type VerifyCall struct {
	ArtifactPath    string
	AttestationPath string
	Context         context.Context
}

VerifyCall represents a single verification call for testing

Jump to

Keyboard shortcuts

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