report

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 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

Overview

Package report builds the reports relgap prints. A digest lists a tool's versions in a range and the classified entries of their release notes.

Index

Constants

View Source
const (
	FailOnBreaking    = "breaking"
	FailOnDeprecation = "deprecation"
	FailOnEOL         = "eol"
	FailOnVuln        = "vuln"
	FailOnDrift       = "drift"
	FailOnOutdated    = "outdated"
)

FailOn values, as listed in the config schema.

View Source
const (
	ViaPrefix = "highest stable version with this prefix"
	ViaLatest = "latest channel"
)

Ways a non-exact pin becomes its current version, next to version.PickKnown and version.PickLowest.

View Source
const ViaFloor = "lower bound of the constraint"

ViaFloor says a constraint pin counts as its own lower bound, next to version.PickKnown.

Variables

This section is empty.

Functions

func IsEOL

func IsEOL(p *OutdatedPin) bool

IsEOL reports whether the pin's current version is on a release cycle that has reached its end.

func ParseVulnSeverity

func ParseVulnSeverity(s string) (string, error)

ParseVulnSeverity validates a --vuln-severity value. The empty string means any severity.

func Values

func Values() []string

Values returns every --fail-on value in the order of the config schema.

Types

type Behind

type Behind struct {
	Releases int        `json:"releases"`        // stable versions after Current up to Latest
	Major    int        `json:"major"`           // newer major lines among them
	Minor    int        `json:"minor"`           // newer minor lines among them
	Patch    int        `json:"patch"`           // those on Current's own minor line
	Since    *time.Time `json:"since,omitempty"` // when the first of them was published
}

Behind measures how far Current is from Latest. Every field comes from the digest's versions.

type Cell

type Cell struct {
	Values []CellValue
}

Cell is what one repository pins of a tool.

type CellValue

type CellValue struct {
	Text    string // a version, or the value of a pin that isn't compared
	Approx  bool   // no exact pin in the repository backs it
	Outlier bool   // differs from the tool's reference version
}

CellValue is one version or uncompared value in a Cell.

type Digest

type Digest struct {
	Tools []ToolDigest `json:"tools"`
}

Digest is the data of `relgap digest --format json`.

type DigestRequest

type DigestRequest struct {
	Tool               registry.ToolSpec
	From, To           string // To empty means the latest stable version on the line
	Line               version.Level
	IncludePrereleases bool
	MinConfidence      float64
	Kinds              []classify.Kind // when set, Entries lists only these kinds; Counts still counts every kind
	Only               *int            // when set, only the source at this index of Tool.Sources runs
}

DigestRequest says what to digest.

type Digester

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

Digester builds digests from GitHub.

func NewDigester

func NewDigester(logger *slog.Logger, gh GitHub, web source.WebFetcher) *Digester

NewDigester returns a digester that reads from gh and, for web-doc and URL sources, from web. Changelog files and web pages are fetched and parsed once per digester, and so is each tool's list of releases or tags.

func (*Digester) Digest

func (d *Digester) Digest(ctx context.Context, req DigestRequest) (*ToolDigest, error)

Digest lists the tool's versions, selects the range and classifies the notes of each version.

func (*Digester) TestSources

func (d *Digester) TestSources(ctx context.Context, req DigestRequest) (*SourceTest, error)

TestSources digests the range once per source, then with every source, ignoring the minimum confidence. A failing source doesn't stop the others.

func (*Digester) Universe

func (d *Digester) Universe(ctx context.Context, t registry.ToolSpec) (*version.Universe, error)

Universe returns every version of the tool, listed once per digester.

type Drift

type Drift struct {
	Repos []string    `json:"repos"`
	Tools []DriftTool `json:"tools"` // sorted by tool
}

Drift is the data of `relgap drift --format json`.

func (*Drift) Drifting

func (d *Drift) Drifting() []DriftTool

Drifting returns the tools whose pins stand for more than one version.

type DriftPin

type DriftPin struct {
	Location scan.Location `json:"location"`
	Value    string        `json:"value"`
	Match    scan.Match    `json:"match"`
	Version  string        `json:"version,omitempty"` // absent for a pin that isn't compared
	Via      string        `json:"via,omitempty"`     // how a constraint pin became Version
}

DriftPin is one pin and the version it counts as.

type DriftRequest

type DriftRequest struct {
	Repos             []string
	Pins              []scan.Pin // resolved pins only
	Resolve           ResolveFunc
	IgnoreConstraints bool // constraint pins aren't compared
	Latest            bool // look up the newest version of each tool
}

DriftRequest says which pins to compare.

type DriftTool

type DriftTool struct {
	Tool      string         `json:"tool"`
	Drift     bool           `json:"drift"`               // the pins stand for more than one version
	Reference string         `json:"reference,omitempty"` // the version most repositories pin; the newest on a tie
	Latest    string         `json:"latest,omitempty"`    // with --latest: the newest stable version on Reference's line
	Note      string         `json:"note,omitempty"`      // why Latest is missing
	Versions  []DriftVersion `json:"versions"`            // oldest first
	Pins      []DriftPin     `json:"pins"`                // sorted by repo, file and line

	// Err is set when looking up Latest failed.
	Err error `json:"-"`
}

