report

package
v4.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package report turns scan findings into what a person reads and what a pipeline greps.

One Report, several renderers. The model is built once from the enriched findings, the dependency graphs, any defence lookups and any recorded compensating controls; the packages, findings, tree, plain and GitHub renderers all read it. A wording change lands everywhere at once, and the renderers cannot disagree about what a package's urgency or fix is, because neither is computed in a renderer.

The unit is the package, not the advisory. Nobody upgrades an advisory: they upgrade a package, once, to a version that clears every advisory on it.

Index

Constants

View Source
const (
	ViewAuto     = "auto"
	ViewPackages = "packages"
	ViewFindings = "findings"
	ViewTree     = "tree"
	ViewTable    = "table"
	ViewPlain    = "plain"
	ViewJSON     = "json"
)

Views are the names `--view` accepts. "table" is the legacy eighteen-column table; it is drawn by the scan command itself and never reaches this package.

View Source
const JSONSchema = "vulnetix/report/v1"

JSONSchema names the shape RenderJSON emits. It changes only by adding fields.

Variables

View Source
var (
	Views       = []string{ViewAuto, ViewPackages, ViewFindings, ViewTree, ViewTable, ViewPlain, ViewJSON}
	FilterNames = []string{"kev", "exploited", "reachable", "fixable", "nofix", "defended", "unprotected", "direct", "transitive"}
	ShowParts   = []string{"paths", "files", "clean", "scores", "defences", "tests"}
	HideParts   = []string{"fixes", "exploits", "defences", "not-affected"}
	SortKeys    = []string{"threat", "severity", "package"}
)

Allowed values for the list-valued flags. They are the single source for both validation and shell completion.

Functions

func AttachDefences

func AttachDefences(r *Report, found map[string]defences.Summary, checked bool, reason string)

AttachDefences records lookup results on the no-fix packages. found is keyed by the identifier that was looked up; a package whose advisories were never indexed gets StateNotIndexed rather than being left silent.

func BuildSARIF

func BuildSARIF(r Report, root, toolVersion string) *sarif.Log

BuildSARIF returns the report's SCA findings as a single-run SARIF log with the code scanning category vulnetix/sca/. root is the scan root the package sources are relative to; it is read only to find the declaring line.

func DefenceIDs

func DefenceIDs(r Report) []string

DefenceIDs lists the identifiers worth looking up: one entry per indexed advisory on each package that has no fix. Duplicates are removed.

func MergeSummaries

func MergeSummaries(id string, in []defences.Summary) defences.Summary

MergeSummaries combines per-advisory summaries into one for the package.

func ParseList

func ParseList(values ...string) []string

ParseList splits a comma-separated flag value.

func Render

func Render(view string, r Report, o Options, t *display.Terminal) string

Render dispatches on the resolved view.

func RenderBinaries

func RenderBinaries(b BinarySummary, o Options, t *display.Terminal) string

RenderBinaries draws the ELF pass as one section in the container report's grammar. It is a summary of what the files are, not a list of findings: the malware verdict and the packages inside travel on their own channels.

func RenderCode

func RenderCode(r CodeReport, o Options, t *display.Terminal) string

RenderCode draws code findings in the packages view's grammar: a verdict line, then the rules grouped by what to do, then the next commands.

func RenderCodeExplain

func RenderCodeExplain(r CodeReport, query string, o Options, t *display.Terminal) (string, bool)

RenderCodeExplain shows the rule behind a finding and every place it fired: production code first, grouped by file, then test code. A file path query explains each rule that fired in that file.

func RenderCodeGitHub

func RenderCodeGitHub(r CodeReport) string

RenderCodeGitHub emits workflow-command annotations, one per finding, on the file and line.

func RenderCodePlain

func RenderCodePlain(r CodeReport, o Options, t *display.Terminal) string

RenderCodePlain is the pipe and CI form: one line per finding, worst first.

func RenderDefend

func RenderDefend(v DefendView, o Options, t *display.Terminal) string

RenderDefend draws the read view: what exists, in which lane, how sure the rule is, how it should be started, and what it does not cover. Block and detect are separate sections, because one stops the request and the other only tells you it happened.

func RenderExplain

func RenderExplain(r Report, query string, o Options, t *display.Terminal) (string, bool)

RenderExplain shows the working behind each matching finding. It returns false when nothing matched.

func RenderFindings

func RenderFindings(r Report, o Options, t *display.Terminal) string

RenderFindings is the flat view: one line per advisory, grouped like the packages view but without collapsing a package's advisories.

func RenderGitHub

func RenderGitHub(r Report) string

RenderGitHub emits workflow commands that GitHub Actions turns into annotations on the manifest line, one per package. Findings that need action are errors, the rest warnings, and anything with a recorded control a notice.

func RenderJSON

