Documentation
¶
Overview ¶
Package report turns verdicts into something a human reads at 2am.
Index ¶
- Constants
- func Explain(w io.Writer, v model.Verdict)
- func JSON(w io.Writer, vs []model.Verdict, opt JSONOptions) error
- func Policy(w io.Writer, res policy.Result, source string)
- func Probe(w io.Writer, dis []probe.Disagreement, source string)
- func RenderRule(r facts.Rule) string
- func Table(w io.Writer, vs []model.Verdict, warns []facts.Warning)
- type JSONOptions
Constants ¶
const SchemaVersion = 1
SchemaVersion is the version of the verdict document JSON writes. It is deliberately its own number, not facts.SchemaVersion: that one describes what was collected, this one describes what was concluded, and the two change for different reasons.
Variables ¶
This section is empty.
Functions ¶
func Policy ¶ added in v0.3.0
Policy prints what the policy made of the verdicts, under the table they came from. It prints in every output mode, so an exit code the policy produced is never one the reader cannot see a reason for.
func Probe ¶ added in v0.4.0
func Probe(w io.Writer, dis []probe.Disagreement, source string)
Probe prints what a probe run found that the model did not, which is the whole reason to run one. A disagreement means either the model is missing something or something upstream is, and which one decides where the reader goes looking, so the diagnosis prints with it rather than leaving them to work it out from two verdicts.
func RenderRule ¶
RenderRule reconstructs an nft-like one-liner from the stored expressions. It is for human eyes only: whyopen never re-emits a rule.
Types ¶
type JSONOptions ¶ added in v0.4.0
type JSONOptions struct {
Version string
Hostname string
Zone string
Warnings []facts.Warning
Policy *policy.Result
PolicySource string
// WithPath includes the ordered rule path of every verdict. It is the
// expensive half of the document and only --explain asks for it.
WithPath bool
// ProbeSource and Disagreements describe a probe run. The
// disagreements are the part a reader cannot derive from the verdicts,
// because they are about the verdicts being wrong.
ProbeSource string
Disagreements []probe.Disagreement
}
JSONOptions is everything the document carries beyond the verdicts themselves. All of it is optional: a field nothing was given for is absent from the output rather than present and empty, so a consumer can tell "no policy was consulted" from "a policy found nothing".