suppress

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 16 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 suppress applies accepted findings to an engine report: ignore rules (from .upgradescope.yaml or ClusterReadiness spec.ignore) and the ignore object annotation (apigroup.IgnoreAnnotation) move findings, or single objects of a finding, into Report.Suppressed with the reason given, so they stop counting toward score and verdict but stay visible. It also compares a report with a baseline report (see Baseline).

Index

Constants

View Source
const AnnotationSource = "annotation"

AnnotationSource is SuppressedFinding.Source for annotation suppressions.

View Source
const ConfigFile = ".upgradescope.yaml"

ConfigFile is the config file name scan discovers (see FindConfig).

Variables

This section is empty.

Functions

func Apply

func Apply(r engine.Report, rules []Rule, opts Options) (engine.Report, []string)

Apply returns r with the findings, or listed objects of findings, that rules or object annotations accept moved to Suppressed, and score and verdict recomputed; r itself is not modified, and is returned unchanged when nothing matches. Per finding, rules apply in order and then annotations; the first to match an object takes it.

A rule without object selectors takes the whole finding (unlisted objects included). With selectors it takes the listed objects that match all of them; a finding with no listed objects (add-ons, skew) matches only a namespace selector, and only when every namespace it names matches. A finding all of whose objects are taken, none omitted, leaves Findings; otherwise it stays, with the remaining objects and a note.

The deprecated-API callers folded into an API usage finding (Finding.Callers) are evidence about clients, not about its objects: only a rule without object selectors that takes the finding takes them too. When object selectors or annotations take every object, each caller stands as the deprecated-api-in-use finding it is on its own (engine.Caller.Finding), at its own severity, and is matched against the rules like any finding, so a rule for its key or category, without selectors, still suppresses it. Fail closed: the client calling the removed API may not be the one that wrote the suppressed objects.

The returned warnings name expired rules (which do not apply), invalid rules (skipped), and annotations without a reason (not applied), in that order. Between the rule and the annotation warnings comes one warning for all the objects on the deprecated pre-v0.2.0 annotation keys that annotate a finding of r (see apigroup.LegacyIgnoreWarning), however many there are: a consumer that keeps only the first few warnings still keeps it.

func FindConfig

func FindConfig(scanRoot string) (string, error)

FindConfig returns the config file scan uses when none is named: the one in scanRoot, else the one at the root of the git repository holding scanRoot (the nearest directory upwards with a .git entry), else "".

Types

type Baseline

type Baseline struct {
	// contains filtered or unexported fields
}

Baseline is what a previous JSON report found, for gating only on what is new since. Findings are matched by Key, which is count-free and stable across runs (engine.Finding.Key), and by severity, because a key can escalate (an API removed one minor past the target is a warning; at the target, the same key is a blocker); objects by namespace, name and file, not line, so editing around an object does not make it new.

func ReadBaseline

func ReadBaseline(r io.Reader, schemaVersion int) (Baseline, error)

ReadBaseline parses a JSON report (scan --output json, or --write-baseline) whose schemaVersion is at most schemaVersion. Only its findings count: suppressed entries are not baseline, so a finding whose rule expires is new again.

func (Baseline) Mark

func (b Baseline) Mark(r engine.Report) engine.Report

Mark returns r with every finding's BaselineState set: unchanged when the baseline had its key at the same or a higher severity, every object it lists, and at least as many objects in all (new ones could hide among the unlisted); new otherwise. r itself is not modified.

type Config

type Config struct {
	Ignore []Rule `yaml:"ignore"`
}

Config is the .upgradescope.yaml document.

func LoadConfig

func LoadConfig(file string) (Config, error)

LoadConfig reads and validates a config file. Unknown fields and invalid rules are errors naming the file.

func ParseConfig

func ParseConfig(raw []byte, name string) (Config, error)

ParseConfig parses and validates a config document, as LoadConfig does a file; errors start with name. The server gate reads its config parameter with it.

type Options

type Options struct {
	Now time.Time // decides which rules have expired
	// Source labels rule suppressions and prefixes warnings: the config
	// file path, or "ClusterReadiness spec.ignore".
	Source string
	// FileBase is joined before object file paths when matching file
	// globs: the scanned root relative to the config file's directory, so
	// globs are written relative to the config file.
	FileBase string
}

Options parameterize Apply.

type Rule

type Rule struct {
	Key       string `json:"key,omitempty" yaml:"key,omitempty"`
	Category  string `json:"category,omitempty" yaml:"category,omitempty"`
	Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Name      string `json:"name,omitempty" yaml:"name,omitempty"`
	File      string `json:"file,omitempty" yaml:"file,omitempty"`
	Reason    string `json:"reason" yaml:"reason"`
	Expires   string `json:"expires,omitempty" yaml:"expires,omitempty"`
}

Rule is one ignore entry. It names findings by Key (exact) or Category, optionally narrowed to objects by Namespace, Name and File globs; Reason is required and Expires (YYYY-MM-DD, inclusive, UTC) optional. The same schema is ClusterReadiness spec.ignore.

func (Rule) String

func (r Rule) String() string

String names the rule in warnings: "key eol-addon/ingress-nginx".

func (Rule) Validate

func (r Rule) Validate() error

Validate reports the first problem with r.

Jump to

Keyboard shortcuts

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