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
- Variables
- func MergedSARIF(run engine.Result) sarif.Report
- func MinPriorityOfReport(rep sarif.Report) (string, bool)
- func MinPriorityProvenance(band string) (sarif.Provenance, bool)
- func RenderJSON(w io.Writer, release saga.Release, run engine.Result, verdict norn.Result, ...) error
- func RenderJSONFor(w io.Writer, project string, release saga.Release, run engine.Result, ...) error
- func RenderJSONWith(w io.Writer, release saga.Release, run engine.Result, verdict norn.Result, ...) error
- func RenderJSONWithFeeds(w io.Writer, release saga.Release, run engine.Result, verdict norn.Result, ...) errordeprecated
- func ScopeOfReport(rep sarif.Report) (string, bool)
- func ScopeProvenance(scope engine.Scope) (sarif.Provenance, bool)
- func Strongest(a, b string) string
- func WriteSARIF(w io.Writer, run engine.Result) error
- func WriteSARIFNarrowed(w io.Writer, run engine.Result, band string, opts sarif.MarshalOptions) error
- func WriteSARIFWith(w io.Writer, run engine.Result, opts sarif.MarshalOptions) error
- type Action
- type ActionExploitation
- type ActionFinding
- type ActionKind
- type ActionLocation
- type Build
- type DescriptorRef
- type DescriptorSource
- type Exclusion
- type FailedCaveat
- type FeedProvenance
- type Gate
- type NewFindings
- type PolicyCheck
- type PolicyItem
- type PolicyOutcome
- type PolicyVerdict
- type Provenance
- type ScannerData
Constants ¶
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.
const ( PolicyNone = "none" PolicyFail = "fail" PolicyRefuse = "refuse" )
The acts a policy verdict, and so an outcome, can have.
const MinPriorityProvenanceTool = "draugr/min-priority"
MinPriorityProvenanceTool is the provenance entry a priority-narrowed report stamps on its SARIF.
const ScopeProvenanceTool = "draugr/scope"
ScopeProvenanceTool is the provenance entry a scoped run stamps on its SARIF.
Variables ¶
var WorkOrder = []ActionKind{KindBump, KindCode, KindInfrastructure, KindCredential, KindWait, KindDecide}
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.
Functions ¶
func MergedSARIF ¶
MergedSARIF combines all controls' reports into one SARIF report.
func MinPriorityOfReport ¶ added in v0.82.0
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
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
Strongest is the stronger of two acts: refuse, then fail, then none.
func WriteSARIF ¶
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
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 who does the work and how much it takes, 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 `json:"policy,omitempty"`
// 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"`
// 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 · beyond policy minor` is Beyond and Policy.
Beyond string `json:"beyond,omitempty"`
// 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:"-"`
// 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.
RuleID string `json:"ruleId" jsonschema:"the rule of the finding the signal applies to, a 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"`
}
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: who does it, and how much it takes.
const ( // 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 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"`
// Reason is the entry's reason, so a reader can tell one entry from the next.
Reason string `json:"reason"`
// 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: 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.
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 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 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 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 reports whether any of them met FailOnNew. False where FailOnNew is empty.
Tripped bool
}
NewFindings is a run's comparison with the base scan it was given.
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"`
}
PolicyItem is one thing a verdict checked.
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 or paused.
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`.
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
// 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.