Documentation
¶
Overview ¶
Package report renders a scan result in a chosen format. Each format is a Reporter over a common Data value, so the CLI (and, later, the branch diff) can emit console/markdown/HTML for humans, JUnit for CI test panels, and JSON/SARIF for machines through one interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var StreamFormats = []string{"console", "markdown", "json", "sarif", "template"}
StreamFormats are the formats `--format` accepts: the ones whose natural destination is a stream, so a terminal, a pipe or a redirect all make sense.
html and junit are deliberately absent. An HTML report is a styled document with its CSS inlined, and printing four thousand lines of it because someone typed a plausible-looking flag is not a thing to explain away — a JUnit file is read by a CI runner from a path, never by a person. Both are produced with --report into an output directory, which is the only place they were ever useful.
Narrow on purpose. Every format offered here is one a reader has to rule out.
Functions ¶
func StreamFormat ¶ added in v0.60.0
StreamFormat reports whether a format may be written to stdout, and if not, why.
Types ¶
type Artifact ¶ added in v0.21.0
type Artifact struct {
Format string // the reporter format, e.g. "sarif"
Filename string // default base filename, e.g. "results.sarif"
ContentType string // MIME type, e.g. "application/sarif+json"
Bytes []byte // the rendered report
}
Artifact is a rendered report plus the metadata a publisher needs to deliver it: a default filename, a MIME content type, and the bytes. It is the unit a Publisher (pkg/publish) delivers to a destination.
func Build ¶ added in v0.21.0
func Build(cfg saga.ReportConfig, d Data) (Artifact, error)
Build renders a report as configured and returns it as an Artifact ready to publish. The "template" format renders a user-supplied Go text/template (cfg.Template / cfg.TemplateFile); all other formats use the built-in reporter registry. cfg.Filename overrides the default output filename.
func SBOMArtifacts ¶ added in v0.41.0
SBOMArtifacts converts SBOM documents into the unit publishers deliver, so SBOMs travel the same path as every other output rather than needing their own delivery mechanism.
type ComponentVerdict ¶ added in v0.54.0
type ComponentVerdict struct {
Name string
// Verdict is the run's policy applied to this component's findings alone. Computed by
// running the same norn.Policy rather than re-deciding, so the parts cannot disagree with
// the whole about what failing means.
Verdict norn.Verdict
// Controls names the controls that failed for this component, in order.
Controls []string
// Priorities counts this component's findings by band, highest first (P1…P4).
Priorities [4]int
// Findings is the total, suppressed ones excluded — the same rule the counts follow.
Findings int
}
ComponentVerdict is one component's outcome, judged by the same policy as the run.
The unit a team owns, and the unit exposure and criticality are declared on — so the unit someone is actually deciding about. The controls table answers "is the project shippable", which is a different and usually less useful question than "is my service".
type Data ¶
type Data struct {
Release saga.Release
Run engine.Result
Verdict norn.Result
MinPriority string
// TopN caps how many findings the console "Fix first" table shows: 0 uses the default,
// a negative value shows all, and a positive value shows that many. Ignored by other formats.
TopN int
// Compact strips what only a human reads — indentation and relayed rule prose — from the
// machine formats (json, sarif), for a consumer that acts on the report rather than reads
// it. The human formats ignore it: making those harder to read is the opposite of the point.
Compact bool
// Generated and Version stamp a report with when it ran and what produced it. A report
// offered as evidence has to answer both; a reader who cannot tell whether they are looking
// at today's scan or last quarter's has nothing they can rely on. Zero values are omitted,
// so a caller that does not set them still renders a valid report.
Generated time.Time
Version string
// Components breaks the verdict down by the part of the application it belongs to, when
// there is more than one. Optional: a caller that does not compute it renders as before.
Components []ComponentVerdict
// Exploitability describes the feeds that enriched this run's severities, if any. Empty
// when no enrichment was configured, in which case nothing about it is rendered.
//
// A report that raised a finding to critical has to be able to say on what data, obtained
// when. "KEV said so" is not reproducible; "on KEV as of 2026-08-01" is.
Exploitability []FeedProvenance
// UnattributedFindings counts findings that belong to no component — a project-scoped
// control like `infrastructure` produces them. Reported alongside the component breakdown,
// because a breakdown that silently omits them makes the parts look like the whole.
UnattributedFindings int
}
Data is everything a reporter needs to render a scan.
type FeedProvenance ¶ added in v0.56.0
type FeedProvenance struct {
// Name is the signal: "kev" or "epss".
Name string
// URL is where the copy came from. Empty for a file the operator supplied, which is its own
// useful statement — the data was brought in by hand.
URL string
// FetchedAt is when it was obtained. Zero for a file path, which has no fetch to record.
FetchedAt time.Time
// SHA256 is the digest of the bytes that were read.
SHA256 string
// Stale reports that the copy was older than the run's configured maxAge. Recorded here and
// not only warned about in the logs, because the logs of the run that produced a report are
// exactly where nobody looks six weeks later.
Stale bool
}
FeedProvenance is one exploitability dataset as this run saw it.
type TemplateFinding ¶ added in v0.21.0
type TemplateFinding struct {
Priority string
Level string
Score string
Control string
Tool string
RuleID string
Message string
Location string
}
TemplateFinding is one finding as exposed to a template.
type TemplateView ¶ added in v0.21.0
type TemplateView struct {
Release saga.Release
Verdict string // "pass" | "fail"
Pass bool
Priorities struct{ P1, P2, P3, P4 int }
Controls []norn.ControlOutcome
Findings []TemplateFinding // ranked most-urgent first
}
TemplateView is the data model a "template" report renders against. It is the documented, stable surface for custom templates — a friendly, flattened view of a scan (no engine internals), leading with the verdict and prioritized findings.