policy

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 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 policy turns a scan result into a pass/fail decision and a process exit code. Keeping it separate from the scanner means CI behaviour can change without touching how findings are produced.

Index

Constants

View Source
const (
	ExitOK         = 0 // scan completed and policy passed
	ExitUsage      = 1 // bad flags or configuration
	ExitPolicyFail = 2 // scan completed and policy failed
	ExitIncomplete = 3 // scan could not determine an answer
	ExitInternal   = 4 // the scanner itself broke
)

Exit codes. These are part of the CLI contract; existing values must not be reassigned.

View Source
const FailOnNone = "none"

FailOnNone is the spelling that turns the severity gate off. It is not a severity, so it never reaches ParseSeverity.

Variables

This section is empty.

Functions

func ParseFailOn

func ParseFailOn(s string) (model.Severity, error)

ParseFailOn turns a configured fail_on value into a Policy.FailOn threshold: the empty severity for "none", which turns the gate off, and the parsed severity otherwise

Types

type Decision

type Decision struct {
	Pass     bool
	ExitCode int
	Reason   string
}

Decision is the outcome of applying a policy

type Policy

type Policy struct {
	// FailOn is the lowest severity that fails the build. Empty disables the
	// severity gate.
	FailOn model.Severity

	// FailOnUnknown fails the build when the scan could not complete. This
	// defaults to true, because an unknown result is not a pass.
	FailOnUnknown bool

	// Baseline holds finding IDs that are accepted for now. Baselined findings
	// stay in the report, marked suppressed.
	Baseline map[string]string // finding ID -> reason
}

Policy is the gate applied after a scan

func Default

func Default() Policy

Default is the policy used when nothing is configured. It blocks HIGH findings and incomplete scans so an unattended pipeline does not turn an unknown or serious result green by default.

func (Policy) Apply

func (p Policy) Apply(res *model.ScanResult) Decision

Apply evaluates the gate after suppression has marked findings. This keeps the verdict, exit code, and every serialized copy aligned on which findings still count.

Jump to

Keyboard shortcuts

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