skald

package
v0.201.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 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 skald renders scan results and verdicts into evidence: a JSON summary and merged SARIF. A skald is the poet who records deeds, here, the record of a scan.

Index

Constants

View Source
const (
	// LocationManifest is a file somebody edits to declare a dependency: package.json, go.mod,
	// requirements.txt.
	LocationManifest = "manifest"
	// LocationLockfile is a file a package manager writes from a manifest: package-lock.json,
	// poetry.lock.
	LocationLockfile = "lockfile"
	// LocationVendored is a copy of a dependency committed to the tree, such as a minified script.
	// Bumping the manifest leaves it as it was.
	LocationVendored = "vendored"
	// LocationImage is a container image, for a finding read from one.
	LocationImage = "image"
	// LocationFile is any other file a finding is in.
	LocationFile = "file"
)

The kinds of place an action applies to.

View Source
const (
	PolicyNone   = "none"
	PolicyFail   = "fail"
	PolicyRefuse = "refuse"
)

The acts a policy verdict, and so an outcome, can have.

View Source
const DeclaredProvenanceTool = "draugr/declared"

DeclaredProvenanceTool is the provenance entry a scan stamps on its SARIF to record what its descriptor declared: one entry for the project, and one more for each component.

View Source
const GateProvenanceTool = "draugr/gate"

GateProvenanceTool is the provenance entry a scan stamps on its SARIF to record its descriptor's config.gate.failOnNew.

View Source
const MinPriorityProvenanceTool = "draugr/min-priority"

MinPriorityProvenanceTool is the provenance entry a priority-narrowed report stamps on its SARIF.

View Source
const ScopeProvenanceTool = "draugr/scope"

ScopeProvenanceTool is the provenance entry a scoped run stamps on its SARIF.

Variables

WorkOrder is the order the fix list presents its lists in, one per kind of work.

A list per kind because the kinds are different people's work. A change to the application's code and a newer base image do not compete for one engineer's next hour, and one sequence ranks each against the other by numbers that say nothing about which to do first.

An image somebody else publishes leads. One such action routinely clears more findings than every other list together, and a reader has to see that before reading a package bump inside it as work.

Functions

func DeclaredDigest added in v0.189.0

func DeclaredDigest(d engine.Declarations) string

DeclaredDigest names a declaration in sixteen hex characters: the first eight bytes of the SHA-256 of its provenance entries. --trust-descriptor-change takes it, so the switch typed in a pipeline trusts one descriptor and no later edit of it. Two reads of one declaration give one digest, since the entries hold only what a report reads back.

func DeclaredOfReport added in v0.189.0

func DeclaredOfReport(rep sarif.Report) (engine.Declarations, bool)

DeclaredOfReport is what a loaded report's descriptor declared, and whether the report recorded it. The inverse of DeclaredProvenance. A report written before scans recorded it reads as not recorded, which a comparison has to say rather than read as a descriptor that declared nothing.

func DeclaredProvenance added in v0.189.0

func DeclaredProvenance(d engine.Declarations) []sarif.Provenance

DeclaredProvenance renders what a run's descriptor declared as SARIF provenance entries, none where the run recorded nothing.

A report compared later as somebody's base then carries the declaration of the commit it scanned. A pull request is judged against what its base already declared: its own descriptor is part of the change under review, and a change that declares its component less exposed, turns a control off or excludes the finding it adds would otherwise be judged by the declaration it introduces.

func GateOfReport added in v0.188.1

func GateOfReport(rep sarif.Report) (string, bool)

GateOfReport is the config.gate.failOnNew a loaded report's scan was run under, and whether it recorded one. The inverse of GateProvenance. A report written before scans recorded it, or by a scan whose descriptor set none, reads as none.

func GateProvenance added in v0.188.1

func GateProvenance(failOnNew string) (sarif.Provenance, bool)

GateProvenance renders the gate on new findings a descriptor set, its config.gate.failOnNew, as a SARIF provenance entry, and reports whether there was one to render.

A report compared later as somebody's base carries the gate of the commit it scanned. A pull request is judged against what its base already enforces: its own descriptor is part of the change under review, and a change that deletes or loosens the gate would otherwise be judged by the weaker gate it introduces. Recorded from the descriptor rather than from --fail-on-new, because the descriptor is what the base commit committed to.

func MergedSARIF

func MergedSARIF(run engine.Result) sarif.Report

MergedSARIF combines all controls' reports into one SARIF report.

func MinPriorityOfReport added in v0.82.0

func MinPriorityOfReport(rep sarif.Report) (string, bool)

MinPriorityOfReport reports the band a loaded report was narrowed to, and whether it was narrowed at all. The inverse of MinPriorityProvenance, for a consumer reading a file somebody else wrote.

func MinPriorityProvenance added in v0.82.0

func MinPriorityProvenance(band string) (sarif.Provenance, bool)

MinPriorityProvenance renders a declared priority band as a SARIF provenance entry, and reports whether there was one to render.

The same carrier and the same reason as a scope: a run states what it left out, not only what it found. And the same hazard if it does not, a narrowed file and a complete one are indistinguishable to anything that reloads them, so `draugr diff` would read every finding below the band as fixed.

