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 ChartVersionsNote(t registry.ToolSpec) string
- func EntriesOf(entries []classify.Entry, kinds []classify.Kind) []classify.Entry
- func EntryID(tool string, e classify.Entry) string
- func ImageVersionsNote(t registry.ToolSpec) string
- func IsEOL(p *OutdatedPin) bool
- func ParseVulnSeverity(s string) (string, error)
- func Values() []string
- type Audit
- func (a *Audit) ApplyEnrichment(results map[string]enrich.Result, unresolved []scan.Pin)
- func (a *Audit) AtSeverity(rating string) *Audit
- func (a *Audit) EnrichRequests(resolve ResolveFunc, versions VersionsFunc) []enrich.Request
- func (a *Audit) Failed() []*OutdatedPin
- func (a *Audit) Feeds() Feeds
- func (a *Audit) Fixes() []ToolFix
- func (a *Audit) Open() bool
- func (a *Audit) SetFeeds(f Feeds)
- type AuditFinding
- type AuditRequest
- type Auditor
- type Behind
- type Cell
- type CellValue
- type Claim
- type Digest
- type DigestRequest
- type Digester
- func (d *Digester) Digest(ctx context.Context, req DigestRequest) (*ToolDigest, error)
- func (d *Digester) TestSources(ctx context.Context, req DigestRequest) (*SourceTest, error)
- func (d *Digester) Universe(ctx context.Context, t registry.ToolSpec) (*version.Universe, error)
- func (d *Digester) WithHosts(hosts HostClient) *Digester
- type Drift
- type DriftPin
- type DriftRequest
- type DriftTool
- type DriftVersion
- type Drifter
- type Feeds
- type Finding
- type FindingFix
- type Gate
- type GitHub
- type HostClient
- type Match
- type MaxBehind
- type Outdated
- type OutdatedPin
- type OutdatedRequest
- type Outdater
- type PinChange
- type RecentLister
- type ResolveFunc
- type SourceResult
- type SourceTest
- type Status
- type Summary
- type TagLister
- type ToolDigest
- type ToolFix
- type Unchecked
- type Version
- type VersionsFunc
Constants ¶
const ( FailOnBreaking = "breaking" FailOnDeprecation = "deprecation" FailOnEOL = "eol" FailOnVuln = "vuln" FailOnDrift = "drift" FailOnOutdated = "outdated" FailOnUnchecked = "unchecked" FailOnKEV = "kev" )
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 AdvisoryURL = "https://osv.dev/vulnerability/"
AdvisoryURL is the osv.dev page of an advisory ID.
const SummaryNotice = "LLM-generated, verify against cited sources"
SummaryNotice labels every LLM summary in every format.
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 ChartVersionsNote ¶ added in v0.11.0
ChartVersionsNote explains why a registry.UniverseChart tool has versions but no notes.
func EntriesOf ¶ added in v0.4.0
EntriesOf returns the entries of the given kinds in a new slice, or entries itself when kinds is empty.
func EntryID ¶ added in v0.4.0
EntryID returns the ID of an entry: e- and 8 hex digits of a hash over the tool, the version and the entry's normalized text, the same key that drops repeated entries.
func ImageVersionsNote ¶ added in v0.11.0
ImageVersionsNote explains why a registry.UniverseImage tool has versions but no notes.
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 Audit ¶ added in v0.13.0
type Audit struct {
Repos []string `json:"repos"`
Checked int `json:"checked"` // tool versions OSV answered for
Findings []AuditFinding `json:"findings"`
// Suppressed are the findings a vulns.ignore entry or an OpenVEX statement suppresses. They
// don't count for --fail-on.
Suppressed []AuditFinding `json:"suppressed"`
Unchecked []Unchecked `json:"unchecked"`
// OldestAnswer is when the oldest OSV answer of an --offline run was stored in the cache.
OldestAnswer *time.Time `json:"oldest_answer,omitempty"`
// contains filtered or unexported fields
}
Audit is the data of `relgap audit --format json`.
func ParseAudit ¶ added in v0.13.0
ParseAudit reads the data of a saved `relgap audit --format json` report. The report has the fix targets and feed columns its findings carry. A tool version whose every finding has no fix keeps only the advisories no release fixes, since JSON holds no target for it, and pins whose version lookup failed are only in the envelope's errors.
func (*Audit) ApplyEnrichment ¶ added in v0.13.0
ApplyEnrichment lists the unchecked pins, adding unresolved, the pins that resolve to no tool, and turns each advisory that affects a checked version into a finding, or into a suppressed one. Both lists sort KEV entries first, then by severity, rated before unrated, then by EPSS score, then by ID, tool and version.
func (*Audit) AtSeverity ¶ added in v0.13.0
AtSeverity returns the report with only the findings and suppressed findings rated rating or higher, and those of unknown severity, which reach every threshold. An empty rating keeps all.
func (*Audit) EnrichRequests ¶ added in v0.13.0
func (a *Audit) EnrichRequests(resolve ResolveFunc, versions VersionsFunc) []enrich.Request
EnrichRequests returns one request per tool and version among the pins; see Outdated.EnrichRequests.
func (*Audit) Failed ¶ added in v0.13.0
func (a *Audit) Failed() []*OutdatedPin
Failed returns the pins whose version lookup failed, which leaves them unchecked.
func (*Audit) Fixes ¶ added in v0.13.0
Fixes returns the fix target of each tool version with findings, in the order of their first finding. A tool version whose target relgap couldn't work out is left out.
func (*Audit) Open ¶ added in v0.13.0
Open reports whether a saved audit has something to report: a finding, or a pin that a failure, --offline or a name that resolves to no tool left unchecked. A pin no advisory source covers, such as an image or a chart, doesn't count, since nearly every repository has one.
type AuditFinding ¶ added in v0.13.0
type AuditFinding struct {
Tool string `json:"tool"`
Version string `json:"version"`
Pins []scan.Location `json:"pins"`
ID string `json:"id"`
Aliases []string `json:"aliases,omitempty"`
Summary string `json:"summary,omitempty"`
Package enrich.Package `json:"package"`
Severity *enrich.Score `json:"severity,omitempty"`
FixedIn string `json:"fixed_in,omitempty"` // lowest fixed version above Version
Fix FindingFix `json:"fix,omitzero"`
URL string `json:"url"`
// Suppressed says why the finding doesn't count; only findings in [Audit.Suppressed] have it.
Suppressed *enrich.Suppression `json:"suppressed,omitempty"`
KEV *enrich.KEV `json:"kev,omitempty"` // with --kev, when a CVE alias is in the catalog
EPSS *enrich.EPSS `json:"epss,omitempty"` // with --epss, when EPSS scores a CVE alias
// contains filtered or unexported fields
}
AuditFinding is one advisory that affects one tool version, with every pin of that version.
func (*AuditFinding) PURL ¶ added in v0.13.0
func (f *AuditFinding) PURL() string
PURL returns the package URL of the finding's package at its version, or "" when the ecosystem has no purl type.
type AuditRequest ¶ added in v0.13.0
type AuditRequest struct {
Repos []string
Pins []scan.Pin // resolved pins only
Resolve ResolveFunc
Concurrency int
}
AuditRequest says which pins to audit.
type Auditor ¶ added in v0.13.0
type Auditor struct {
// contains filtered or unexported fields
}
Auditor finds the version each pin stands for, the CURRENT of `relgap outdated`, without looking up latest versions or digests.
func NewAuditor ¶ added in v0.13.0
func NewAuditor(digester *Digester, recent RecentLister) *Auditor
NewAuditor returns an auditor that lists a tool's versions through digester, and its newest releases through recent, only for pins that aren't exact.
func (*Auditor) Audit ¶ added in v0.13.0
Audit returns the pins with their versions, ready for Audit.EnrichRequests. An exact pin is its own version and costs no request, and an image or chart pin is unchecked without a lookup (see enrich.NameReason). It returns an error only for a failure that affects every tool, such as a rejected token.
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"`
Summary *Summary `json:"summary,omitempty"` // only with --summarize
}
Digest is the data of `relgap digest --format json`.
type DigestRequest ¶
type DigestRequest struct {
ID string // the tool's identity; empty means the spec's name
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 and the other git hosts.
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.
func (*Digester) WithHosts ¶ added in v0.11.0
func (d *Digester) WithHosts(hosts HostClient) *Digester
WithHosts returns d reading tools on other git hosts through hosts.
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 Feeds ¶ added in v0.13.0
type Feeds struct {
KEV, EPSS bool
}
Feeds says which prioritization feeds a run asked: CISA KEV and FIRST EPSS.
type Finding ¶
type Finding struct {
FailOn string
Pin *OutdatedPin
Vuln *enrich.Vuln // the advisory, for vuln and kev in outdated
Digest *ToolDigest // for breaking and deprecation in a single digest
Drift *DriftTool // the tool of a drifted pin
Advisory *AuditFinding // for vuln and kev in audit
Unchecked *Unchecked // for unchecked
}
Finding is one thing a --fail-on value counts: a pin, an advisory of a pin, a digest, a drifted pin, an audit finding or an unchecked tool version.
type FindingFix ¶ added in v0.13.0
FindingFix is a finding's fix target: the tool version's enrich.Fix, null when no release fixes the advisory, and absent when relgap couldn't work it out.
func (FindingFix) IsZero ¶ added in v0.13.0
func (f FindingFix) IsZero() bool
IsZero reports whether relgap couldn't work the fix target out, which leaves it out of JSON.
func (FindingFix) MarshalJSON ¶ added in v0.13.0
func (f FindingFix) MarshalJSON() ([]byte, error)
MarshalJSON writes the target, or null.
func (*FindingFix) UnmarshalJSON ¶ added in v0.13.0
func (f *FindingFix) UnmarshalJSON(b []byte) error
UnmarshalJSON reads a target, or null for an advisory no release fixes. An absent field never calls it, which leaves the target unknown.
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
VulnFixable bool // --fail-on vuln counts only advisories with a fixed version above the current one
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 unsuppressed advisory that affects its current version at or above VulnSeverity, with a fixed version under VulnFixable. It counts for kev once per unsuppressed advisory in the KEV catalog, whatever its rating. It counts for outdated, breaking and deprecation only when it is behind latest.
func (Gate) CheckAudit ¶ added in v0.13.0
CheckAudit returns a finding per audit finding at or above VulnSeverity, and with a fixed version under VulnFixable, for vuln, per audit finding in the KEV catalog for kev, and per unchecked tool version for unchecked.
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 HostClient ¶ added in v0.11.0
HostClient returns the client of a git host other than GitHub, such as bitbucket.org.
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"`
Unchecked []Unchecked `json:"unchecked,omitzero"` // after enrichment; empty when OSV checked every pin
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, vulnerabilities, fix target and unchecked reason of each pin, and lists the unchecked pins, adding unresolved, the pins that resolve to no tool.
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, versions VersionsFunc) []enrich.Request
EnrichRequests returns one request per tool and version among the pins, with the latest version as the target and versions for the fix target (nil skips it). A pin is checked at Current, or at its own version when it is exact and its lookup failed. A pin without such a version gets its unchecked reason here.
type OutdatedPin ¶
type OutdatedPin struct {
Tool string `json:"tool"`
Repo string `json:"repo,omitempty"` // GitHub owner/name, or the project path on Host
Host string `json:"host,omitempty"` // the host of Repo when it isn't github.com
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 are the known vulnerabilities of Current, empty when OSV has none. Absent when OSV
// wasn't asked (see Unchecked) or enrichment didn't run.
Vulns []enrich.Vuln `json:"vulns,omitzero"`
Unchecked string `json:"unchecked,omitempty"` // an enrich.Reason* constant saying why OSV wasn't asked
// Fix is the release Current can move to. Absent without a vulnerability of Current, or when
// the version list or OSV failed.
Fix *enrich.Fix `json:"fix,omitempty"`
// Digest is the digest Counts come from; pins with the same tool and Current share it.
Digest *ToolDigest `json:"-"`
// contains filtered or unexported fields
}
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 PinChange ¶ added in v0.11.0
type PinChange struct {
Repo string `json:"repo"`
File string `json:"file"`
Line int `json:"line"`
RawName string `json:"raw_name"`
Base string `json:"base"`
Head string `json:"head"`
}
PinChange is one changed pin that a digest covers: where the head has it, its raw name, and its value on each side as written.
type RecentLister ¶
type RecentLister interface {
Recent(ctx context.Context, qs []github.RecentQuery) (map[github.RecentQuery]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 repository or registry relgap can read StatusError Status = "error" // the host failed for this tool )
Pin statuses.
type Summary ¶ added in v0.4.0
type Summary struct {
Notice string `json:"notice"` // always [SummaryNotice]
Provider string `json:"provider"`
Model string `json:"model"`
Risks []Claim `json:"risks"` // at most 5
Actions []Claim `json:"actions"` // required actions
Entries int `json:"entries"` // entries sent to the model
Trimmed int `json:"trimmed"` // entries left out to fit llm.max_input_tokens
Dropped int `json:"dropped"` // claims removed for citing no entry ID or an unknown one
}
Summary is the optional LLM summary of a digest. It is advisory: no gate reads it.
type TagLister ¶ added in v0.11.0
TagLister lists tags with their dates; the Bitbucket and GitLab clients implement it.
type ToolDigest ¶
type ToolDigest struct {
ID string `json:"id"` // the tool's identity: the name outdated prints in tool and digest accepts
Tool string `json:"tool"` // the short name of the tool's spec
Repo string `json:"repo"`
Host string `json:"host,omitempty"` // the host of Repo when it isn't github.com
Image string `json:"image,omitempty"` // registry/repository of an image tool
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"`
Pins []PinChange `json:"pins,omitempty"` // the changed pins a --base or --pull-request digest covers
}
ToolDigest is the digest of one tool over (From, To].
type Unchecked ¶ added in v0.13.0
type Unchecked struct {
Tool string `json:"tool"` // the pins' tool, or the name as written for a pin that resolves to none
Version string `json:"version"` // the version OSV would be asked about, else the value as written
Reason string `json:"reason"` // an enrich.Reason* constant
Pins []scan.Location `json:"pins"`
}
Unchecked is a tool version that OSV wasn't asked about, with every pin of it. relgap never reports it as clean.
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 release page, when there is a release
}
Version is one version in a digested range.
type VersionsFunc ¶ added in v0.13.0
VersionsFunc lists a tool's released versions; Digester.Universe is one.