slsa

package
v0.0.0-...-1ba91b8 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GithubHostedActionsBuilderID is a default builder ID for Github hosted actions.
	GithubHostedActionsBuilderID = "https://github.com/Attestations/GitHubHostedActions@v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildType

type BuildType interface {
	// URI returns the build type's URI.
	URI() string

	// Subject returns a set of artifacts created by the build.
	Subject(context.Context) ([]intoto.Subject, error)

	// BuildConfig returns the buildConfig for this build type.
	BuildConfig(context.Context) (any, error)

	// Invocation returns an invocation for this build type.
	Invocation(context.Context) (slsa02.ProvenanceInvocation, error)

	// Materials returns materials as defined by this build type.
	Materials(context.Context) ([]slsacommon.ProvenanceMaterial, error)

	// Metadata returns a metadata about the build.
	Metadata(context.Context) (*slsa02.ProvenanceMetadata, error)
}

BuildType implements generation of buildType specific elements of SLSA provenance. Each BuildType instance represents a specific build.

type ClientProvider

type ClientProvider interface {
	OIDCClient() (*github.OIDCClient, error)
	GithubClient(context.Context) (*githubapi.Client, error)
}

ClientProvider creates Github API clients.

type DefaultClientProvider

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

DefaultClientProvider provides a default set of clients based on the Github Actions environment.

func (*DefaultClientProvider) GithubClient

func (p *DefaultClientProvider) GithubClient(ctx context.Context) (*githubapi.Client, error)

GithubClient returns a Github API client authenticated with the token provided in the github context.

func (*DefaultClientProvider) OIDCClient

func (p *DefaultClientProvider) OIDCClient() (*github.OIDCClient, error)

OIDCClient returns a default OIDC client.

type GithubActionsBuild

type GithubActionsBuild struct {
	// Context is the build's `github` context.
	Context github.WorkflowContext
	// Vars is the build's `vars` context.
	Vars github.VarsContext
	// Clients are the GitHub OIDC and API clients.
	Clients ClientProvider
	// Subjects are the build subjects.
	Subjects []intoto.Subject
}

GithubActionsBuild is a basic build type for builders running in GitHub Actions.

func NewGithubActionsBuild

func NewGithubActionsBuild(s []intoto.Subject, c *github.WorkflowContext, v github.VarsContext) *GithubActionsBuild

NewGithubActionsBuild returns a new GithubActionsBuild that uses the GitHub context to generate information.

func (*GithubActionsBuild) BuildConfig

func (b *GithubActionsBuild) BuildConfig(context.Context) (any, error)

BuildConfig implements BuildType.BuildConfig.

func (*GithubActionsBuild) Invocation

Invocation implements BuildType.Invocation. An invocation is returned that describes the workflow run. TODO: Document the basic invocation format.

func (*GithubActionsBuild) Materials

Materials implements BuildType.Materials. It returns a list of materials that includes the repository that triggered the GitHub Actions workflow.

func (*GithubActionsBuild) Metadata

Metadata implements BuildType.Metadata. It specifies that parameters are complete.

func (*GithubActionsBuild) Subject

Subject implements BuildType.Subject.

func (*GithubActionsBuild) WithClients

WithClients overrides the build type's default client provider. This is useful for tests where APIs are not available.

type HostedActionsGenerator

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

HostedActionsGenerator is a SLSA provenance generator for Github Hosted Actions. Provenance is generated based on a "build type" which defines the format for many of the fields in the provenance metadata. Builders for different ecosystems (languages etc.) can implement a build type from scratch or by extending GithubActionsBuild.

func NewHostedActionsGenerator

func NewHostedActionsGenerator(bt BuildType) *HostedActionsGenerator

NewHostedActionsGenerator returns a SLSA provenance generator for the given build type.

func (*HostedActionsGenerator) Generate

Generate generates an in-toto provenance statement in SLSA v0.2 format.

func (*HostedActionsGenerator) WithClients

WithClients overrides the default ClientProvider. Useful for tests where clients are not available.

type NilClientProvider

type NilClientProvider struct{}

NilClientProvider does not provide clients. It is useful for testing where APIs are not available.

func (*NilClientProvider) GithubClient

func (p *NilClientProvider) GithubClient(context.Context) (*githubapi.Client, error)

GithubClient returns nil for the client.

func (*NilClientProvider) OIDCClient

func (p *NilClientProvider) OIDCClient() (*github.OIDCClient, error)

OIDCClient returns nil for the client.

type WorkflowParameters

type WorkflowParameters struct {
	// EventInputs is the inputs for the event that triggered the workflow.
	EventInputs any `json:"event_inputs,omitempty"`

	// VarsContext includes the input parameters provided as part of the `vars`
	// context. This includes environment and repository variables.
	VarsContext any `json:"vars"`
}

WorkflowParameters contains parameters given to the workflow invocation.

Jump to

Keyboard shortcuts

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