report

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package report turns verdicts into something a human reads at 2am.

Index

Constants

View Source
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 Explain

func Explain(w io.Writer, v model.Verdict)

Explain prints the ordered rule path behind one verdict.

func JSON added in v0.4.0

func JSON(w io.Writer, vs []model.Verdict, opt JSONOptions) error

JSON writes the verdict set as a versioned document.

func Policy added in v0.3.0

func Policy(w io.Writer, res policy.Result, source string)

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

func RenderRule(r facts.Rule) string

RenderRule reconstructs an nft-like one-liner from the stored expressions. It is for human eyes only: whyopen never re-emits a rule.

func Table

func Table(w io.Writer, vs []model.Verdict, warns []facts.Warning)

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".

Jump to

Keyboard shortcuts

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