models

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DigestTypeGitCommit = "gitCommit"
	DigestTypeSha1      = "sha1"
)

Digest algorithm names used in attestation subjects

Variables

View Source
var (
	ErrProtectionAlreadyInPlace = errors.New("controls already in place in the repository")
	ErrRepositoryAccessDenied   = errors.New("access to repository denied")
)

Functions

This section is empty.

Types

type Actor

type Actor struct {
	Login string
}

Actor abstracts a user. For now it is intended to model both entities that interact with a repository but also the user using sourcetool. At some point we may split both roles if we need to.

func (*Actor) GetLogin

func (a *Actor) GetLogin() string

GetLogin returns the login string of the Actor

type AttestationStorageReader

type AttestationStorageReader interface {
	GetCommitVsa(context.Context, *Branch, *Commit) (*attestation.Statement, *vpb.VerificationSummary, error)
	GetCommitProvenance(context.Context, *Branch, *Commit) (*attestation.Statement, *provenance.SourceProvenancePred, error)
}

AttestationStorageReader abstracts an attestation storage system where sourcetool can read VSAs and provenance attestations. For now we only have retrieval functions but this may expand to store statements as well if we need to.

type BackendOptions added in v0.7.0

type BackendOptions struct {
	AllowMergeCommits bool
	DriverOptions     any
}

type Branch

type Branch struct {
	Name       string
	Repository *Repository
}

func (*Branch) FullRef

func (b *Branch) FullRef() string

func (*Branch) GetName added in v0.7.0

func (b *Branch) GetName() string

func (*Branch) GetRepository added in v0.7.0

func (b *Branch) GetRepository() *Repository

type Commit

type Commit struct {
	SHA     string
	Author  string
	Time    *time.Time
	Message string
}

func (*Commit) GetCommit added in v0.7.0

func (c *Commit) GetCommit() *Commit

func (*Commit) ToResourceDescriptor added in v0.7.0

func (c *Commit) ToResourceDescriptor() *attestation.ResourceDescriptor

type ControlConfiguration

type ControlConfiguration string
const (
	CONFIG_POLICY         ControlConfiguration = "CONFIG_POLICY"
	CONFIG_GEN_PROVENANCE ControlConfiguration = "CONFIG_GEN_PROVENANCE"
	CONFIG_BRANCH_RULES   ControlConfiguration = "CONFIG_BRANCH_RULES"
	CONFIG_TAG_RULES      ControlConfiguration = "CONFIG_TAG_RULES"
)

type ControlConfigurationReporter added in v0.7.3

type ControlConfigurationReporter interface {
	ConfigureControlsWithResults(*Repository, []*Branch, []ControlConfiguration) ([]*ControlConfigurationResult, error)
}

ControlConfigurationReporter is an optional interface that VCS backends can implement to report what they did when configuring the controls. Backends that do not implement it are driven through VcsBackend.ConfigureControls and produce no results.

type ControlConfigurationResult added in v0.7.3

type ControlConfigurationResult struct {
	// Config is the control configuration the result refers to.
	Config ControlConfiguration

	// Changed is true when configuring the control modified the repository
	// or opened a pull request. It is false when there was nothing to do.
	Changed bool

	// Message describes the outcome in a sentence that can be shown to users.
	Message string

	// PullRequest is the pull request that configures the control. It is set
	// both when the pull request was opened and when it was already open.
	PullRequest *PullRequest
}

ControlConfigurationResult reports what was done when configuring a control.

type ControlPreRemediationFn

type ControlPreRemediationFn func() (string, error)

ControlPreRemediation is a function returned by the VCS backends when checking for prerequisites that the user may optionally run

type ProvenanceWorkflow added in v0.7.1

type ProvenanceWorkflow struct {
	// Path of the workflow file, relative to the repository root
	Path string

	// LegacyActionsRepos lists the deprecated repositories the workflow still
	// calls the SLSA actions from. When empty, the workflow calls the actions
	// from their current repository.
	LegacyActionsRepos []string

	// RecommendedAction describes how to bring the workflow up to date. It
	// is nil when the workflow does not need any changes.
	RecommendedAction *slsa.ControlRecommendedAction

	// LastRun is the most recent completed run of the workflow in the branch.
	// It is nil when the workflow has not run or when its runs could not
	// be read.
	LastRun *WorkflowRun
}

