Documentation
¶
Overview ¶
Package render selects output formats and writes the JSON envelope.
Index ¶
- Constants
- func AuditMarkdown(w io.Writer, a *report.Audit, failed []Error) error
- func AuditOpenVEX(w io.Writer, a *report.Audit, now time.Time, version string) error
- func AuditRules() []string
- func AuditSARIF(a *report.Audit, problems []scan.Problem, version string) *sarif.Log
- func AuditText(w io.Writer, a *report.Audit, color bool) error
- func DigestMarkdown(w io.Writer, d *report.Digest, failed []Error, notes []string) error
- func DigestText(w io.Writer, d *report.Digest, color bool) error
- func DriftMarkdown(w io.Writer, d *report.Drift, o DriftOptions) error
- func DriftRules() []string
- func DriftSARIF(d *report.Drift, problems []scan.Problem, version string) *sarif.Log
- func DriftText(w io.Writer, d *report.Drift, o DriftOptions) error
- func JSON(w io.Writer, v any) error
- func LatestAffected(f *enrich.Fix) string
- func OutdatedMarkdown(w io.Writer, o *report.Outdated) error
- func OutdatedRules() []string
- func OutdatedSARIF(o *report.Outdated, problems []scan.Problem, version string) *sarif.Log
- func OutdatedText(w io.Writer, o *report.Outdated, color bool) error
- func PinLocation(l scan.Location) string
- func PinsMarkdown(w io.Writer, pins []scan.Pin, unresolved bool) error
- func PinsText(w io.Writer, pins []scan.Pin, unresolved bool) error
- func SARIFRule(id string) sarif.Rule
- func SourceTestText(w io.Writer, t *report.SourceTest) error
- func TruncateMarkdown(md string, limit int, hint string) string
- func UseColor(mode ColorMode, lookup func(string) (string, bool), isTTY bool) bool
- type ColorMode
- type DriftOptions
- type Envelope
- type Error
- type Format
- type Output
- type Page
- type Sink
- type WriteFunc
Constants ¶
const ( RuleBreaking = "breaking" RuleDeprecation = "deprecation" RuleEOL = "eol" RuleDrift = "drift" RuleOutdated = "outdated" RuleFailed = "failed" RuleUnchecked = "unchecked" )
SARIF rule IDs. A vulnerability's rule ID is its OSV ID.
const ApproxMark = "≈"
ApproxMark prefixes a pin value that allows more than one version.
const AuditUncheckedTitle = "Not checked for vulnerabilities"
AuditUncheckedTitle heads audit's list of tool versions OSV wasn't asked about.
const DefaultMDMaxChars = 60_000
DefaultMDMaxChars is the default --md-max-chars, under GitHub's 65,536-character cap on comments.
const FixTitle = "Fix targets"
FixTitle heads the list of fix targets.
const InfoURI = "https://github.com/sassdavid/relgap"
InfoURI is the tool's home page in SARIF logs.
const SchemaVersion = "1"
SchemaVersion is the envelope version in schemas/report-v1.json.
const SuppressedTitle = "Suppressed"
SuppressedTitle heads the list of advisories a vulns.ignore entry or VEX statement suppresses.
const ToolName = "relgap"
ToolName is the value of the envelope's "tool" field.
const UncheckedTitle = "Not checked for vulnerabilities (VULNS ?)"
UncheckedTitle heads the list of pins OSV wasn't asked about.
Variables ¶
This section is empty.
Functions ¶
func AuditMarkdown ¶ added in v0.13.0
AuditMarkdown writes the findings as a Markdown table with the same sections as AuditText. Mentions and issue references in advisory summaries are silenced. failed are the envelope errors of a saved report, listed under "Failed"; a report fresh from a run passes nil, since its pins carry their failures.
func AuditOpenVEX ¶ added in v0.13.0
AuditOpenVEX writes the findings as an OpenVEX v0.2.0 document issued at now, one statement per advisory and tool version: affected with the fix target as the action statement, and the suppressed ones with the status that suppresses them, not_affected for a vulns.ignore entry. Products are the purls of the advisories' packages at the tool versions.
func AuditRules ¶ added in v0.13.0
func AuditRules() []string
AuditRules returns the IDs of the fixed rules in audit's SARIF, in their order there.
func AuditSARIF ¶ added in v0.13.0
AuditSARIF returns a SARIF log with a result per finding and pin location, the suppressed ones marked with a suppression, per tool version OSV wasn't asked about and pin location, per pin whose version lookup failed and per file that didn't parse. Results don't depend on --fail-on. Rules are failed and unchecked, then one rule per OSV ID.
func AuditText ¶ added in v0.13.0
AuditText writes the findings as an aligned table, then the advisories, the fix targets, the suppressed findings, the unchecked tool versions and a summary. With color it marks high and critical ratings red (the tty format).
func DigestMarkdown ¶
DigestMarkdown writes d as PR-ready Markdown: counts, then breaking changes and security entries of every version, then one <details> block per version with the other kinds. A "Not digested" section, which lists failed digests and pins without a digest, comes first so truncation never cuts it, then a --summarize summary labelled as LLM output.
func DigestText ¶
DigestText writes d as plain text, breaking changes first and entries grouped by version. A --summarize summary comes first, labelled as LLM output. With color it adds ANSI bold headings and red breaking changes (the tty format).
func DriftMarkdown ¶
DriftMarkdown writes the matrix as a Markdown table, the tools left out as a list and a summary.
func DriftRules ¶ added in v0.7.0
func DriftRules() []string
DriftRules returns the IDs of the rules in drift's SARIF, in their order there.
func DriftSARIF ¶
DriftSARIF returns a SARIF log with a result per drifted pin (a compared pin whose version differs from its tool's reference version), per file that didn't parse and per tool whose latest version couldn't be listed.
func DriftText ¶
DriftText writes the matrix (a row per repo, a column per drifting tool), the tools left out and a summary.
func LatestAffected ¶ added in v0.13.0
LatestAffected is the warning for a fix target whose latest release still has advisories, such as "latest 1.35.0 still has GO-2025-3521".
func OutdatedMarkdown ¶
OutdatedMarkdown writes the pins as a Markdown table followed by notes.
func OutdatedRules ¶ added in v0.7.0
func OutdatedRules() []string
OutdatedRules returns the IDs of the fixed rules in outdated's SARIF, in their order there.
func OutdatedSARIF ¶
OutdatedSARIF returns a SARIF log with a result per pin behind latest, per pin on an EOL cycle, per pin whose upgrade has breaking changes or deprecations, per advisory that affects a pin, per pin or file that failed, and per pin OSV wasn't asked about. Results don't depend on --fail-on. Rules are in --fail-on order, then failed and unchecked, then one rule per OSV ID.
func OutdatedText ¶
OutdatedText writes the pins as an aligned table followed by notes. With color it marks outdated versions yellow, current ones green and breaking counts red (the tty format). Skipped pins are left out; JSON lists them.
func PinLocation ¶
PinLocation formats a location as repo/file:line, leaving out a "." repo and a zero line.
func PinsMarkdown ¶
PinsMarkdown writes pins as a Markdown table.
func PinsText ¶
PinsText writes pins as an aligned table. unresolved swaps the TOOL column for RAW NAME.
func SARIFRule ¶ added in v0.7.0
SARIFRule returns the rule with id, one of the Rule constants, or a zero rule.
func SourceTestText ¶
func SourceTestText(w io.Writer, t *report.SourceTest) error
SourceTestText writes what each source of a registry entry produced as an aligned table, followed by the documents, warnings and errors of each source.
func TruncateMarkdown ¶ added in v0.2.0
TruncateMarkdown returns md cut to at most limit characters (Unicode code points). It cuts between table rows, list items and sections, and ends with a footer that counts what was cut and names the first cut section. A limit of 0 or less, or md within the limit, returns md.
Types ¶
type ColorMode ¶
type ColorMode string
ColorMode is the --color flag value.
const ( ColorAuto ColorMode = "auto" ColorAlways ColorMode = "always" ColorNever ColorMode = "never" )
Color modes.
func ParseColorMode ¶
ParseColorMode validates a --color value.
type DriftOptions ¶
type DriftOptions struct {
All bool // a column for every tool, drifting or not
Color bool // yellow outliers (the tty format)
}
DriftOptions says how to lay out the drift matrix.
type Envelope ¶
type Envelope struct {
SchemaVersion string `json:"schema_version"`
Tool string `json:"tool"`
Version string `json:"version"`
GeneratedAt time.Time `json:"generated_at"`
Data any `json:"data"`
Errors []Error `json:"errors"`
Page *Page `json:"page,omitempty"` // set by the MCP server when it splits a result
}
Envelope wraps every JSON output.
type Format ¶
type Format string
Format is an output format selected with --format.
const ( FormatAuto Format = "" FormatTTY Format = "tty" FormatPlain Format = "plain" FormatMD Format = "md" FormatJSON Format = "json" FormatCSV Format = "csv" FormatSARIF Format = "sarif" FormatGitHub Format = "github" // GitHub Actions workflow commands, which show as annotations FormatOpenVEX Format = "openvex" // an OpenVEX v0.2.0 document )
Output formats. FormatAuto resolves to tty or plain depending on stdout.
func OutFormats ¶ added in v0.2.0
func OutFormats() []Format
OutFormats lists the formats --out accepts. tty is left out because a file is never a terminal.
func ParseFormat ¶
ParseFormat validates a --format value. The empty string means auto.
type Output ¶ added in v0.2.0
Output is one --out value: a format and the file it goes to.
func ParseOutputs ¶ added in v0.2.0
ParseOutputs validates --out values of the form format=path.
type Page ¶
type Page struct {
Items string `json:"items"` // what was split, such as "entries"
Returned int `json:"returned"` // items in this page
Total int `json:"total"` // items in the whole result
NextCursor string `json:"next_cursor,omitempty"` // empty on the last page
}
Page says which part of a split result an envelope holds.