func RenderJSON

func RenderJSON(w io.Writer, release saga.Release, run engine.Result, verdict norn.Result, minPriority string) error

RenderJSON writes a JSON evidence summary combining the run result and the verdict. Controls are emitted in name order for stable output. When minPriority is non-empty (e.g. "P2"), a ranked `findings` list of findings at or above that band is included; priority counts are always included when the run was prioritized.

func RenderJSONFor added in v0.106.0

func RenderJSONFor(w io.Writer, project string, release saga.Release, run engine.Result, verdict norn.Result, minPriority string, feeds []FeedProvenance, opts sarif.MarshalOptions, prov Provenance) error

RenderJSONFor is RenderJSONWithFeeds with the project the run belongs to.

A separate function rather than another parameter on the three above, which are kept for callers outside this repository and say what they leave out.

func RenderJSONWith added in v0.35.0

func RenderJSONWith(w io.Writer, release saga.Release, run engine.Result, verdict norn.Result, minPriority string, opts sarif.MarshalOptions) error

RenderJSONWith is RenderJSON with marshaling options; Compact drops the indentation.

func RenderJSONWithFeeds deprecated added in v0.56.0

func RenderJSONWithFeeds(w io.Writer, release saga.Release, run engine.Result, verdict norn.Result, minPriority string, feeds []FeedProvenance, opts sarif.MarshalOptions) error

RenderJSONWithFeeds is RenderJSONWith plus the exploitability datasets the run used.

Deprecated: use RenderJSONFor, which carries the project. This one emits a document naming no project at all, a platform files it under nothing, and there is no longer a release name for one to fall back to.

func ScopeOfReport added in v0.71.0

func ScopeOfReport(rep sarif.Report) (string, bool)

ScopeOfReport describes what a loaded report was scoped to, and reports whether it was scoped at all. The inverse of ScopeProvenance, for a consumer reading a file somebody else wrote.

func ScopeProvenance added in v0.71.0

func ScopeProvenance(scope engine.Scope) (sarif.Provenance, bool)

ScopeProvenance renders a scope as a SARIF provenance entry, and reports whether there was one to render.

Provenance is the right carrier and already says so: it is what a run states about itself rather than about what it found, and it survives a round trip through the file.

func Strongest added in v0.149.0

func Strongest(a, b string) string

Strongest is the stronger of two acts: refuse, then fail, then none.

func WriteSARIF

func WriteSARIF(w io.Writer, run engine.Result) error

WriteSARIF writes the merged run results as SARIF 2.1.0 JSON.

func WriteSARIFNarrowed added in v0.82.0

func WriteSARIFNarrowed(w io.Writer, run engine.Result, band string, opts sarif.MarshalOptions) error

WriteSARIFNarrowed writes a SARIF report that says which priority band it was narrowed to.

The caller has already dropped the findings below the band; what this adds is the statement that it did. A file that is a subset and does not say so is the failure this whole provenance mechanism exists to prevent, most sharply for `draugr diff`, which would otherwise report every omitted finding as fixed.

func WriteSARIFWith added in v0.35.0

func WriteSARIFWith(w io.Writer, run engine.Result, opts sarif.MarshalOptions) error

WriteSARIFWith is WriteSARIF with marshaling options.

Types

type Action added in v0.147.0