ProvenanceWorkflow describes a CI workflow found in a repository that calls the SLSA source actions to generate provenance.

func (*ProvenanceWorkflow) IsFailing added in v0.7.3

func (pw *ProvenanceWorkflow) IsFailing() bool

IsFailing returns true when the most recent run of the workflow failed.

func (*ProvenanceWorkflow) IsLegacy added in v0.7.1

func (pw *ProvenanceWorkflow) IsLegacy() bool

IsLegacy returns true when the workflow calls the SLSA actions from a deprecated repository.

type PullRequest

type PullRequest struct {
	Title  string
	Body   string
	Time   *time.Time
	Head   string
	Base   string // main
	Number int
	Repo   *Repository
}

PullRequest models a GitHub pull request. If we need to use this outside of the repo.PullRequestManager and other GitHub-specific code we should model a ChangeRequest or similar interface to accommodate similar constructs, such as GitLab merge requests.

func (*PullRequest) GetHttpURL added in v0.7.3

func (pr *PullRequest) GetHttpURL() string

GetHttpURL returns the URL of the pull request. It returns an empty string when the pull request does not have enough data to build it.

func (*PullRequest) Reference added in v0.7.3

func (pr *PullRequest) Reference() string

Reference returns the pull request URL or, when it cannot be built, its number.

type Reference added in v0.7.0

type Reference interface {
	FullRef() string
	GetRepository() *Repository
	GetName() string
}

type Repository

type Repository struct {
	Hostname      string
	Path          string
	DefaultBranch string
}

func (*Repository) GetHttpURL

func (r *Repository) GetHttpURL() string

func (*Repository) GetSshURL

func (r *Repository) GetSshURL() string

func (*Repository) PathAsGitHubOwnerName

func (r *Repository) PathAsGitHubOwnerName() (owner, name string, err error)

parseRepoPath parses the owner and repo name from the repository path

type Revision added in v0.7.0

type Revision interface {
	GetCommit() *Commit
}

type Tag

type Tag struct {
	Name       string
	Commit     *Commit
	Repository *Repository
}

func (*Tag) FullRef added in v0.7.0

func (t *Tag) FullRef() string

func (*Tag) GetCommit added in v0.7.0

func (t *Tag) GetCommit() *Commit

func (*Tag) GetName added in v0.7.0

func (t *Tag) GetName() string

func (*Tag) GetRepository added in v0.7.0

func (t *Tag) GetRepository() *Repository

type VcsBackend

type VcsBackend interface {
	GetBranchControls(context.Context, *Branch) (*slsa.ControlSet, error)
	GetBranchControlsAtCommit(context.Context, *Branch, *Commit) (*slsa.ControlSet, error)
	GetTagControls(context.Context, *Branch, *Tag) (*slsa.ControlSet, error)
	ControlConfigurationDescr(*Branch, ControlConfiguration) string
	ConfigureControls(*Repository, []*Branch, []ControlConfiguration) error
	GetLatestCommit(context.Context, *Repository, *Branch) (*Commit, error)
	ControlPrecheck(*Repository, []*Branch, ControlConfiguration) (bool, string, ControlPreRemediationFn, error)
	GetPreviousCommit(context.Context, *Branch, *Commit) (*Commit, error)
	GetDefaultBranch(context.Context, *Repository) (*Branch, error)
	GetRevisionCommit(context.Context, *Repository, Revision) (*Commit, error)
	FindProvenanceWorkflows(context.Context, *Branch) ([]*ProvenanceWorkflow, error)
}

VcsBackend abstracts a VCS or VCS hosting system that sourcetool can inspect for SLSA controls.

type WorkflowRun added in v0.7.3

type WorkflowRun struct {
	// Conclusion is the result of the run as reported by the CI system,
	// for example "success" or "failure".
	Conclusion string

	// URL is the address where the run can be inspected.
	URL string

	// Commit is the digest of the commit the workflow ran on.
	Commit string

	// Time is when the run was created.
	Time *time.Time
}

WorkflowRun describes a completed run of a CI workflow.

func (*WorkflowRun) Failed added in v0.7.3

func (wr *WorkflowRun) Failed() bool

Failed returns true when the run finished with an error. Runs that were cancelled or skipped are not considered failures.

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