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
- func IsEOL(p *OutdatedPin) bool
- func ParseVulnSeverity(s string) (string, error)
- func Values() []string
- type Behind
- type Cell
- type CellValue
- type Digest
- type DigestRequest
- type Digester
- type Drift
- type DriftPin
- type DriftRequest
- type DriftTool
- type DriftVersion
- type Drifter
- type Finding
- type Gate
- type GitHub
- type Match
- type MaxBehind
- type Outdated
- type OutdatedPin
- type OutdatedRequest
- type Outdater
- type RecentLister
- type ResolveFunc
- type SourceResult
- type SourceTest
- type Status
- type ToolDigest
- type Version
Constants ¶
const ( FailOnBreaking = "breaking" FailOnDeprecation = "deprecation" FailOnEOL = "eol" FailOnVuln = "vuln" FailOnDrift = "drift" FailOnOutdated = "outdated" )
FailOn values, as listed in the config schema.
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.
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 ¶
ParseVulnSeverity validates a --vuln-severity value. The empty string means any severity.
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 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 ¶
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.
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`.
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.
type DriftVersion ¶
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 ¶
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 ¶
CheckDrift returns a finding for each drifted pin: a compared pin whose version differs from its tool's reference version.
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 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 ¶
ParseMaxBehind parses "<unit>:<n>"; the empty string is the zero threshold.
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 ¶
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.
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 ¶
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].