norn

package
v0.124.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package norn evaluates scan results against policy to produce a verdict (pass/fail) per control and overall. It begins with declarative severity thresholds; a richer policy language (e.g. OPA/Rego) can follow.

The Norns decide fate, here, the fate of a release.

Index

Constants

View Source
const DefaultPriority = "P1"

DefaultPriority is the band a run fails on when its policy names no threshold of its own.

The product's own ranking rather than the scanner's: severity rates a flaw in the abstract, and priority folds in what the descriptor says about the component it was found in, which is the thing no scanner can compute. A tool whose default gate is the number a scanner printed is a tool whose central claim is off by default.

Variables

This section is empty.

Functions

This section is empty.

Types

type ControlOutcome

type ControlOutcome struct {
	Control         string
	Verdict         Verdict
	Highest         sarif.Severity
	HighestPriority string
	Counts          sarif.Counts
	Threshold       sarif.Severity
}

ControlOutcome is the verdict for a single control.

type Policy

type Policy struct {
	FailOn         sarif.Severity
	PerControl     map[string]sarif.Severity
	FailOnPriority string
	// PerControlBand overrides the band for named controls, and is the band gate's half of
	// PerControl.
	//
	// Two maps rather than one, because a threshold is only meaningful in the vocabulary the gate
	// asks in, and FailOn and FailOnPriority are already a pair for the same reason. A single map
	// would hold values that mean nothing to the gate reading it, which is how a per-control
	// threshold came to be written, reviewed, and dropped without a word.
	PerControlBand map[string]string
}

Policy decides verdicts from findings. A control fails when its most severe finding is at least as severe as the applicable threshold. FailOn is the default threshold; PerControl overrides it for named controls.

**A run has one gate.** Either it asks what a finding's own severity is, or it asks what band that finding lands in for this component, and those are two different questions about the same finding. Answering both meant a verdict had two possible reasons, and "why did this fail" could not be answered from the policy alone, which is how a failure on the default severity threshold came to be read as the priority gate somebody had actually configured.

So FailOn and FailOnPriority are exclusive. The zero value gates on **P1**, which is the product's own ranking rather than the scanner's, and setting FailOn is how a caller says it wants the scanner's number instead.

Thresholds are severity bands, the ladder the report prints, rather than SARIF levels. The two are not interchangeable: a finding with a CVSS score takes its band from the score, so one a scanner emitted as `warning` can be `high`. Gating on the level let such a finding pass a gate its reader believed was set to catch it, with the report beside it saying `high`.

FailOnPriority adds component-aware gating: when set (e.g. "P1"), a control also fails if any of its findings has a priority band at least that urgent. Because a finding's priority already combines its severity with its component's exposure and criticality, this gates per component without a separate per-component threshold.

func (Policy) Evaluate

func (p Policy) Evaluate(reports map[string]sarif.Report) Result

Evaluate judges each control's report against the policy and combines them. The overall verdict is Fail if any control fails.

Controls come back in **alphabetical order**, not the order the map happened to yield. Go randomizes map iteration, so without sorting here the same scan prints its Controls block, and writes its report.json, markdown and HTML, in a different order each run. That makes two runs of an unchanged repository diff against each other, which is the opposite of what an artifact offered as evidence is for, and it contradicts the promise that the same input gives the same answer.

Alphabetical rather than, say, worst-first: it is stable as controls are added, and it matches how the catalog and the docs list them.

func (Policy) GatesOnSeverity added in v0.116.0

func (p Policy) GatesOnSeverity() bool

GatesOnSeverity reports whether this policy judges a finding's own severity rather than the band it landed in.

Set by asking: naming a threshold, globally or for one control, is what chooses the question. Nothing named means the default, which is the priority band.

func (Policy) PriorityBand added in v0.116.0

func (p Policy) PriorityBand() string

PriorityBand is the band this policy fails on, or empty where it gates on severity instead.

type Result

type Result struct {
	Verdict  Verdict
	Controls []ControlOutcome
}

Result is the overall evaluation across all controls.

type Verdict

type Verdict string

Verdict is the outcome of a policy evaluation.

const (
	Pass Verdict = "pass"
	Fail Verdict = "fail"
)

The possible verdicts.

Jump to

Keyboard shortcuts

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