sourcetool

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type ConfigFn

type ConfigFn func(*Tool) error

func WithAuthenticator

func WithAuthenticator(a *auth.Authenticator) ConfigFn

func WithCreatePolicyPR

func WithCreatePolicyPR(yesno bool) ConfigFn

func WithEnforce

func WithEnforce(enforce bool) ConfigFn

func WithPolicyRepo

func WithPolicyRepo(slug string) ConfigFn

func WithUserForkOrg

func WithUserForkOrg(org string) ConfigFn

type Tool

type Tool struct {
	Authenticator *auth.Authenticator
	Options       options.Options
	// contains filtered or unexported fields
}

Tool is the main object intended to expose sourcetool's functionality as a public API. Some of the logic is still implemented on the CLI commands but we want to slowly move it to public function under this struct.

func New

func New(funcs ...ConfigFn) (*Tool, error)

New initializes a new source tool instance.

func (*Tool) CheckPolicyRepoFork

func (t *Tool) CheckPolicyRepoFork() (bool, error)

CheckPolicyRepoFork checks that the logged in user has a fork of the configured policy repo.

func (*Tool) ConfigureControls

func (t *Tool) ConfigureControls(repo *models.Repository, branches []*models.Branch, configs []models.ControlConfiguration) error

ConfigureControls sets up a control in the repo

func (*Tool) ControlConfigurationDescr

func (t *Tool) ControlConfigurationDescr(branch *models.Branch, config models.ControlConfiguration) string

ControlConfigurationDescr returns a description of the controls

func (*Tool) ControlPrecheck

func (t *Tool) ControlPrecheck(
	r *models.Repository, branches []*models.Branch, config models.ControlConfiguration,
) (ok bool, remediationMessage string, remediateFn models.ControlPreRemediationFn, err error)

ControlPrecheck performs a prerequisite check before enabling a contrlol Backend may optionally return a remediation function to correct the prerequisite which the CLI can before attempting to enable the control.

func (*Tool) CreateBranchPolicy

func (t *Tool) CreateBranchPolicy(ctx context.Context, r *models.Repository, branches []*models.Branch) (*policy.RepoPolicy, error)

CreateBranchPolicy creates a repository policy

func (*Tool) CreatePolicyRepoFork

func (t *Tool) CreatePolicyRepoFork(ctx context.Context) error

CreatePolicyRepoFork creates a fork of the policy repository in the user's GitHub org

func (*Tool) CreateRepositoryPolicy

func (t *Tool) CreateRepositoryPolicy(ctx context.Context, r *models.Repository, branches []*models.Branch) (*policy.RepoPolicy, *models.PullRequest, error)

CreateRepositoryPolicy creates a policy for a repository

func (*Tool) FindPolicyPR

func (t *Tool) FindPolicyPR(repo *models.Repository) (*models.PullRequest, error)

func (*Tool) GetBranchControls

func (t *Tool) GetBranchControls(r *models.Repository, branch *models.Branch) (*slsa.ControlSetStatus, error)

GetRepoControls returns the controls that are enabled in a repository branch.

func (*Tool) GetRepositoryPolicy

func (t *Tool) GetRepositoryPolicy(ctx context.Context, r *models.Repository) (*policy.RepoPolicy, error)

GetRepositoryPolicy retrieves the policy of repo from the community

func (*Tool) OnboardRepository

func (t *Tool) OnboardRepository(repo *models.Repository, branches []*models.Branch) error

OnboardRepository configures a repository to set up the required controls to meet SLSA Source L3.

Directories

Path Synopsis
backends
attestation/notes
Package notes implements an attestation storage backend that reads from git commit notes
Package notes implements an attestation storage backend that reads from git commit notes
modelsfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
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