func RenderJSON(r Report) ([]byte, error)

RenderJSON is the machine-readable view: every package with its group, fix and, for each advisory, the verdict and the working behind it. Findings the verdict rules out are included under ruledOut; nothing is dropped.

func RenderMalscan

func RenderMalscan(m MalscanReport, o Options, t *display.Terminal) string

RenderMalscan draws a malware scan in the same grammar as the other scanners. A scan that checked nothing never reads as clean.

func RenderPackages

func RenderPackages(r Report, o Options, t *display.Terminal) string

RenderPackages draws the default view: a verdict, then packages grouped by what to do about them, then the next command.

func RenderPlain

func RenderPlain(r Report, o Options, t *display.Terminal) string

RenderPlain is the pipe and CI renderer: one line per package, stable columns, ASCII only. It is a documented output format, so scripts may rely on it.

func RenderTree

func RenderTree(r Report, o Options, t *display.Terminal) string

RenderTree groups packages under the manifest that declared them.

func ResolveView

func ResolveView(o Options, t *display.Terminal, ci bool) string

ResolveView picks the renderer. An explicit --view wins; otherwise a pipe, a file or CI gets the plain renderer and a person at a terminal gets packages.

func Set

func Set(values []string) map[string]bool

Set turns a parsed list into a membership set.

func SevWord

func SevWord(level string) string

SevWord is the fixed-width uppercase severity word.

func SortedNames

func SortedNames(m map[string]bool) []string

SortedNames returns the keys of a set in a stable order, for messages.

func StepSummary

func StepSummary(r Report) string

StepSummary renders the report as Markdown for $GITHUB_STEP_SUMMARY.

func Validate

func Validate(flag string, values, allowed []string) error

Validate reports the first value not in allowed, naming every valid one so a typo costs one read instead of a trip to the help text.

Types

type Advisory

type Advisory struct {
	ID       string
	Severity string // normalised: critical high medium low info
	CVSS     float64
	EPSS     float64
	KEV      bool
	Exploits int
	Verdict  scan.VerdictResult
	Signals  []Signal
	// Reach is the raw reachability outcome; ReachAt is a file:line when known.
	Reach   string
	ReachAt string
	// Fix is the version this advisory alone recommends, if any.
	Fix string
	// FixSource says where Fix came from: "recommended" or "advisory" (the upper
	// bound of its affected range).
	FixSource string
	// AnyUpgrade is set when moving to any other version clears this advisory.
	AnyUpgrade bool
	// FixAvailability is the server's word: available, partial, no_fix.
	FixAvailability string
	// AlsoKnownAs lists the other identifiers of the same vulnerability that were
	// folded into this one (see foldAliases).
	AlsoKnownAs []string
	Ev          scan.EnrichedVuln
}

Advisory is one vulnerability on one package.

type BinaryRow

type BinaryRow struct {
	Path       string
	Weaknesses []string
	// Package is the OS package that installed it, when the lookup knew.
	Package string
}

BinaryRow is one ELF file the container scan inspected.

type BinarySummary

type BinarySummary struct {
	Files  int // everything walked
	Rows   []BinaryRow
	Errors []string
}

BinarySummary is the ELF pass of a container scan, ready to draw.

type CodeFinding

type CodeFinding struct {
	RuleID   string
	Name     string
	Severity string
	Kind     string // sast | secrets | iac | oci
	Path     string
	Line     int
	EndLine  int
	Message  string
	// Snippet is the matched source. It is never printed for secrets.
	Snippet     string
	Description string
	HelpURI     string
	CWE         []int
	TestSuite   bool

	// Resource is the thing the finding sits in: "aws_s3_bucket.logs",
	// "Deployment/api", "service api". ResourceLine is where it starts. The
	// caller reads both from the file; they are empty where a file has no such
	// notion.
	Resource     string
	ResourceLine int

	// Where a secret entered the history, from git blame. Blamed is false when
	// nothing could be asked (not a git tree), so "unknown" is never "clean".
	Blamed bool
	// InHistory marks a copy found in a past commit, not in the working tree.
	InHistory   bool
	Committed   bool
	Commit      string
	CommittedAt time.Time
}

CodeFinding is one finding from the rule engine: static analysis, secrets, infrastructure as code or container files. They share a layout because they share a shape: a place in a file, a rule, a message.

func FindCodeExplain

func FindCodeExplain(r CodeReport, query string) []CodeFinding

FindCodeExplain returns the findings a --explain query names: a rule id, or a file path.

type CodeReport

type CodeReport struct {
	Findings []CodeFinding
	// Label names what ran: "SAST", "Secrets", "IaC", "Containers".
	Label       string
	RulesLoaded int
	RulesTotal  int
}

CodeReport is the engine's result, ready to draw.

type Counts

type Counts struct {
	Advisories int
	Packages   int
	ByGroup    map[Group]int
}

