Documentation
¶
Overview ¶
Package render selects output formats and writes the JSON envelope.
Index ¶
- Constants
- func DigestMarkdown(w io.Writer, d *report.Digest) error
- func DigestText(w io.Writer, d *report.Digest, color bool) error
- func DriftMarkdown(w io.Writer, d *report.Drift, o DriftOptions) error
- 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 OutdatedMarkdown(w io.Writer, o *report.Outdated) error
- 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 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" )
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 DefaultMDMaxChars = 60_000
DefaultMDMaxChars is the default --md-max-chars, under GitHub's 65,536-character cap on comments.
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 ToolName = "relgap"
ToolName is the value of the envelope's "tool" field.
Variables ¶
This section is empty.
Functions ¶
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.
func DigestText ¶
DigestText writes d as plain text, breaking changes first and entries grouped by version. 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 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 OutdatedMarkdown ¶
OutdatedMarkdown writes the pins as a Markdown table followed by notes.
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, and per pin or file that failed. Results don't depend on --fail-on. Rules are in --fail-on order, then failed, 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 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 )
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.