Help us shape the future of Go! Take the 2026 Go Developer Survey

verification

package
v1.233.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PolicyWhenAvailable = "when_available"
	PolicyRequired      = "required"
	PolicyDisabled      = "disabled"

	VerifierInstallAuto     = "auto"
	VerifierInstallPathOnly = "path_only"

	VerifierTrustAuto     = "auto"
	VerifierTrustDisabled = "disabled"
)

Variables

View Source
var (
	ErrChecksumRequired        = errors.New("checksum verification required")
	ErrChecksumMismatch        = errors.New("checksum mismatch")
	ErrChecksumNotFound        = errors.New("checksum not found")
	ErrChecksumAmbiguous       = errors.New("ambiguous checksum entries for asset")
	ErrDownloadFailed          = errors.New("verification sidecar download failed")
	ErrUnsupportedAlgorithm    = errors.New("unsupported checksum algorithm")
	ErrSignatureRequired       = errors.New("signature verification required")
	ErrSignatureFailed         = errors.New("signature verification failed")
	ErrVerifierCommandRequired = errors.New("verifier command required")
)

Functions

func DigestFile added in v1.230.0

func DigestFile(path, algorithm string) (string, error)

DigestFile computes an artifact checksum independently of upstream sidecar availability, allowing a project lockfile to remain an integrity constraint.

Types

type CommandRunner

type CommandRunner interface {
	Run(ctx context.Context, name string, args ...string) error
}

CommandRunner runs external verification commands.

type Downloader

type Downloader interface {
	Download(ctx context.Context, url string) ([]byte, error)
}

Downloader fetches verification sidecar files such as checksum files and signatures.

type ExecRunner

type ExecRunner struct{}

ExecRunner runs verifier commands from PATH.

func (ExecRunner) Run

func (ExecRunner) Run(ctx context.Context, name string, args ...string) error

Run executes a verifier command.

type HTTPDownloader

type HTTPDownloader struct {
	Client *http.Client
}

HTTPDownloader downloads sidecar files using an HTTP client.

func (HTTPDownloader) Download

func (d HTTPDownloader) Download(ctx context.Context, url string) ([]byte, error)

Download fetches a URL and returns its response body.

type Policy

type Policy struct {
	Checksums       string
	Signatures      string
	VerifierInstall string
	VerifierTrust   string
}

Policy controls verification behavior.

func PolicyFromConfig

func PolicyFromConfig(config *schema.ToolchainVerification) Policy

PolicyFromConfig returns a fully defaulted verification policy.

type Request

type Request struct {
	Tool       *registry.Tool
	Version    string
	AssetURL   string
	AssetPath  string
	Policy     Policy
	Downloader Downloader
	Runner     CommandRunner
}

Request contains all data required to verify a downloaded tool asset.

type Result

type Result struct {
	AssetSize         int64
	ChecksumAlgorithm string
	Checksum          string
	SignatureMethods  []string
	SkippedReasons    []string
}

Result describes verification that was performed or skipped.

type Verifier

type Verifier struct {
	Downloader Downloader
	Runner     CommandRunner
	// contains filtered or unexported fields
}

Verifier verifies downloaded tool assets.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, req Request) (*Result, error)

Verify verifies a downloaded asset according to request policy.

Jump to

Keyboard shortcuts

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