type Action struct {
	// ID identifies the action across runs: the same findings grouped the same way, toward the same
	// target, get the same ID. A dependency action's is derived from its component, package,
	// installed version and target, so it changes when any of them does.
	ID string `json:"id"`
	// Title is what to do, in the imperative.
	Title string `json:"title"`
	// Kind is the kind of work the action is, so a list of actions can be split into the lists people
	// work from.
	Kind ActionKind `json:"kind"`
	// Summary is the scanner's one-line description of what is wrong, for an action whose title
	// names a rule rather than saying what it found. Empty where the title says it already.
	Summary string `json:"summary,omitempty"`
	// Component every finding belongs to. A dependency action is always one component's; an action
	// grouped on a rule or an image can span several, and then this is empty.
	Component string `json:"component,omitempty"`
	// Control the findings came from, and the worst priority among them.
	Control  string `json:"control,omitempty"`
	Priority string `json:"priority,omitempty"`
	// Clears is how many findings this one action resolves.
	Clears int `json:"clears"`
	// Severity, SeverityFrom and Exploitation are what orders actions inside one priority band. For
	// the two steps of an upgrade split by Policy they are the package's, because both steps rank
	// together, so the values always account for the order the actions are in.
	//
	// Severity is the worst ranked severity among the findings: held at the control's minimum severity,
	// raised where KEV or EPSS raised one, lowered where reachability analysis lowered one.
	Severity sarif.Severity `` /* 199-byte string literal not displayed */
	// SeverityFrom is the worst severity as the scanners reported it, where the floor or an
	// adjustment changed the worst. Absent where Severity is the scanners' own.
	SeverityFrom sarif.Severity `` /* 176-byte string literal not displayed */
	// Exploitation is the strongest exploitation evidence among the findings: a KEV listing, whether
	// or not it raised the finding, then an EPSS score that raised one. KEV outranks EPSS. Nil where
	// no finding is on KEV and EPSS raised none.
	Exploitation *ActionExploitation `` /* 227-byte string literal not displayed */
	// Upstream marks an action whose unit of work is something somebody else publishes: the fix
	// is to take a newer one, not to change anything inside it.
	Upstream bool `json:"upstream,omitempty"`
	// Ecosystem, Package and From name the dependency and the version installed, for an action
	// that upgrades or replaces one. Empty for every other action.
	Ecosystem string `json:"ecosystem,omitempty"`
	Package   string `json:"package,omitempty"`
	From      string `json:"from,omitempty"`
	// Versioning is the ecosystem whose rules order the dependency's versions, in lower case:
	// debian, red hat, maven, pypi, npm. Ecosystem is what the scanner reported, and several
	// reported names share one set of rules. The note counting actions a policy could not split
	// groups them by this.
	Versioning string `json:"versioning,omitempty"`
	// Target is the one version to move to. For an upgrade it is the lowest release that clears
	// every finding, by the package's own ecosystem's order. Empty when no one release can be named,
	// for an ecosystem Draugr cannot order or for an image whose findings are in many packages.
	Target string `json:"target,omitempty"`
	// Policy is the component's fixes.upgrade, patch or minor, for an upgrade it applies to. Absent
	// where the component left the default of major.
	Policy string `` /* 131-byte string literal not displayed */
	// PolicyFrom is the descriptor key that set Policy, `config.fixes.upgrade` or
	// `components["web"].fixes.upgrade`, which a reader changes for the fix list to propose a larger
	// step. Absent with Policy, and in a report whose findings did not record it.
	PolicyFrom string `` /* 194-byte string literal not displayed */
	// WithinPolicy says whether this step stays within Policy. A step past it carries the findings
	// only it clears, and After names the step within the policy it follows.
	WithinPolicy *bool `json:"withinPolicy,omitempty" jsonschema:"false for a step larger than policy allows, which the reader has to choose to take"`
	// PolicyApplies is false where Policy could not be applied because the versions are not
	// semantic, a distribution's packages among them, so the action was not split.
	PolicyApplies *bool `json:"policyApplies,omitempty"`
	// After is the ID of the action this one presumes has been taken.
	After string `json:"after,omitempty"`
	// Beyond is the size of a step past Policy, minor or major, measured from the release the After
	// step reaches, or from the installed version where there is none. The label
	// `major, past config.fixes.upgrade: minor` is Beyond, PolicyFrom and Policy.
	Beyond string `json:"beyond,omitempty" jsonschema:"the size of a step past policy, minor or major"`
	// FixedVersions are the releases the advisories name as fixing these findings, in the order
	// first seen, each advisory's own answer.
	FixedVersions []string `json:"fixedVersions,omitempty"`
	// Locations are every distinct place the findings are, in the order first seen, then each other
	// file holding a finding counted under one of them, such as a vendored copy or the same advisory
	// in a second Go module. Such a file is one more place the change reaches and adds nothing to
	// Clears.
	Locations []ActionLocation `json:"locations,omitempty"`
	// Where lists the same places as text, capped, the way the console names them.
	Where []string `json:"where,omitempty"`
	// RuleIDs are the rules this action resolves, capped, so a caller can look any of them up.
	RuleIDs []string `json:"ruleIds,omitempty"`
	// Fingerprints identify every finding this action clears, most urgent first. Each is the
	// `fingerprint` property of a result in results.sarif, which holds the rest of the finding.
	//
	// Identities rather than copies, so the document stays bounded however many findings a run has:
	// a destination holding results.sarif already has every finding once.
	Fingerprints []string `json:"findings,omitempty"`
	// Findings are every finding this action clears, most urgent first, uncapped where Where and
	// RuleIDs are capped. Not serialized: a publisher that lists the findings reads them here, and
	// the document carries Fingerprints.
	Findings []ActionFinding `json:"-"`
	// Row is the ID of the action whose row this one shares in `draugr scan --view actions`, which
	// lists the actions for single lines that say the same thing, in one band, component and
	// repository, as one row in the first one's place. Every action of such a row carries the first's
	// ID, the first included; an action on a row of its own has none.
	Row string `json:"row,omitempty"`
	// Key is what these findings grouped under: the identity that makes two of them one action.
	//
	// Opaque, and deliberately. Its shape is report's business and changes when the grouping
	// does. What it is for is membership: a caller holding the findings can ask which action each
	// one belongs to and match on this, instead of inferring it from a title. Title is written for a
	// reader and is not an identity, an action fed by two controls takes one of their names, and
	// matching on that silently drops the other's findings.
	//
	// Not serialized. It is an identity for a caller holding report's own output in memory, and it
	// contains a separator that has no business in a JSON document. ID is the serialized identity.
	Key string `json:"-"`
	// OneChange marks an action that one change resolves: an upgrade, a newer image, a license
	// review. Its findings are what the change clears. An action for a rule has each finding at a
	// place that needs its own edit.
	OneChange bool `json:"-"`
}

Action is one thing to do and what doing it clears, as report.json and the MCP server carry it.

Declared here so the document can hold it; the grouping that produces one is report.ActionsFor. The keying is the subtle part. Which findings are one fix and which only look alike, and a second implementation of it would drift from that one silently, leaving an assistant and a terminal describing the same report differently.

type ActionExploitation added in v0.156.0

type ActionExploitation struct {
	// Signal names the dataset: "kev" or "epss".
	Signal string `json:"signal" jsonschema:"kev (observed exploitation) or epss (predicted probability of exploitation)"`
	// RuleID is the rule of the finding the signal applies to: a CVE, or an advisory id relating the
	// CVE that CVE names.
	RuleID string `json:"ruleId" jsonschema:"the rule of the finding the signal applies to: a CVE, or an advisory id relating the CVE in cve"`
	// Detail is the specific fact, e.g. "on KEV" or "EPSS 0.87".
	Detail string `json:"detail,omitempty" jsonschema:"the specific fact, e.g. on KEV or EPSS 0.87"`
	// AsOf is the day the data was fetched, as YYYY-MM-DD.
	AsOf string `json:"asOf,omitempty" jsonschema:"the day the dataset was obtained, YYYY-MM-DD"`
	// CVE is the CVE the dataset matched, where RuleID names none and the finding listed it as an
	// alias.
	CVE string `json:"cve,omitempty" jsonschema:"the CVE the dataset matched, present where ruleId names none"`
}

ActionExploitation is the exploitation evidence an action ranks by: one finding's KEV listing or escalation, in the words the finding's own record uses.

type ActionFinding added in v0.147.0

type ActionFinding struct {
	Control    string
	RuleID     string
	Tool       string
	Priority   string
	Severity   sarif.Severity
	Message    string
	Component  string
	Repository string
	// Location is the file and line, or the image for a finding inside one.
	Location    string
	HelpURI     string
	Fingerprint string
	// Upgrade is the dependency and the version that clears it, `jinja2 2.10 → 2.10.1`, or its
	// "no fix available". Empty for a finding that is not about a dependency.
	Upgrade string
}

ActionFinding is one finding an action clears.

type ActionKind added in v0.151.0

type ActionKind string

ActionKind is the kind of work an action is, which decides the list it goes in.

const (
	// KindImage is a newer release of an image somebody else publishes, one the descriptor declares
	// `builtBy: upstream`: the reader moves the reference to it rather than changing anything inside.
	KindImage ActionKind = "image"
	// KindBump is an upgrade of a dependency to the release that clears its findings.
	KindBump ActionKind = "bump"
	// KindCode is a change to the application's code or configuration, and an investigation of
	// what it talks to.
	KindCode ActionKind = "code"
	// KindInfrastructure is a change to infrastructure: IaC, a cluster, a cloud account.
	KindInfrastructure ActionKind = "infrastructure"
	// KindCredential is a committed credential to remove and rotate.
	KindCredential ActionKind = "credential"
	// KindWait is a fix that has to come from somebody else's release: a newer image, an upstream
	// repository, a package with no fixed version yet.
	KindWait ActionKind = "wait"
	// KindDecide is a decision rather than a change: a license, an operating system past its end of
	// life, a finding that reports a fact.
	KindDecide ActionKind = "decide"
)

The kinds of action.

func (ActionKind) ListName added in v0.155.0

func (k ActionKind) ListName() string

ListName is the name of the list an action of this kind is in, or "" for a kind with none.

type ActionLocation added in v0.147.0

type ActionLocation struct {
	// Repository the path is in, for a component holding more than one. Paths are relative to it.
	Repository string `json:"repository,omitempty"`
	// Path is the file, or the image reference for a location of kind image.
	Path string `json:"path"`
	Line int    `json:"line,omitempty"`
	// Kind is one of the Location constants.
	Kind string `json:"kind"`
}

ActionLocation is one place an action applies to.

type Build added in v0.122.0

type Build struct {
	Version string `json:"version,omitempty"`
	Commit  string `json:"commit,omitempty"`
}

Build identifies the Draugr that produced a report.

The document already names release.version, which is the version of the software being scanned. Nothing in it said which version did the scanning, so two reports a month apart that disagree could not be told apart: the code changed, or Draugr did, and the CI logs that would have said are long gone.

type DescriptorRef added in v0.106.0

type DescriptorRef struct {
	// Digest is over the merged, environment-substituted descriptor, serialized canonically.
	//
	// No file on disk has this content. A digest over the root file alone would call two runs
	// identical when a fragment between them changed, and different when a comment moved.
	Digest string `json:"digest,omitempty"`
	// Sources are the files it was assembled from, root first.
	Sources []DescriptorSource `json:"sources,omitempty"`
	// Effective is the merged, environment-substituted descriptor as YAML. The same bytes Digest is
	// taken over.
	//
	// Sent because a digest is worth nothing to somebody who cannot reproduce it, and because the
	// question a reader actually has is "what did this run apply", which no list of filenames
	// answers. It holds less than the report beside it: the findings, their locations and every
	// suppression's reason are already in that, and a descriptor never carries a
	// credential. The schema has no field for one, only for the name of a variable.
	//
	// A few kilobytes against a report that is already larger.
	Effective string `json:"effective,omitempty"`
	// Contributed names the fragments each control setting came from, keyed "control.option", for
	// the settings a fragment is allowed to carry, and the configuration file behind each control
	// default that reached the descriptor, keyed by the setting's dotted path.
	//
	// Sources says which files were merged and Effective says what the merged descriptor holds.
	// Neither answers which of those files expects an identity nobody reading the root descriptor
	// declared, and that is the question a reviewer of an included policy is asking. Nor which
	// value in Effective no committed file holds, because a configuration file outside the
	// repository supplied it.
	//
	// Absent when every setting came from the descriptor itself, which is the ordinary case.
	Contributed map[string][]string `json:"contributed,omitempty"`
	// Exclusions are the merged descriptor's config.exclude entries, in its order: where each is
	// written, and what git's history says about that line.
	Exclusions []Exclusion `json:"exclusions,omitempty"`
}

DescriptorRef identifies the descriptor a run was produced from.

Both halves are needed and neither substitutes for the other: Digest says whether two runs were asked the same question, and Sources says which files that question was assembled from.

func DescriptorFrom added in v0.106.0

func DescriptorFrom(res *saga.Resolved) *DescriptorRef

DescriptorFrom renders a resolution as the report's descriptor block, or nil when there was none, a scan driven entirely from flags has no descriptor to record, and an empty block would claim otherwise.

type DescriptorSource added in v0.106.0

type DescriptorSource struct {
	// Path is the file as the descriptor that named it wrote it. A configuration file is named as
	// `draugr config show` names it: from the working directory, or from the home directory.
	Path string `json:"path,omitempty"`
	// Config marks a configuration file that supplied control defaults, by where it was found:
	// machine, project, --config or DRAUGR_CONFIG. Contributed names the settings it supplied.
	Config string `json:"config,omitempty"`
	// URL, Revision and Resolved locate a fragment fetched from another repository. Revision is what
	// was asked for and Resolved is the commit that turned out to be, a branch moves, so only the
	// second makes the run reproducible.
	URL      string `json:"url,omitempty"`
	Revision string `json:"revision,omitempty"`
	Resolved string `json:"resolved,omitempty"`
	// Digest is over the file as committed, before ${{ VAR }} substitution: it answers "is this
	// the same file somebody reviewed", which is a question about the text, not the run.
	Digest string `json:"digest,omitempty"`
	// Root marks the descriptor the resolution started from.
	Root bool `json:"root,omitempty"`
}

DescriptorSource is one file a descriptor was assembled from.

type DroppedControl added in v0.189.0

type DroppedControl struct {
	// Component is the base's component the control was on, absent for a project-wide control.
	Component string `json:"component,omitempty"`
	// Control is the control's name.
	Control string `json:"control"`
}

DroppedControl is a control the base scan ran that this run does not.

type Exclusion added in v0.161.0

type Exclusion struct {
	// Source is the descriptor or fragment, named as results.sarif's suppression `source` names it,
	// and Line the line the entry starts at. Together they match a suppressed finding's `source`
	// and `line`.
	Source string `json:"source"`
	Line   int    `json:"line,omitempty"`
	// Rules and Paths are the entry's matchers as written, wildcards and trailing slashes kept.
	Rules []string `json:"rules,omitempty"`
	Paths []string `json:"paths,omitempty"`
	// Reason is the entry's reason, so a reader can tell one entry from the next.
	Reason string `json:"reason"`
	// Expires is the entry's expiry date, YYYY-MM-DD, absent where it sets none.
	Expires string `json:"expires,omitempty"`
	// VEX is the claim the entry makes for `--report vex`, absent where it makes none.
	VEX *ExclusionVEX `json:"vex,omitempty"`
	// GitHistory is what `git blame` says about Line. Absent where nobody asked, as a caller
	// building a report from a model does.
	GitHistory *saga.LineHistory `json:"gitHistory,omitempty"`
}

Exclusion is one config.exclude entry: every field it sets, the file and line it is written at, and git's record of that line.

The record of who set a finding aside is the repository's history of the line, which a reviewer reads with git blame. The report carries it where the history is reliable and says why where it is not, so a platform reading the report can show it without the checkout.

The entry's own fields travel with it because a reason is only auditable against what it matches: "fixtures hold fake credentials" is a claim about some paths and some rules, and a reader holding the report and not the descriptor has no other way to see which.

func ExclusionsFrom added in v0.161.0

func ExclusionsFrom(rules []saga.ExcludeRule) []Exclusion

ExclusionsFrom renders exclusion rules as the report's descriptor.exclusions, or nil for none.

type ExclusionVEX added in v0.168.0

type ExclusionVEX struct {
	Status        string `json:"status"`
	Justification string `json:"justification,omitempty"`
}

