Help us shape the future of Go! Take the 2026 Go Developer Survey

severity

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: AGPL-3.0, AGPL-3.0-only Imports: 1 Imported by: 0

Documentation

Overview

Package severity is the vulnerability domain's severity vocabulary: normalization, ranking, and ordering of the well-known labels (critical, high, medium, low, unknown). It models vulnerability SEVERITY LABELS — the normalized vocabulary shared by OSV, Trivy, Grype, and friends — NOT CVSS scores or vectors. It is dependency-free so any vulnerability-producing module can depend DOWN on it.

This is deliberately NOT a universal severity scale for StageFreight. Other domains (lint diagnostic importance, and later license/quality/etc.) own their OWN ordered vocabularies. The shared thing across modules is the evaluation PIPELINE and the fail_on policy algorithm — never a single scale. The typed Severity keeps this vocabulary compile-time non-interchangeable with, e.g., lint's importance tiers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b Severity) int

Compare orders two severities by rank: POSITIVE means a is more severe than b, zero equal, negative less. Pure vocabulary — no policy. Policy sites express a threshold as, e.g., `Compare(finding, failOn) >= 0` ("at least as severe as the gate").

func Order

func Order(s Severity) int

Order returns an ascending sort key where the MOST severe sorts FIRST (critical=0, high=1, medium=2, low=3, unknown=4) — the inverse of Rank, for severity-descending displays.

func Rank

func Rank(s Severity) int

Rank maps a severity to a comparable rank where HIGHER is worse (critical=4, high=3, medium=2, low=1, unknown=0). Normalizes defensively, so an unnormalized value still ranks correctly.

Types

type Severity

type Severity string

Severity is a vulnerability severity label. Typed (not a bare string) so it cannot be silently crossed with another domain's ordered vocabulary.

const (
	Critical Severity = "CRITICAL"
	High     Severity = "HIGH"
	Medium   Severity = "MEDIUM"
	Low      Severity = "LOW"
	Unknown  Severity = "UNKNOWN"
)

The canonical vulnerability severity vocabulary.

func Normalize

func Normalize(label string) Severity

Normalize canonicalizes any raw label (a scanner's output, a config value) to a Severity. It folds the OSV "MODERATE" onto Medium and maps empty or unrecognized input to Unknown. This is the one entry point from raw strings.

Jump to

Keyboard shortcuts

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