report

package
v0.55.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

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

This section is empty.

Functions

func Formats

func Formats() []string

Formats lists the available format names, sorted.

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

func SBOMArtifacts(docs []sbom.Document) []Artifact

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
	// 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 Reporter

type Reporter interface {
	Format() string
	Render(w io.Writer, d Data) error
}

Reporter renders Data in one format.

func For

func For(format string) (Reporter, error)

For returns the reporter for a format name.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL