verify

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInSumDB = errors.New("module version not found in checksum database")

ErrNotInSumDB indicates the module version is absent from the checksum database (e.g. a private module). Callers must treat this as "cannot verify" and keep the module.

Functions

func Poisoned

func Poisoned(ctx context.Context, g storage.Getter, o Oracle, mod, ver string) (bool, error)

Poisoned reports whether the stored zip for mod@ver disagrees with the canonical hash from the oracle. Any error obtaining the stored zip or the canonical hash is returned to the caller, which MUST treat it as "cannot verify -> keep" (never delete on uncertainty).

Types

type Oracle

type Oracle interface {
	CanonicalHash(ctx context.Context, mod, ver string) (string, error)
}

Oracle returns the canonical h1: zip hash for a module version.

func NewSumDBOracle

func NewSumDBOracle(baseURL string, client *http.Client) Oracle

NewSumDBOracle returns an Oracle backed by the checksum database at baseURL.

type Report

type Report struct {
	Matched        int // stored hash == canonical
	Mismatched     int // stored hash != canonical
	Purged         int // mismatches deleted (purge mode)
	SkippedPrivate int // matched a NoSumPattern, never looked up
	SkippedUnknown int // absent from the checksum DB (ErrNotInSumDB)
	Unverified     int // transient/storage/oracle error; kept
	DeleteErrors   int // Delete failed in purge mode
}

Report tallies the outcome of a sweep.

func Sweep

func Sweep(ctx context.Context, s Store, o Oracle, skip func(mod string) bool, purge bool, out io.Writer) (Report, error)

Sweep verifies every catalogued module version against the oracle. skip reports whether a module is private and MUST be consulted before any oracle lookup (to avoid leaking private module paths). When purge is true, mismatches are deleted; otherwise they are only reported.

type Store

type Store interface {
	storage.Cataloger
	storage.Getter
	storage.Deleter
}

Store is the subset of a storage backend the sweep needs.

Jump to

Keyboard shortcuts

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