Counts is the header's partition. Every package with a counting advisory is in exactly one of Action, Wait, Protected, Monitored, so the numbers add up.

type DefendView

type DefendView struct {
	PackageLabel string
	ID           string
	Fix          Fix
	// Exploit is a one-line description of the public exploit, when known.
	Exploit string
	Summary defences.Summary
	// Fits are the enforcement points inferred from the repository.
	Fits map[defences.Kind]defences.Hint
}

DefendView is everything `vulnetix defend` shows for one finding.

type Fix

type Fix struct {
	State FixState
	// Target is the version to move to. Empty with FixAvailable means a fix is
	// reported to exist but its version was not given.
	Target string
	// Clears and Of describe a partial fix: "2 of 3".
	Clears, Of int
}

Fix is the lowest version that clears the package's advisories.

type FixState

type FixState int

FixState is the package-level answer to "how do I fix it".

const (
	// FixUnknown means the data carried no remediation either way.
	FixUnknown FixState = iota
	// FixAvailable means one version clears every advisory.
	FixAvailable
	// FixPartial means a version clears some advisories and not all.
	FixPartial
	// FixNone means no version clears any advisory.
	FixNone
)

type Group

type Group string

Group says what to do about a package, which is not the same as how severe it is. A critical advisory nothing reaches can wait; a medium one under active exploitation cannot.

const (
	// GroupAction is exploited, reachable, on a KEV list or malicious.
	GroupAction Group = "action"
	// GroupWait is affected but with no signal that raises urgency.
	GroupWait Group = "wait"
	// GroupUnverified is matched by name where the advisory's range cannot be
	// compared with the installed version (a git commit, say). It still counts:
	// unknown is not safe. It does not claim urgency, because nobody has
	// established the package is affected at all.
	GroupUnverified Group = "unverified"
	// GroupProtected has an unexpired recorded control that blocks the request.
	// It is still affected, and still counted.
	GroupProtected Group = "protected"
	// GroupMonitored has an unexpired recorded control that only detects, or a
	// blocking rule still in log-only mode. It stops nothing.
	GroupMonitored Group = "monitored"
	// GroupNotAffected was matched by name and ruled out by version.
	GroupNotAffected Group = "not_affected"
)

func (Group) Title

func (g Group) Title() string

Title is the group's heading.

type Input

type Input struct {
	Vulns    []scan.EnrichedVuln
	Groups   []scan.ManifestGroup
	Controls defences.ControlSet
	Meta     Meta
	// Strict counts not-affected and likely-not-affected findings anyway.
	Strict bool
	Now    time.Time
}

Input is everything Build needs. Nothing in it is read from the environment.

type MalscanFinding

type MalscanFinding struct {
	Ecosystem string
	Package   string // "" when the file belongs to no package
	Location  string // where the package is installed: "node_modules"
	Title     string
	RuleID    string
	File      string
	Line      int
	Snippet   string
	Severity  string
	// Class is the engine's grade of the evidence: "evidence" convicts a package,
	// "trigger" and "context" only make it worth a look.
	Class    string
	IOCType  string
	IOCValue string
}

MalscanFinding is one piece of evidence from the malware scan, attributed to the installed package it was found in.

type MalscanReport

type MalscanReport struct {
	Findings []MalscanFinding
	Targets  []MalscanTarget
	// Indicators is how many known-bad indicators were loaded to compare with.
	Indicators int
	// FeedsEnabled is false under --no-ioc-feeds, when zero indicators is chosen.
	FeedsEnabled bool
	IncludeHome  bool
	Warnings     []string
}

MalscanReport is a malware scan, ready to draw.

type MalscanTarget

type MalscanTarget struct {
	Ecosystem  string
	Label      string
	UserScoped bool
	Packages   int
	Files      int
}

MalscanTarget is one place dependencies are installed and what was checked in it.

type Meta

type Meta struct {
	ScannedPackages int
	Manifests       int
	// Kinds are the scanners that ran: "sca", "sast", ...
	Kinds   []string
	Elapsed time.Duration
	// VEXSuppressed is how many findings third-party VEX closed.
	VEXSuppressed int
	// Unchecked are packages the advisory lookup could not answer for after retries.
	// A report that omits them is incomplete, and must not read as "clean".
	Unchecked []string
	// Strict records that not-affected findings were counted anyway.
	Strict bool
}

Meta is run context for the header.

type Options

