allowlist

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 10 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 allowlist derives an entry's allowlist (a mirror entry's security/allowlist.yaml, a build entry's security/allowlists/<name>.yaml) from the blocking findings of a fresh scan, and lints any allowlist against the accepted-risk policy — mirror and build share both halves, so the two apply identical rules. Hand-curating a per-CVE list stops being review and starts being transcription once images bump on their own schedule — so the machine transcribes, and the PR review is where the risk is actually accepted.

Three rules make the regenerated file trustworthy rather than a rubber stamp: findings that no longer appear are DROPPED (a stale accept is indistinguishable from a live one); surviving entries KEEP their original expired_at (regeneration must never roll the clock forward — the expiry is the whole forcing function; new entries get today+newDays); and per-entry notes are preserved verbatim (statements are machine facts, human reachability analysis lives in notes).

Everything here is pure — findings in, entries and rendered bytes out — except Regenerate, which writes the rendered file. The wall clock is a parameter, and derivation runs only on the explicit update paths (mirror upgrade, build --update-allowlists) — never validate — because the finding set moves with the vulnerability databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Active added in v0.12.0

func Active(a *spec.Allowlist, today time.Time) *spec.Allowlist

Active returns the entries still in force today: an expiry that parses and lies after today. Suppression with a lapsed or malformed entry would accept a risk nobody re-reviewed.

func Render

func Render(entries []spec.AllowlistEntry, preamble string) []byte

Render produces a mirror allowlist file under MirrorBanner.

func RenderBanner added in v0.12.0

func RenderBanner(banner Banner, entries []spec.AllowlistEntry, preamble string) []byte

RenderBanner produces the generated allowlist file: the GENERATED banner, the entry's preamble as comments, then the entries. expired_at is always double-quoted, matching the hand-written allowlists' style so an entry opting in produces no gratuitous diff.

Types

type Banner string

Banner is the GENERATED comment block atop a rendered allowlist: who regenerates the file, from what, and where its whole-file context lives.

const (
	MirrorBanner Banner = "# GENERATED by patchy mirror — do not hand-edit the entries.\n" +
		"# Regenerated by `patchy mirror upgrade` from a fresh scan of the locked images:\n" +
		"# findings that no longer appear are dropped, surviving entries keep their\n" +
		"# original expired_at (renewed once it has lapsed), and per-entry notes are\n" +
		"# preserved. Whole-file context lives in scan.allowlist.preamble in\n" +
		"# manifest.yaml; per-finding analysis goes in a \"notes\" field on the entry.\n"
	BuildBanner Banner = "# GENERATED by patchy build — do not hand-edit the entries.\n" +
		"# Regenerated by `patchy build --update-allowlists` from a fresh scan of the built\n" +
		"# image: findings that no longer appear are dropped, surviving entries keep their\n" +
		"# original expired_at (renewed once it has lapsed), and per-entry notes are\n" +
		"# preserved. Whole-file context lives in the build entry's\n" +
		"# scan.allowlist.preamble; per-finding analysis goes in a \"notes\" field on the entry.\n"
)

The two generators' banners. MirrorBanner is byte-for-byte the text every committed mirror allowlist already carries, so regeneration never churns it.

type Finding

type Finding struct {
	// ID is the primary identifier the scanner reported (CVE, GHSA, GO-...).
	ID string
	// Package is the affected artifact name.
	Package string
	// Installed is the version the locked image ships.
	Installed string
	// FixedIn lists the advisory's fixed versions across release branches.
	FixedIn []string
}

Finding is one blocking (already severity-filtered) scan finding for one image. The same ID appears once per image reporting it; derivation aggregates them.

func Rows added in v0.12.0

func Rows(blocking []scan.Finding) []Finding

Rows converts policy-filtered scan findings into derivation rows.

type Issue added in v0.12.0

type Issue struct {
	// ID is the offending entry's id (empty when the id itself is missing).
	ID string
	// Expired marks the lapsed-expiry violation. Mirror lint fails on it
	// like any other issue; build reports it and stops suppressing with
	// the entry, so a lapsed acceptance blocks the publish instead.
	Expired bool
	// Message is the human-readable violation.
	Message string
}

Issue is one accepted-risk policy violation in an allowlist.

func Lint added in v0.12.0

func Lint(a *spec.Allowlist, today time.Time, maxDays int) []Issue

Lint enforces the accepted-risk policy: every entry carries an id, a statement and a parseable expiry, expiries are in the future (re-review on schedule is the whole forcing function) and within maxDays of today.

func (Issue) String added in v0.12.0

func (i Issue) String() string

String implements fmt.Stringer.

type Renewal added in v0.11.3

type Renewal struct {
	ID string
	// ExpiredAt is the lapsed date the previous file carried.
	ExpiredAt string
}

Renewal records a surviving entry whose expiry had already lapsed and was restamped like a new acceptance.

type Stats

type Stats struct {
	Kept    int
	Renewed []Renewal
	Added   int
	Dropped []string
}

Stats summarizes one derivation for narration.

func Derive

func Derive(findings []Finding, prev *spec.Allowlist, today time.Time, newDays int) ([]spec.AllowlistEntry, Stats)

Derive regenerates the allowlist entries from findings against the previous file. Entries come out sorted by ID; surviving IDs keep their previous expiry and notes, new IDs expire newDays after today, and previous IDs no longer reported are dropped (returned in Stats). A surviving entry whose expiry is on or before today (lint's boundary) is renewed to the new-entry expiry instead: it already blocks lint, and the date change surfaces in the upgrade diff for review. Unexpired entries never move, so regeneration cannot roll a live acceptance forward.

func Regenerate added in v0.12.0

func Regenerate(path string, banner Banner, rows []Finding, prev *spec.Allowlist,
	now time.Time, newDays int, preamble string) (Stats, error)

Regenerate derives the allowlist from rows against prev, renders it under banner and writes it to path, creating the directory. This is the derive-render-write half both generators share; scanning and the policy filter that produced rows are the caller's.

Jump to

Keyboard shortcuts

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