ExclusionVEX is an exclusion's `vex` block: the status it claims, and the justification from VEX's vocabulary where it gives one.

type FailedCaveat added in v0.150.0

type FailedCaveat struct {
	// Component is the component it is about.
	Component string `json:"component"`
	// What is the surface, scanner, file or cloud service it names.
	What string `json:"what"`
	// Kind is its kind, as gate.failOnCaveats names it.
	Kind saga.CaveatKind `json:"kind"`
	// Detail is why, in the words the report prints.
	Detail string `json:"detail"`
}

FailedCaveat is a caveat whose kind the gate lists in failOnCaveats, so it failed the run as an error does, or was accepted as one under --allow-scan-errors.

type FeedProvenance added in v0.56.0

type FeedProvenance struct {
	Name      string     `json:"name"`
	URL       string     `json:"url,omitempty"`
	FetchedAt *time.Time `json:"fetchedAt,omitempty"`
	SHA256    string     `json:"sha256,omitempty"`
	Stale     bool       `json:"stale,omitempty"`
}

FeedProvenance is one exploitability dataset as a run saw it: where it came from, when, and whether it was already older than the run allowed for.

type Found added in v0.196.0

type Found struct {
	// Kind names what was found, an ecosystem or a kind of file: go, Dockerfile, Terraform. A
	// repository config.detect could not read is a row of kind repository.
	Kind string `json:"kind"`
	// Paths are the files, every one of them, relative to their repository, or joined to its url
	// where the run read more than one.
	Paths []string `json:"paths,omitempty"`
	// Did is what the run did with them, in the words the report prints: the controls and scanners
	// they turned on, each one the run did not run written `<name> off`.
	Did string `json:"did"`
}

Found is one kind of file a run read from its repositories to decide which controls to turn on.

type Gate added in v0.116.0

type Gate struct {
	Policy norn.Policy
	// Disabled is --no-gate: the verdict is reported and the command still exits 0.
	Disabled bool
	// FailOnCaveats are the kinds of caveat that fail the run as an error does.
	FailOnCaveats []saga.CaveatKind
	// FailOnNew is the threshold at which a finding new since the base scan fails the run, a band
	// or a severity, as config.gate.failOnNew or --fail-on-new set it. Empty where neither did.
	FailOnNew string
	// New is the run's comparison with a base scan, nil where no comparison ran.
	New *NewFindings
	// WholeRun is the outcome of Policy 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
}

Gate is the policy a verdict was produced under, and whether it decided the exit code.

The policy is norn's own rather than a copy of its four fields: a second declaration of the same rule is a second thing to keep true, and the copy is the one that drifts.

type HeldFile added in v0.189.2

type HeldFile struct {
	// Repository is the URL of the repository whose checkout held a scanner's file, absent for a
	// VEX document or a file a setting names.
	Repository string `json:"repository,omitempty"`
	// Path is the file's path as the run records it.
	Path string `json:"path"`
	// Change is "added" or "changed".
	Change string `json:"change"`
}

HeldFile is a file this run adds, or reads with other content than its base did, that can set findings aside or change what a scanner finds.

type NewFindings added in v0.164.0

type NewFindings struct {
	// Base is each repository the base scan read and the revision it read, as the base's SARIF
	// records them.
	Base []sarif.RepositoryRef
	// Introduced are the findings this run reports and the base does not, without a second
	// scanner's copy of one already counted.
	Introduced []sarif.Result
	// Tripped are the introduced findings that met FailOnNew, the ones the gate failed the run on.
	// Empty where none did, and where FailOnNew is empty.
	Tripped []sarif.Result
	// Dropped are the controls the base's descriptor turned on that this run's does not. Each fails
	// the gate on new findings by itself: what the change adds where the control ran was never
	// looked for, so no count of new findings can say the change is clean.
	Dropped []DroppedControl
	// Files are the files outside the descriptor this run adds or reads with other content than the
	// base did, that can set findings aside or change what a scanner finds. Each fails the gate on
	// new findings by itself, as a dropped control does.
	Files []HeldFile
	// Trusted is set where --trust-descriptor-change let this run's descriptor decide: Dropped and
	// Files then say what the base would have held and fail nothing.
	Trusted bool
}

NewFindings is a run's comparison with the base scan it was given.

type NotChecked added in v0.174.0

type NotChecked struct {
	// Component is the component it is about.
	Component string `json:"component,omitempty"`
	// What is the surface, such as hosts or images, or the files, joined into one list.
	What string `json:"what"`
	// Controls are the controls that would have examined a surface, every one of them off. Absent
	// for files, which no control was set to examine.
	Controls []string `json:"controls,omitempty"`
	// Paths are the files What names, every one by its own path. Absent for a surface.
	Paths []string `json:"paths,omitempty"`
	// Reason is why, in the words the report prints.
	Reason string `json:"reason"`
}

NotChecked is a not-checked caveat: a surface or files the run did not examine.

type PolicyCheck added in v0.149.0

type PolicyCheck struct {
	// Server is the endpoint the policy came from.
	Server string `json:"server,omitempty"`
	// Checked says the server answered. A run that could not ask says why in Reason.
	Checked bool   `json:"checked"`
	Reason  string `json:"reason,omitempty"`
	// Version is the policy version the descriptor was judged against.
	Version int    `json:"version,omitempty"`
	Outcome string `json:"outcome,omitempty"`
	// Pending says the server had not decided every setting when the wait for its verdict ended, so
	// Outcome covers only the settings it had. It is never a pass.
	Pending  bool            `json:"pending,omitempty"`
	Verdicts []PolicyVerdict `json:"verdicts,omitempty"`
	// Run is the servers' verdict on the published run, its findings included. Nil where the run was
	// published to no server that judges policy.
	Run *PolicyCheck `json:"run,omitempty"`
}

PolicyCheck is what a run's pre-flight learned of the organization's policy, as report.json records it. Run is the same for the published run, judged with its findings.

func (*PolicyCheck) Fails added in v0.158.0

func (p *PolicyCheck) Fails() bool

Fails reports whether the check's outcome fails the gate. A refusal fails it too, since a run already recorded can no longer be refused.

type PolicyItem added in v0.149.0

type PolicyItem struct {
	Field      string `json:"field"`
	Found      string `json:"found"`
	Constraint string `json:"constraint"`
	Expected   string `json:"expected"`
	Breaks     bool   `json:"breaks,omitempty"`
	// Request is the id of the request this item is about, on a descriptor's exclusion an approver
	// declined, and RequestURL its address in the console, where the server knows that. What the
	// approver said is read there and not carried here: this item reaches CI logs.
	Request    string `json:"request,omitempty"`
	RequestURL string `json:"requestUrl,omitempty"`
}

PolicyItem is one thing a verdict checked.

func (PolicyItem) ReadAt added in v0.171.0

func (i PolicyItem) ReadAt() string

ReadAt is where to read the request behind the item, for the line under it: its address, its id where the server knows no address, and empty for an item about no request.

func (PolicyItem) String added in v0.149.0

func (i PolicyItem) String() string

String is the item as every surface shows it: `failOn: P1 · required: P2 or stricter`.

type PolicyOutcome added in v0.149.0

type PolicyOutcome struct {
	// Schema is the shape's version. A field added beside the rest does not raise it.
	Schema int `json:"schema"`
	// Project is the project the token belongs to, whose policy this is.
	Project string `json:"project,omitempty"`
	// PolicyVersion is the version of the organization's policy judged against, 0 where nothing is
	// written down.
	PolicyVersion int `json:"policyVersion"`
	// Paused says an organization-wide pause stood, so no setting acted.
	Paused bool `json:"paused,omitempty"`
	// Outcome is the strongest act among the verdicts: refuse, then fail, then none.
	Outcome string `json:"outcome"`
	Passed  bool   `json:"passed"`
	// Pending, on the answer to a published run's policy, says the server has not decided every
	// setting yet, so Outcome and Passed cover only the settings decided so far.
	Pending  bool            `json:"pending,omitempty"`
	Verdicts []PolicyVerdict `json:"verdicts,omitempty"`
}

PolicyOutcome is what an organization's policy makes of one run, or of one descriptor before its run, as a draugr-api server answers it.

The server judges and words every part of it. Draugr holds no rule logic: it renders the items and terms it is given and acts on Outcome, so a rule the organization changes reaches every client without a release, and two versions of Draugr cannot disagree about one.

func (PolicyOutcome) Summary added in v0.149.0

func (p PolicyOutcome) Summary(act string) string

Summary is the outcome's broken verdicts as one line each, for an error message.

func (PolicyOutcome) Undecided added in v0.158.0

func (p PolicyOutcome) Undecided() bool

Undecided reports whether a setting is still to be decided: the answer says it is pending, or a verdict does.

type PolicyVerdict added in v0.149.0

type PolicyVerdict struct {
	Rule    string `json:"rule"`
	Profile string `json:"profile"`
	// State is violates, meets, not_evaluated or not_applicable. Words for the API only: a reader is
	// shown a mark and the items.
	State string `json:"state"`
	// Detail says, for a violation, how many items break, and for a verdict not evaluated, what
	// was missing.
	Detail string `json:"detail,omitempty"`
	// Items are what the verdict checked, broken ones first, a passing verdict's as well.
	Items []PolicyItem `json:"items,omitempty"`
	// Mode, EnforceFrom and Response are the setting's own terms.
	Mode        string `json:"mode,omitempty"`
	EnforceFrom string `json:"enforceFrom,omitempty"`
	Response    string `json:"response,omitempty"`
	// ProfileState is active, or observing where the setting observes whatever its mode.
	ProfileState string `json:"profileState,omitempty"`
	// Override names what made an enforce setting observe: profile-observing, paused, or
	// not-on-plan where the organization's plan does not include enforcement. Any override means
	// the setting observes, so one this version does not know still reads as observed.
	Override string `json:"override,omitempty"`
	// InForce says the setting acts: enforced, its date reached, the profile active, no pause.
	InForce bool `json:"inForce,omitempty"`
	// Acts is what the verdict does to the run: refuse, fail or none.
	Acts string `json:"acts,omitempty"`
	// Pending marks, on a publish answer, a setting in force that is decided once the run's
	// evidence is expanded, after the answer.
	Pending bool `json:"pending,omitempty"`
}