DriftTool is every pin of one tool across the scanned repositories.

func (*DriftTool) Cell

func (t *DriftTool) Cell(repo string) Cell

Cell returns what repo pins of t: its distinct versions oldest first, then the values of pins that aren't compared. It is empty when repo doesn't pin the tool.

func (*DriftTool) Outliers

func (t *DriftTool) Outliers() []DriftPin

Outliers returns the compared pins of a drifting tool whose version differs from Reference.

type DriftVersion

type DriftVersion struct {
	Version string   `json:"version"`
	Repos   []string `json:"repos"`
}

DriftVersion is one distinct version of a tool and the repositories that pin it.

type Drifter

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

Drifter compares the pins of each tool across repositories.

func NewDrifter

func NewDrifter(logger *slog.Logger, recent RecentLister) *Drifter

NewDrifter returns a drifter that looks up latest versions through recent. Without DriftRequest.Latest it makes no call.

func (*Drifter) Drift

func (d *Drifter) Drift(ctx context.Context, req DriftRequest) (*Drift, error)

Drift compares every pin. Exact pins count as their version. A constraint counts as the highest exact pin of the tool in the same repository that satisfies it, else its lower bound. Prefix and channel pins aren't compared. It returns an error only when the latest lookup fails for every tool, such as for a rejected token.

type Finding

type Finding struct {
	FailOn string
	Pin    *OutdatedPin
	Vuln   *enrich.Vuln // the advisory, for vuln
	Digest *ToolDigest  // for breaking and deprecation in a single digest
	Drift  *DriftTool   // the tool of a drifted pin
}

Finding is one thing a --fail-on value counts: a pin, an advisory of a pin, a digest or a drifted pin.

type Gate

type Gate struct {
	Values       []string // the --fail-on values to check, in [Values] order
	MaxBehind    MaxBehind
	VulnSeverity string // the lowest rating --fail-on vuln counts; empty counts every advisory
	MinCount     int    // findings a value needs before it matches; below 1 counts as 1
	Now          time.Time
}

Gate is the set of --fail-on checks a command runs, with their thresholds.

func (Gate) Check

func (g Gate) Check(o *Outdated) ([]Finding, []*OutdatedPin)

Check returns the findings of the gate's values among the pins, and the outdated pins whose lag it couldn't measure. A pin counts for eol when its current version's cycle has reached its end, and for vuln once per advisory that affects its current version at or above VulnSeverity. It counts for outdated, breaking and deprecation only when it is behind latest.

func (Gate) CheckDigests

func (g Gate) CheckDigests(ds []ToolDigest) []Finding

CheckDigests returns a finding for each digest with a breaking or deprecation entry, for the values the gate checks. Entries below the minimum confidence aren't in the counts.

func (Gate) CheckDrift

func (g Gate) CheckDrift(d *Drift) []Finding

CheckDrift returns a finding for each drifted pin: a compared pin whose version differs from its tool's reference version.

func (Gate) Has

func (g Gate) Has(value string) bool

Has reports whether the gate checks value.

func (Gate) Matches

func (g Gate) Matches(findings []Finding) []Match

Matches groups findings by value, in Values order, and keeps the values with at least MinCount findings.

type GitHub

type GitHub interface {
	Releases(ctx context.Context, repo string) ([]github.Release, error)
	Tags(ctx context.Context, repo string) ([]string, error)
	source.ReleaseFetcher
	source.FileFetcher
	source.RootLister
}

GitHub lists releases, tags and top-level files and fetches release bodies and files; github.Client implements it.

type Match

type Match struct {
	FailOn   string
	Findings []Finding
}

Match is a --fail-on value whose findings reached the minimum count.

type MaxBehind

type MaxBehind struct {
	Unit string // major, minor, patch, releases or days; empty means any lag
	N    int
}

MaxBehind is a --max-behind threshold such as minor:2. The zero value allows nothing: any pin behind latest exceeds it.

func ParseMaxBehind

func ParseMaxBehind(s string) (MaxBehind, error)

ParseMaxBehind parses "<unit>:<n>"; the empty string is the zero threshold.

func (MaxBehind) Exceeded

func (m MaxBehind) Exceeded(b *Behind, now time.Time) (bool, bool)

Exceeded reports whether b is further behind than m allows. The second result is false when b can't tell, as with days for a tool whose versions are tags without publish dates.

func (MaxBehind) String

func (m MaxBehind) String() string

String returns the threshold as written.

type Outdated

type Outdated struct {
	Repos    []string         `json:"repos"`
	Pins     []OutdatedPin    `json:"pins"`
	Binaries []*enrich.Binary `json:"binaries,omitzero"` // with --binaries; empty when none found
}

Outdated is the data of `relgap outdated --format json`.

func (*Outdated) ApplyEnrichment

func (o *Outdated) ApplyEnrichment(results map[string]enrich.Result)

ApplyEnrichment sets the EOL state and vulnerabilities of each compared pin.

func (*Outdated) Digests

func (o *Outdated) Digests() []ToolDigest

Digests returns the distinct digests behind the outdated pins, in pin order.

