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
- Variables
- func AutomationID(project string, scope engine.Scope) string
- func BaseName(base []sarif.RepositoryRef, path string) string
- func BuildLabel(build string) string
- func Cleared(actions []Action) int
- func DataSourceState(d engine.ScannerData) string
- func Filename(format string) string
- func FilterByPriority(run engine.Result, minPriority string) engine.Result
- func FoldedPlaces(lines []CodeLine, withRepository bool, room int) string
- func Formats() []string
- func ImageDeclarations(model *saga.Model, inRepository func(file string) (string, bool)) sarif.Declarations
- func LineKey(res sarif.Result) (string, bool)
- func NamesRule(id, query string) bool
- func PlaceLines(results []sarif.Result) []sarif.Result
- func StreamFormat(format string) error
- func Summary(format string) string
- func ThresholdWords(setting string) string
- func UncoveredColumns() []string
- func UpgradeTarget(results []sarif.Result) string
- func WriteCodeScanning(w io.Writer, declared sarif.Declarations, render func(io.Writer) error) error
- func WritePolicyRefused(w io.Writer, col tui.Painter, project, release string, p *skald.PolicyCheck)
- func WritePolicyTable(w io.Writer, col tui.Painter, p *skald.PolicyCheck, project string)
- func WritePolicyTableWith(w io.Writer, col tui.Painter, p *skald.PolicyCheck, project string, ...)
- type Action
- type ActionFinding
- type ActionList
- type ActionLocation
- type AnalyzerCounts
- type Artifact
- type ChangeStates
- type ChangeView
- type CodeLine
- type ComponentVerdict
- type Data
- type FailedCaveat
- type FeedProvenance
- type Found
- type Gap
- type GateSettings
- type LineRule
- type LineRules
- type Reporter
- type RepositoryProvenance
- type Scope
- type Suggestion
- type TemplateFinding
- type TemplateView
- type ToolBuild
- type Unexamined
- type View
Constants ¶
const ActionsPerList = 3
ActionsPerList is how many actions each of the fix list's lists shows by default, in the console and in the MCP server's fix_list.
const CodeScanningFormat = "code-scanning"
CodeScanningFormat is the report a workflow uploads to GitHub code scanning itself.
Variables ¶
var StreamFormats = []string{"console", "markdown", "json", "sarif", "vex", "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 AutomationID ¶ added in v0.121.1
AutomationID is what a run writes to SARIF's runs[].automationDetails.id, and it decides whether two analyses of one commit can coexist.
GitHub code scanning splits the id on its last "/" into a category and a run id, and an upload replaces whatever it last received under the same tool and category. A report carrying no id is filed under the empty category, so a monorepo publishing two products over one commit keeps only whichever pipeline finished last, with nothing in either run saying so. An upload made through the code-scanning API cannot correct this from outside: that endpoint takes no category of its own, and the id in the file is the only thing it reads.
The id is the project and, when the run was narrowed, what it was narrowed to. Both are asked for rather than found, which is what makes the id identical on every run of the same product, and an identical id is what lets an alert fixed in one run resolve instead of reappearing under a new category. The trailing "/" puts all of it in the category and leaves the run id empty.
Empty when there is no project and no narrowing. That is a scan with no descriptor at all, and also an ordinary descriptor that never set project:, which the schema does not require.
func BaseName ¶ added in v0.165.0
func BaseName(base []sarif.RepositoryRef, path string) string
BaseName is a base scan as a reader quotes it: the first seven characters of each revision it read, or path, the file it was read from, where it records none. Seven, because that is how git abbreviates a commit and how a reader will look it up.
func BuildLabel ¶ added in v0.122.0
BuildLabel is the Draugr that produced a report, spelled for somebody reading it.
A binary not built from a release tag is stamped "dev", which in a footer reads as though "dev" were the version number. Only the formats a person reads use this; the rest carry what Data holds, which is what a consumer comparing two reports can compare.
func Cleared ¶ added in v0.154.1
Cleared is how many findings a set of actions resolves between them, each counted once: the figure the console's "What to do" heading gives for the rows it lists.
Counted by identity rather than summed, so the figure cannot exceed the findings it describes whatever the grouping does. Each finding is in exactly one action, which makes the two equal; a grouping that put one finding in two actions would otherwise count it twice. Read from each action's Fingerprints, which ActionsFor fills.
func DataSourceState ¶ added in v0.152.0
func DataSourceState(d engine.ScannerData) string
DataSourceState is one data source as the tool reports it: the tool and the data, when its publisher built it and when this machine downloaded it, each where the tool says, and "refused as too old" where the tool will not use the copy. Not "stale", which a feed uses for a copy past its maxAge and still read. "" for a source with none of these, which says nothing a reader could act on.
Dates rather than ages, so a saved report reads the same on any later day.
func Filename ¶ added in v0.63.0
Filename is what a format is written as, whether a publisher delivers it or `-o` writes it.
One table, because the alternative is two that agree until they do not. A format written under one name locally and another by a publisher breaks whatever globs for it, and a CI step that globs for a file it never finds usually warns and carries on, which is a green run with no results in it.
func FilterByPriority ¶ added in v0.82.0
FilterByPriority drops findings below the requested band, returning a copy so the caller's run is untouched. The same Data is rendered in several formats and delivered to publishers.
Findings the scanner never prioritized are kept. An empty Priority means prioritization did not run for that finding, not that it ranked low, and silently dropping it would be the worst reading of an unset field.
Only the results need filtering: the emitted rules[] is derived from the results that remain, so a rule nobody matched leaves with them. That is where most of the size saving comes from, on Draugr's demo repository, filtering to P1 takes the compact SARIF from 82 KB to 32 KB.
func FoldedPlaces ¶ added in v0.174.0
FoldedPlaces names the lines a folded row stands for as the scan's fix list names them: each file once with its line numbers together, within room columns, the lines that do not fit counted. A row for one rule across many lines is read once, so the places are what it adds, and a list of them that ran to the end of the comment would bury every row under it.
func ImageDeclarations ¶ added in v0.184.0
func ImageDeclarations(model *saga.Model, inRepository func(file string) (string, bool)) sarif.Declarations
ImageDeclarations is where each image model declares is written in the repository a run's code scanning upload belongs to, for Data.Declared.
inRepository names a file on disk by its path in that repository, slash-separated, and says false for a file outside it. An image with no file or line, such as one a survey found or one a fragment from another repository declared, has no entry, and neither does one declared in a file inRepository refuses: a path in some other repository would put the finding on a file in this one that does not declare the image.
Each image is keyed under its component by both spellings a finding names it by: the reference the scanners pulled, which carries the digest written beside it (`registry/app:1.2@sha256:…`), as the image findings' `image` property does, and `image:` as written, as a finding that has no such property carries it as its location.
func LineKey ¶ added in v0.161.0
LineKey is the key a result groups under when it is a flaw at one line of code, a sast finding with a line, and false for any other result. Two results with the same key are one action.
func NamesRule ¶ added in v0.173.0
NamesRule reports whether query names the rule id the way a report prints it: the short name under an action, or the end of a long id after the mark that says the front was cut. Somebody copying a name from a row expects it to find the rule.
func PlaceLines ¶ added in v0.161.0
PlaceLines is results with every result at a line of code that names no repository placed in the repository the rest of its component was scanned in, as the fix list places them. Call it over every result being grouped before LineKey, so an imported SARIF file's finding joins the other findings at its line. The results are copied, never changed in place.
func StreamFormat ¶ added in v0.60.0
StreamFormat reports whether a format may be written to stdout, and if not, why.
func Summary ¶ added in v0.123.0
Summary is what a format is for, or "" for a name this build does not render.
The one place that answers it. An editor's completion, the catalog's table and any listing written later read this rather than composing a sentence of their own.
func ThresholdWords ¶ added in v0.165.0
ThresholdWords is a gate setting as the report states it: a band as it is written, and a severity followed by "severity", the way the gate's own line words one. Shared with the message a failed run exits with, so the two say it alike.
func UncoveredColumns ¶ added in v0.123.0
func UncoveredColumns() []string
UncoveredColumns are the column names doctor's "Not checked" block is headed with.
func UpgradeTarget ¶ added in v0.165.0
UpgradeTarget is the release the fix list names for an upgrade clearing these findings, empty where it names none or would split them into more than one action.
For `draugr diff`'s rendering of a scan's change, so an upgrade there names the version the scan's own fix list names, from the same computation, rather than one worked out a second way.
func WriteCodeScanning ¶ added in v0.184.0
func WriteCodeScanning(w io.Writer, declared sarif.Declarations, render func(io.Writer) error) error
WriteCodeScanning writes what render writes, a sarif report, as GitHub code scanning accepts it, with a finding on an image placed on the line declared names for it.
func WritePolicyRefused ¶ added in v0.149.0
func WritePolicyRefused(w io.Writer, col tui.Painter, project, release string, p *skald.PolicyCheck)
WritePolicyRefused is what a scan prints when the policy refuses it before any scanner starts.
func WritePolicyTable ¶ added in v0.149.0
WritePolicyTable is doctor's POLICY section: every rule that reaches the project, passing and broken, with what its setting does to a run that breaks it.
func WritePolicyTableWith ¶ added in v0.158.0
func WritePolicyTableWith(w io.Writer, col tui.Painter, p *skald.PolicyCheck, project string, under []string)
WritePolicyTableWith is WritePolicyTable with lines printed as given under the heading, such as whose login the server was asked with.
Types ¶
type Action ¶ added in v0.98.0
Action is one thing to do and what doing it clears, for a consumer outside this package. The shape is skald's, so report.json can carry it; ActionsFor is what fills it.
func ActionsFor ¶ added in v0.98.0
ActionsFor groups a run's findings into the fix list, most urgent first.
The one implementation of the fix list. The console's "What to do", the HTML report, report.json's actions and the MCP server's fix_list all come from groupActions over findings built by findingOf, so a scan describes the same actions, grouped the same way and clearing the same counts, wherever it is read.
Suppressed findings are left out for the same reason the console leaves them out: an excluded finding is a decision somebody recorded, and proposing it as work is proposing to undo that decision without the reason they gave.
Keyed by control, as a run holds them, because the grouping keys on it: two controls reporting the same rule id are two things to do, and an image's packages and its licenses are two actions. A caller holding a merged results.sarif passes it as one entry under any name, and each result's own control, which the file carries, is used instead.
type ActionFinding ¶ added in v0.140.0
type ActionFinding = skald.ActionFinding
ActionFinding is one finding an action clears.
type ActionList ¶ added in v0.156.0
type ActionList struct {
Kind skald.ActionKind
Actions []Action
}
ActionList is one of the fix list's lists: the actions of one kind of work, most urgent first.
func ListsOf ¶ added in v0.156.0
func ListsOf(actions []Action) []ActionList
ListsOf splits a fix list into the lists the console's "What to do" prints: one per kind of work, in skald.WorkOrder, each keeping the order ActionsFor gave its actions. A kind with no action has no list.
The same split the console makes, so an assistant reading the lists and a terminal printing them put the same action at the head of each. Inside a band the ranking's keys are exploitation, then severity, then count, and only a published CVE carries exploitation evidence, so one list across kinds puts every exploited dependency above every flaw in the project's own code.
type ActionLocation ¶ added in v0.147.0
type ActionLocation = skald.ActionLocation
ActionLocation is one place an action applies to.
type AnalyzerCounts ¶ added in v0.168.0
type AnalyzerCounts struct{ Reachable, Unreachable, Unknown int }
AnalyzerCounts is one analyzer's verdicts in this run, by state.
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.
Named by sbom.Filenames, the function report.json's `sboms` block names them by, so the file a publisher delivers is the file the record describes.
type ChangeStates ¶ added in v0.178.0
type ChangeStates struct {
New, Unaccepted, Accepted, Fixed []sarif.Result
// Moved are findings the head reports under another component than the base did, and
// MovedFrom the component each was under, in the same order.
Moved []sarif.Result
MovedFrom []string
// Reranked count in both scans, in one component, at a different band, and RerankedFrom is the
// band each had in the base, in the same order.
Reranked []sarif.Result
RerankedFrom []string
// Unchanged count in both scans at one band, and StillAccepted were excused in both.
Unchanged, StillAccepted []sarif.Result
}
ChangeStates is a run's findings sorted by what happened to each against the base, in the states `draugr diff` reports. New, unaccepted, accepted and fixed are the change; moved and reranked are findings it left in place and filed or ranked differently; unchanged and still accepted are what it left as it was. Every finding at the head is in exactly one of the states other than fixed, which holds findings only the base had.
func (ChangeStates) Changed ¶ added in v0.178.0
func (c ChangeStates) Changed() bool
Changed reports whether anything changed against the base.
type ChangeView ¶ added in v0.165.0
type ChangeView interface {
// WriteStrips draws a strip of band counts for each state a finding can be in against the base,
// then one more labeled strip for the counts in whole, with no blank line after them, so the
// caller can put what qualifies the counts directly beneath.
WriteStrips(w io.Writer, label string, whole [4]int)
// WriteListing draws what changed in the view asked for, capped at top rows where top is
// positive, and reports whether it wrote anything. It writes nothing where nothing changed.
WriteListing(w io.Writer, view View, top int) bool
// States is every finding sorted by what happened to it against the base, each counted once
// however many scanners reported it, for the reports that draw the change as data rather than
// as console text.
States() ChangeStates
}
ChangeView draws a run's comparison with its base in the shape `draugr diff` prints: the band strips by state, and what changed.
An interface this package declares and pkg/diff implements, with the CLI joining the two, rather than a call from here into pkg/diff. pkg/diff renders that shape and imports this package for the fix list its actions are grouped by, so a call the other way would be an import cycle. Moving the shared pieces into a package both could import means moving the fix list, which is most of this package, for the sake of two methods. Declaring the interface here keeps one renderer for the change, the one `draugr diff` already prints, and leaves the dependency pointing the way it did.
type CodeLine ¶ added in v0.161.0
type CodeLine struct {
// Key identifies the line: its component, repository and location. Results sharing a key are
// one action.
Key string
// Component and Repository the line belongs to, and Location, its path and line.
Component, Repository, Location string
// Title is what to do about the line, in the imperative.
Title string
// Summary is the scanner's description of the flaw, for a title that names a rule rather than
// quoting the description. Empty where the title quotes it.
Summary string
// Rules are each scanner and the rules of its that flag the line, starting with the rule the
// title quotes.
Rules []LineRules
}
CodeLine is the findings at one line of code as the fix list groups them: one action, however many rules flag the line.
For a caller outside this package that lists its own actions, `draugr diff` among them. The keying, the title and the rules come from the functions the fix list itself uses, so a line is one action with the same title wherever it is listed.
func LineOf ¶ added in v0.161.0
LineOf titles the results at one line of code, every one sharing a LineKey. rules is what the scanners published about the rules the results cite, which titles the line where a rule's description says more than its findings' messages. Empty results give an empty CodeLine.
type ComponentVerdict ¶ added in v0.54.0
type ComponentVerdict struct {
Name string
// Exposure and Criticality are what the descriptor declared this component to be, and empty
// where it declared nothing.
//
// Carried beside the verdict because they are half of why the verdict is what it is: the same
// finding bands differently on a public, critical service and an internal, supporting one, and
// a reader comparing two rows of this table without them is comparing two numbers whose
// difference has no visible cause.
Exposure string
Criticality 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
// Declared counts what the descriptor gave this component, by target kind. It is the denominator:
// "3 images not scanned" does not say whether that is all of them or three of thirty, and those
// are different situations. One is a component nobody looked at, the other is a gap in one that
// was mostly covered.
Declared map[string]int
// Unscanned is what this component has that no scanner managed to look at.
//
// A component whose every image failed to pull has had nothing examined, and without this it
// renders as passing with no findings. Which is the report asserting something no scanner
// established. The same reasoning already keeps a component the scope excluded out of the pass
// list; a component the scan could not reach is the same situation arrived at later.
Unscanned []engine.Unscanned
// FailedCaveats are this component's caveats of a kind gate.failOnCaveats lists. Like a target
// no scanner read, each leaves the component short of what the gate requires, so the component
// reads ERROR rather than pass.
FailedCaveats []FailedCaveat
}
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".
func (ComponentVerdict) Errored ¶ added in v0.150.0
func (c ComponentVerdict) Errored() bool
Errored reports whether something kept this component from a verdict the gate accepts: a target no scanner read, or a caveat of a kind the gate fails on.
type Data ¶
type Data struct {
// Project is which project this run belongs to, and what a platform files it under.
Project string
Release saga.Release
Run engine.Result
Verdict norn.Result
MinPriority string
// Scope describes what the run was narrowed to, and is nil when it was not narrowed at all.
//
// A pointer so that every unscoped report. Which is nearly all of them, renders and serializes
// exactly as it did before. Its presence is the signal: an artifact carrying a scope is a partial
// answer, and a consumer that finds one has been told so rather than having to infer it from a
// component list that looks complete.
Scope *Scope
// 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
// Evidence restores the blocks that make a run defensible, tool provenance, what each control
// measured against, declared effects, the scanned revision, job and cache counts.
//
// Off by default. A developer at a terminal is asking what to fix, and answers to questions
// they have not asked push the answer to the one they have off the screen. An auditor is a
// real reader, just not the default one, and asks for this.
Evidence bool
// Descriptor is the Saga this run was produced from: the digest of the merged, effective
// document and the files it was assembled from.
//
// Nil for a scan with no descriptor, which is a real case and not an error.
Descriptor *skald.DescriptorRef
// Policy is what the run's pre-flight learned of the organization's policy, nil where the
// descriptor publishes to no draugr-api server or the run did not ask.
Policy *skald.PolicyCheck
// CI is the job the scan ran in, and nil outside one.
//
// It exists once, in the process doing the work, and is gone when that process exits. A
// platform receiving this report can see a repository URL and cannot see which workflow
// produced the scan.
CI *ci.Context
// Gate records the policy the verdict was produced under.
//
// A verdict is only as meaningful as the gate behind it, and a gate can be narrowed or turned off
// entirely from the command line. Without this the report shows a verdict and no way to tell what
// it was measured against, the same gap that suppression closes for findings, where the question
// is never "did the scanner run" but "who decided this was acceptable".
Gate GateSettings
// Requested is the scope as the caller asked for it, before labels, exposure and criticality
// were resolved to component names. Scope holds the resolved form, which changes whenever a
// component gains or loses a label; anything keyed on what was asked for reads this one.
Requested engine.Scope
// Incomplete reports a run that failed because a scanner could not finish: an error nothing
// waived, or a waivable one without --allow-scan-errors. The verdict already says fail; this
// says the failure is about what was not looked at.
Incomplete bool
// Labels holds each declared component's labels by component name, with an entry for every
// component the descriptor declares, labeled or not. A publisher covering part of a run by
// label reads it, and report.json carries it as componentLabels; the reports a person reads do
// not.
Labels map[string]map[string]string
// View is what the report shows and how densely, one setting rather than two that have to be
// combined. The zero value is ViewFindings.
View View
// Uncovered is what this descriptor declares and no enabled control examines.
Uncovered []Gap
// Unexamined are the files a run with no descriptor found that called for a scanner this
// machine cannot run, which the run turned off. Each is a not-checked caveat.
Unexamined []Unexamined
// Found is what a run with no descriptor read from the tree, a row per kind of file, and nil
// for a run from a descriptor. The report does not read the tree; the caller that did passes
// what it found.
Found []Found
// FailOnCaveats is the kinds of caveat the gate fails the run on, as gate.failOnCaveats or
// --fail-on-caveats set them. A caveat of a listed kind is reported with the errors.
FailOnCaveats []saga.CaveatKind
// FailOnCaveatsFrom names the setting that listed them, config.gate.failOnCaveats or
// --fail-on-caveats, so the caveats block can say where to change it.
FailOnCaveatsFrom string
// Suggestions are the things this particular run makes worth trying, decided by the caller
// because they depend on how it was invoked rather than on what it found.
Suggestions []Suggestion
// ReportsDir is the directory this run writes its report files into, as -o names it, and empty
// where it writes none. Reports are the formats it writes there. The console reads both to offer
// the HTML report where it cut a block short, naming only the flags the run lacks.
ReportsDir string
Reports []string
// Unclassified reports that no component declares exposure or criticality.
//
// A caveat on every band in the report: with nothing declared, each component is read as public
// and critical, which is the most severe reading, so the bands rank severity alone. A reader
// who does not know that is reading a ranking as though it described their application.
Unclassified 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
// Commit is the commit the Draugr binary was built from, empty when it was not stamped. A
// version alone does not identify a development build, and those produce most runs of an
// unreleased change.
Commit string
// VEX names the author and product for the "vex" format. Nil falls back to the release,
// which is enough for a valid document and not enough for a publishable one.
VEX *saga.VEXConfig
// 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
// Repositories is which repository each scan read, and at which commit. Derived from what the
// scanners recorded rather than from the descriptor, because the descriptor usually names no
// revision at all. And "the default branch" is not something a reader can check out.
Repositories []RepositoryProvenance
// Tools records the build of each external scanner the run used, and whether Draugr can
// vouch for it. Empty when nothing external ran.
//
// A scan runs whatever is on PATH, which is right. An operator may have an experimental build or a
// fork, and blocking them would be Draugr mistaking "I cannot verify this" for "this is wrong".
// But a report that cannot say which build produced its findings cannot be reproduced, so the
// answer is to record it.
Tools []ToolBuild
// UnattributedFindings counts findings that belong to no component, which a project-scoped
// control produces. Reported alongside the component breakdown, because a breakdown
// that silently omits them makes the parts look like the whole.
UnattributedFindings int
// AcceptedErrors is a run whose scan errors --allow-scan-errors accepted, which passes covering
// less than it was asked to.
AcceptedErrors bool
// Change draws the run's comparison with its base, on a run the gate on new findings judged.
// Nil on any other run, and the console then prints the scan's own layout.
Change ChangeView
// Declared is where each image the run scanned is declared in the repository it ran in, as
// ImageDeclarations finds it. The copy of the report that goes to code scanning places a finding
// on an image there; every other report keeps the image reference as its location. Nil where the
// caller found none, and a finding on an image then goes to code scanning with no location.
Declared sarif.Declarations
}
Data is everything a reporter needs to render a scan.
func (Data) GateForReport ¶ added in v0.116.0
GateForReport is the run's gate in the shape the JSON document states it, for a caller writing that document through skald rather than through this package's reporters.
func (Data) JSONFeeds ¶ added in v0.132.0
func (d Data) JSONFeeds() []skald.FeedProvenance
JSONFeeds is the exploitability data the run was ranked against, as the JSON document records it.
func (Data) JSONProvenance ¶ added in v0.132.0
func (d Data) JSONProvenance() skald.Provenance
JSONProvenance is what produced the run, as the JSON document records it: the descriptor, the CI job, the gate and the Draugr build.
One function for every path that writes the document, the -o artifact, --format json and the reporter a publisher uses, so the same run cannot record different provenance depending on where it was sent. A platform receiving the document by publisher reads the build from it to know which Draugr produced the run.
func (Data) ProjectName ¶ added in v0.106.0
ProjectName is which project this run belongs to.
The one accessor. Everything that renders the name of the thing being scanned reads this, which is why the field it used to fall back to could be removed in one place rather than in thirty.
func (Data) SARIFOptions ¶ added in v0.171.0
func (d Data) SARIFOptions() sarif.MarshalOptions
SARIFOptions is what every SARIF file of this run carries beyond its findings: which analysis it is, the Draugr that wrote it, and what it says about the run itself. One function for the file -o writes and the one a publisher renders, so the two cannot say different things about one run.
type FailedCaveat ¶ added in v0.150.0
type FailedCaveat = skald.FailedCaveat
FailedCaveat is a caveat whose kind the gate lists in failOnCaveats. Declared in skald, which writes it into report.json.
func FailedCaveats ¶ added in v0.150.0
func FailedCaveats(d Data) []FailedCaveat
FailedCaveats returns the run's caveats of the kinds d.FailOnCaveats lists, by component.
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 Found ¶ added in v0.163.0
type Found struct {
// Kind names what was found, an ecosystem or a kind of file: go, copied JavaScript, Dockerfile.
Kind string
// Files are the files, joined into one list.
Files string
// Paths are the same files, every one of them, from which a console too narrow for Files cuts
// a shorter list.
Paths []string
// Did is what the run did with them: the controls and scanners it turned on, and each one it
// left off, written `<name> off`.
Did string
}
Found is one kind of file a run with no descriptor read from the tree: its kind, the files, and what the run did with them.
type Gap ¶ added in v0.119.0
type Gap struct {
// Component and Surface name what was declared and went unexamined.
Component, Surface string
// Controls are the ones that would have looked at it, every one of them off.
Controls []string
}
Gap is one surface a descriptor declares that no enabled control looks at.
Carried in the report rather than left to whoever renders it, because a run that examined everything except the thing a component exposes to the internet reads exactly like one that examined everything, and the difference is the descriptor's own words.
type GateSettings ¶ added in v0.97.0
type GateSettings struct {
// Threshold is the severity band that fails a control by default.
Threshold sarif.Severity
// PerControl overrides Threshold for named controls, on a severity gate.
PerControl map[string]sarif.Severity
// FailOnPriority additionally fails on a priority band, when set.
FailOnPriority string
// PerControlBand overrides the band for named controls, on a band gate. The other half of
// PerControl: a threshold only applies in the vocabulary its gate asks in, so exactly one of
// these is ever populated.
PerControlBand map[string]string
// Disabled is --no-gate: the verdict is reported and the command still exits 0.
Disabled bool
// FailOnNew is the gate on new findings in force, from config.gate.failOnNew or --fail-on-new,
// and empty where neither set one.
FailOnNew string
// FailOnNewFrom names the setting FailOnNew came from, config.gate.failOnNew or --fail-on-new,
// for the line that states the gate.
FailOnNewFrom string
// DeclaredNew is the descriptor's own config.gate.failOnNew, whatever --fail-on-new said, and
// empty where it sets none. The sarif report records it, so a later comparison reading this scan
// as its base holds a change to at least the gate its base committed to.
DeclaredNew string
// HeldToBase is set where FailOnNew is the base scan's recorded config.gate.failOnNew, applied
// because this scan's descriptor sets a weaker one or none.
HeldToBase bool
// HeldNotes say what the base's declaration decided beyond this scan's, a sentence each: a
// control the base ran that this scan does not, new findings ranked by the base's
// classification, and findings excused by an exclusion the change adds. Empty where nothing.
HeldNotes []string
// New is the run's comparison with a base scan, nil where none ran.
New *skald.NewFindings
// BasePath is the file --base named, which names the base where its SARIF records no revision.
BasePath string
// WholeRun is the outcome of the gate above over every finding, on a run the gate on new
// findings judged instead. Empty on any other run, whose verdict is that outcome.
WholeRun norn.Verdict
}
GateSettings is the policy a verdict was produced under, as the report states it.
Held here rather than recomputed from the Saga: the effective gate is the descriptor, the configuration and the flags resolved together, and a reporter deriving it a second time is how the report and the verdict come to disagree about the run they describe.
type LineRule ¶ added in v0.161.0
type LineRule struct {
// ID is the rule's identifier, Name the part of it that names the rule, and HelpURI where the
// rule is documented, empty when nothing is.
ID, Name, HelpURI string
}
LineRule is one rule at a line of code.
type LineRules ¶ added in v0.161.0
type LineRules struct {
// Tool is the scanner as it names itself, without its edition unless the edition is what tells
// two scanners at the line apart.
Tool string
Rules []LineRule
}
LineRules is one scanner's rules at a line of code.
type RepositoryProvenance ¶ added in v0.64.0
type RepositoryProvenance = sarif.RepositoryRef
RepositoryProvenance is one repository as this run read it.
An alias rather than a copy: the JSON report is rendered by pkg/skald, which cannot import this package, and two structs that must agree eventually will not.
func RepositoriesFrom ¶ added in v0.64.0
func RepositoriesFrom(run engine.Result) []RepositoryProvenance
RepositoriesFrom collects which repository each scan read, and at which commit.
type Scope ¶ added in v0.71.0
type Scope struct {
// Components and Controls are what the caller asked for; an empty list means that axis was
// not restricted.
Components []string `json:"components,omitempty"`
Controls []string `json:"controls,omitempty"`
// SkippedComponents are declared components this run did not scan.
//
// Named rather than counted: "10 not scanned" tells a reader they are missing something and
// not which thing, and the answer is one they already have.
SkippedComponents []string `json:"skippedComponents,omitempty"`
}
Scope is what a run was narrowed to, and what it therefore did not cover.
A scoped run is a real verdict about a real subset, which is why it still gates. It is only dangerous when it is indistinguishable from a whole one, so this travels into every artifact the run produces, and every rendering says what was left out.
type Suggestion ¶ added in v0.119.0
type Suggestion struct {
// What to type, or the key to add to the descriptor.
What string
// Why, in a clause. Not an instruction: none of this is required, and a reader who already has
// their answer should be able to pass over the whole block.
Why string
}
Suggestion is something a reader may try, and the reason it is worth trying.
Two fields rather than a sentence. A sentence naming a flag has to be read whole to find out whether it applies, where a column of flags is scanned for the one that does.
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 {
// Project is what the run is about. Exposed beside the release because a release carries only
// a version now, and a template with nothing but that renders "1.4.0" over and over with no
// statement about what is at 1.4.0.
Project string
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.
type ToolBuild ¶ added in v0.63.0
type ToolBuild struct {
// Name is the executable, e.g. "trivy".
Name string
// Version is what it reports, or what Draugr recorded when it installed it.
Version string
// Level is how strongly Draugr can vouch for this build: pinned, signed, checksum, unverified, or
// external. Not a boolean, because those are genuinely different claims, an unsigned checksum
// proves the download was not corrupted without proving upstream published it, and collapsing that
// into "unattested" discards a difference a reader may care about.
Level string
// Reason renders the level for someone who has not read its definition.
Reason string
}
ToolBuild is the build of one external scanner, as this run found it.
type Unexamined ¶ added in v0.163.0
type Unexamined struct {
// Component holds the files.
Component string
// Files are the files that called for the scanner, joined into one list for a reader, which may
// name only the first of them.
Files string
// Paths are the same files, every one by its own path.
Paths []string
// Why names what the machine is missing, and the command that installs it where Draugr can.
Why string
}
Unexamined is a set of files that called for a scanner the machine running the scan cannot run.
Only a run with no descriptor has them. A descriptor names its scanners, and one that cannot run is an error, because somebody asked for it. With no descriptor the tree chose the scanner, and the run reports what went unexamined rather than failing over a tool nobody asked for.
type View ¶ added in v0.119.0
type View string
View is what a report shows and how densely.
One setting rather than a shape flag and a density flag that have to be combined. The three are answers to one question, what does this reader want to see, and as two flags four combinations exist of which two mean the same thing. It also gives the machine formats the same word: a consumer that acts on a report rather than reading it asks for the same view as somebody who already knows what they are looking at.
const ( // ViewFindings is a row per finding with what it is, and what argued with its band, underneath. // // The default, and the fuller one, for the reason it carries any reasoning at all: a reader // meeting a ranking for the first time is deciding whether to believe it, and the line under // each row is where a band accounts for itself. ViewFindings View = "findings" // ViewActions is a row per thing to do, each saying how many findings it clears. // // A reader deciding what to spend an afternoon on is choosing between actions, and a list of // findings makes them do that grouping in their head. Not the default, because a list of fixes // above the controls that produced them reads as instructions from a tool the reader has not // yet decided to trust. ViewActions View = "actions" // ViewCompact is one line per finding, and in json and sarif no indentation and no relayed // rule prose. // // For a reader who already knows what they are looking at and is asking how much there is, and // for a consumer that parses rather than reads. ViewCompact View = "compact" )
The views. Findings is the default, and is the one that explains itself.
Source Files
¶
- actions.go
- artifact.go
- change.go
- change_tables.go
- console.go
- declared.go
- errors.go
- evidence.go
- fixfirst.go
- fold.go
- gitlab.go
- gitlab_sbom.go
- html.go
- htmldata.go
- instructions.go
- instructions_cloud.go
- instructions_reasoned.go
- junit.go
- lines.go
- markdown.go
- memory.go
- notifications.go
- orgpolicy.go
- policy.go
- refusal.go
- report.go
- reportstail.go
- sbom.go
- signals.go
- target.go
- template.go
- unread.go
- unsettled.go
- vex.go