PolicyVerdict is one rule under one profile, judged.

func (PolicyVerdict) Breaking added in v0.149.0

func (v PolicyVerdict) Breaking() []PolicyItem

Breaking is the verdict's broken items, or every item where none is marked.

func (PolicyVerdict) Evaluated added in v0.149.0

func (v PolicyVerdict) Evaluated() bool

Evaluated reports whether the verdict could be judged: it either holds or is broken.

func (PolicyVerdict) Term added in v0.149.0

func (v PolicyVerdict) Term() string

Term is what the setting does to a run that breaks it, in the phrases every surface uses: `observed`, `fails the gate, since 2026-10-01`, `refuses from 2026-12-01`, `observed, profile observing`, `observed, enforcement not on the plan`.

func (PolicyVerdict) Violates added in v0.149.0

func (v PolicyVerdict) Violates() bool

Violates reports whether the run or descriptor breaks the setting.

type Provenance added in v0.106.0

type Provenance struct {
	Descriptor *DescriptorRef
	CI         *ci.Context
	// Gate is the policy the verdict was judged against. Absent on a document written by a caller
	// that did not have it, which is why the field it renders is omitted rather than defaulted: a
	// consumer must be able to tell "the gate was the default" from "nobody said".
	Gate *Gate
	// Build is the Draugr that produced the run, and the commit it was built from. Known only to
	// the command that ran, and gone when the process exits.
	Build *Build
	// Actions are the run's findings grouped into things to do. Grouped by the caller, because the
	// grouping is report's and report renders through this package.
	Actions []Action
	// Policy is the pre-flight's check against the organization's policy, nil where none was asked
	// for.
	Policy *PolicyCheck
	// FailedCaveats are the run's caveats of a kind the gate fails on. Decided by the caller,
	// because a caveat is read off the report's own data.
	FailedCaveats []FailedCaveat
	// NotChecked and UnboundImports are the run's caveats of those two kinds, every one of them.
	NotChecked     []NotChecked
	UnboundImports []UnboundImport
	// Found is what the run read from its repositories to turn its controls on, nil where the
	// descriptor named them itself.
	Found []Found
	// ComponentLabels is each declared component's labels by name, with an entry for every
	// component the descriptor declares, labeled or not.
	ComponentLabels map[string]map[string]string
}

Provenance is what produced a run, as opposed to what it found.

Grouped rather than added as three more parameters: these travel together, and the renderer's signature is already long enough that a caller passing them in the wrong order would compile.

type ScannerData added in v0.152.0

type ScannerData struct {
	Tool       string     `json:"tool"`
	Data       string     `json:"data"`
	Version    string     `json:"version,omitempty"`
	Published  *time.Time `json:"published,omitempty"`
	Downloaded *time.Time `json:"downloaded,omitempty"`
	TooOld     string     `json:"tooOld,omitempty"`
}

ScannerData is one data source a run read, as report.json and `draugr doctor --json` write it. A time a tool does not report is absent rather than written as some other time.

func ScannerDataFrom added in v0.152.0

func ScannerDataFrom(ds []engine.ScannerData) []ScannerData

ScannerDataFrom is the written form of each data source, nil for none.

type ScopedImport added in v0.181.0

type ScopedImport struct {
	// Component is the component that imported it.
	Component string `json:"component,omitempty"`
	// File is the imported file, as the descriptor names it.
	File string `json:"file"`
	// Controls are the controls that read it.
	Controls []string `json:"controls,omitempty"`
	// OutsidePaths counts the findings left out because their file is outside the paths: of the
	// repository they were placed in.
	OutsidePaths int `json:"outsidePaths,omitempty"`
	// Ignored counts the findings left out because that repository's ignore: matches their file.
	Ignored int `json:"ignored,omitempty"`
	// NotScoped counts the findings kept whole because the file establishes no one repository of the
	// component's, whose scope would apply. They are in the report and counted.
	NotScoped int `json:"notScoped,omitempty"`
	// Folded counts the findings that repeated another of the file's exactly and were counted once.
	Folded int `json:"folded,omitempty"`
}

ScopedImport is one imported SARIF file in one component where the import did not count every finding the file lists as one of its own: a repository's paths: or ignore: left a finding out or could not be applied to one, or a finding repeated another exactly and was counted once.

type UnboundImport added in v0.174.0

type UnboundImport struct {
	// Component is the component that imported it.
	Component string `json:"component,omitempty"`
	// File is the imported file, as the descriptor names it, or for a service's alerts the service,
	// `Dependabot`.
	File string `json:"file"`
	// Controls are the controls that read it.
	Controls []string `json:"controls,omitempty"`
	// Reason is why, in the words the report prints.
	Reason string `json:"reason"`
}

UnboundImport is an unbound-imports caveat: an imported SARIF file that names no commit.

Jump to

Keyboard shortcuts

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