type Options struct {
	View        string
	Filters     []string
	MinSeverity string
	Sort        string
	Show, Hide  map[string]bool
	// Verbosity is 0 normally, 1 for -v, 2 for -vv.
	Verbosity int
	Quiet     bool
	ASCII     bool
	// Width forces a width; zero uses the terminal's.
	Width int
	Now   time.Time
	// Command names the subcommand in plain output: "scan", "sca", and so on.
	Command string
	// RulePacks maps an upper-cased rule id to the external pack ("org/repo")
	// that supplied it; an embedded rule maps to "". A suggested command loads
	// the pack again, or the rule it names never runs.
	RulePacks map[string]string
	// Replay holds, per scanner, the input flags this run was given that a
	// suggested command must repeat to see the same thing (--path, --exclude,
	// --rule-registry, ...), already filtered to the flags that scanner takes.
	// --rule is not in it: packs come from RulePacks.
	Replay map[string][]string
}

Options shape what is shown. None of them changes what is found, counted in JSON or SARIF, or gated: they are about the terminal.

type Package

type Package struct {
	Name, Version, Ecosystem, Scope string
	// Source is the manifest (or image, or pipeline file) that declared it.
	Source string
	// MoreSources counts further manifests that declare the same package.
	MoreSources int
	Direct      bool
	// Via is the chain from a direct dependency to this one, excluding it.
	Via       []string
	Severity  string
	Malicious bool
	// Advisories are those that count: affected or unverified, worst first.
	Advisories []Advisory
	// RuledOut are advisories matched by name and excluded by version.
	RuledOut []Advisory
	Fix      Fix
	Signals  []Signal
	Group    Group

	// Defence is set only for packages with no fix, and only when asked.
	Defence *defences.Summary
	// DefenceID is the identifier the defence lookup used.
	DefenceID string
	// Controls are the unexpired recorded controls covering this package.
	Controls []defences.Control
	// Lapsed is a recorded control that has expired, if one was found.
	Lapsed *defences.Control
	// Covered reports that every counted advisory has an active control.
	Covered bool
	// contains filtered or unexported fields
}

Package is one dependency and everything known about its problems.

func FindExplain

func FindExplain(r Report, query string) []Package

FindExplain returns the packages (and the advisory, when the query named one) that a --explain query refers to. The query is an advisory id, a package name or name@version, compared case-insensitively. The report passed in must be the unfiltered one: explaining a finding the display filters hid is the point.

func Unprotected

func Unprotected(r Report) []Package

Unprotected lists the packages with no fix and no recorded, unexpired control: the "no fix and no plan" set that `--fail-on unprotected` fails on.

func (Package) Label

func (p Package) Label() string

Label is "name version".

func (Package) Top

func (p Package) Top() Advisory

Top is the advisory to name when only one fits.

type Report

type Report struct {
	Packages []Package
	Meta     Meta
}

Report is the whole result.

func Apply

func Apply(r Report, o Options) Report

Apply returns the report with the display options applied: filtered, hidden and sorted. The input is not modified.

func Build

func Build(in Input) Report

Build assembles the report. It performs no I/O.

func (Report) Counts

func (r Report) Counts() Counts

Counts tallies the report.

func (Report) InGroup

func (r Report) InGroup(g Group) []Package

InGroup returns the packages of one group in print order.

func (Report) NoFix

func (r Report) NoFix() []Package

NoFix returns the packages whose advisories have no fix.

func (*Report) Resort

func (r *Report) Resort(key string)

Resort reorders the report's packages by "threat", "severity" or "package".

type Signal

type Signal struct {
	Label string
	// Strong signals move a package into GroupAction.
	Strong bool
}

Signal is one fact that raises (or merely annotates) a finding's urgency.

type Style

type Style struct {
	T     *display.Terminal
	G     glyphs
	Width int
	// contains filtered or unexported fields
}

Style draws text for one terminal. With colour off every method returns its input unchanged, so tests and pipes see exactly the characters, no escapes.

func NewStyle

func NewStyle(t *display.Terminal, o Options) *Style

NewStyle builds a Style from a terminal and the display options.

func (*Style) Bad

func (s *Style) Bad(t string) string

Bad is failure.

func (*Style) Bold

func (s *Style) Bold(t string) string

Bold is emphasis without a colour.

func (*Style) Cmd

func (s *Style) Cmd(t string) string

Cmd is a command the reader can run.

func (*Style) Defence

func (s *Style) Defence(t string) string

Defence is the colour for protection lines.

func (*Style) Dim

func (s *Style) Dim(t string) string

Dim is secondary text.

func (*Style) Good

func (s *Style) Good(t string) string

Good is success and fixes.

func (*Style) Hot

func (s *Style) Hot(t string) string

Hot is the orange used for "no fix" and strong signals.

func (*Style) Path

func (s *Style) Path(t string) string

Path is a file path.

func (*Style) Rule

func (s *Style) Rule(width int) string

Rule draws a horizontal rule.

func (*Style) Sev

func (s *Style) Sev(level, text string) string

Sev colours a word by severity.

func (*Style) Warn

func (s *Style) Warn(t string) string

Warn is caution.

Jump to

Keyboard shortcuts

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