func (*Outdated) EnrichRequests

func (o *Outdated) EnrichRequests(resolve ResolveFunc) []enrich.Request

EnrichRequests returns one request per tool and current version among the compared pins, with the latest version as the target.

type OutdatedPin

type OutdatedPin struct {
	Tool    string                `json:"tool"`
	Repo    string                `json:"repo,omitempty"` // GitHub owner/name
	Pin     scan.Pin              `json:"pin"`
	Current string                `json:"current,omitempty"` // the version the pin stands for
	Via     string                `json:"via,omitempty"`     // how a non-exact pin became Current
	Latest  string                `json:"latest,omitempty"`  // newest stable version on the tool's line
	Behind  *Behind               `json:"behind,omitempty"`
	Counts  map[classify.Kind]int `json:"counts,omitempty"` // entries of the digest Current..Latest
	Hidden  int                   `json:"hidden,omitempty"` // entries below the minimum confidence
	Status  Status                `json:"status"`
	Note    string                `json:"note,omitempty"`
	EOL     *enrich.EOL           `json:"eol,omitempty"`   // absent without an endoflife.date product
	Vulns   []enrich.Vuln         `json:"vulns,omitempty"` // known vulnerabilities of Current

	// Digest is the digest Counts come from; pins with the same tool and Current share it.
	Digest *ToolDigest `json:"-"`
}

OutdatedPin compares one pin with the latest version of its tool.

type OutdatedRequest

type OutdatedRequest struct {
	Repos         []string
	Pins          []scan.Pin // resolved pins only
	Resolve       ResolveFunc
	MinConfidence float64
	Concurrency   int
}

OutdatedRequest says which pins to compare.

type Outdater

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

Outdater compares pins with the latest versions of their tools.

func NewOutdater

func NewOutdater(digester *Digester, recent RecentLister) *Outdater

NewOutdater returns an outdater that finds latest versions through recent and counts entries with digester, the same code `relgap digest` runs.

func (*Outdater) Outdated

func (o *Outdater) Outdated(ctx context.Context, req OutdatedRequest) (*Outdated, error)

Outdated compares every pin. The "latest" lookup asks GitHub about all tools in batches; only pins behind latest and non-exact pins need a tool's full version list. It returns an error only for a failure that affects every tool, such as a rejected token.

type RecentLister

type RecentLister interface {
	Recent(ctx context.Context, qs []github.RecentQuery) (map[string]github.Recent, error)
}

RecentLister lists the newest releases of many repositories at once; github.Client implements it.

type ResolveFunc

type ResolveFunc func(tool string) (registry.ToolSpec, error)

ResolveFunc turns a pin's tool name into a tool spec.

type SourceResult

type SourceResult struct {
	Index    int                   `json:"index"` // position in the registry entry; -1 for merged
	Source   *registry.Source      `json:"source,omitempty"`
	Versions []string              `json:"versions"` // versions with at least one entry
	Entries  int                   `json:"entries"`
	Counts   map[classify.Kind]int `json:"counts"`
	URLs     []string              `json:"urls"` // distinct documents the entries came from
	Warnings []string              `json:"warnings"`
	Error    string                `json:"error,omitempty"`
}

SourceResult is what one source produced. Error is set when it failed.

type SourceTest

type SourceTest struct {
	Tool     string         `json:"tool"`
	Repo     string         `json:"repo"`
	From     string         `json:"from"`
	To       string         `json:"to"`
	Versions []string       `json:"versions"` // the versions in the range, oldest first
	Sources  []SourceResult `json:"sources"`
	Merged   SourceResult   `json:"merged"`
}

SourceTest is the data of `relgap registry test`: what each source of a tool produced over a range, and the merged digest's counts.

type Status

type Status string

Status says how a pin compares with the latest version.

const (
	StatusCurrent  Status = "current"  // at the latest version on its line
	StatusOutdated Status = "outdated" // behind it
	StatusUnknown  Status = "unknown"  // a channel other than latest, or a value that matches no version
	StatusSkipped  Status = "skipped"  // the tool has no GitHub repository relgap can read
	StatusError    Status = "error"    // GitHub failed for this tool
)

Pin statuses.

type ToolDigest

type ToolDigest struct {
	Tool     string                `json:"tool"`
	Repo     string                `json:"repo"`
	From     string                `json:"from"`
	To       string                `json:"to"`
	Versions []Version             `json:"versions"` // oldest first
	Entries  []classify.Entry      `json:"entries"`  // by version, then document order
	Counts   map[classify.Kind]int `json:"counts"`   // entries at or above the minimum confidence, per kind, listed or not
	Hidden   int                   `json:"hidden"`   // entries below the minimum confidence
	Warnings []string              `json:"warnings"`
}

ToolDigest is the digest of one tool over (From, To].

type Version

type Version struct {
	Version     string     `json:"version"`
	Tag         string     `json:"tag"`
	PublishedAt *time.Time `json:"published_at,omitempty"`
	URL         string     `json:"url,omitempty"` // the GitHub release page, when there is a release
}

Version is one version in a digested range.

Jump to

Keyboard shortcuts

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