filter

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package filter classifies Renovate autodiscoverFilter values and reports whether they can be bypassed by an attacker-controlled repository path.

It ports the pattern-matching semantics of Renovate's matchRegexOrGlobList / isRegexMatch helpers so that verdicts match what the actual bot would do.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	// RuleID identifies the check: "V1"–"V4" for exploitable, "N2"–"N4" for broken/review, "INFO" for informational.
	RuleID string
	// Verdict is the security classification.
	Verdict Verdict
	// Pattern is the offending pattern, empty for list-level findings.
	Pattern string
	// Evidence contains adversarial inputs that passed the filter (probe findings only).
	Evidence []string
	// Message is a human-readable explanation.
	Message string
}

Finding is a single classifier result for one pattern or the filter list as a whole.

func Analyze

func Analyze(filterValue string) []Finding

Analyze parses filterValue (a single pattern string or a JSON array of pattern strings) and returns all findings in order of decreasing severity. Empty or whitespace-only inputs return nil.

type PatternKind

type PatternKind int

PatternKind describes how a single pattern was classified.

const (
	// KindGlob is a plain glob pattern compiled with gobwas/glob.
	KindGlob PatternKind = iota
	// KindRegex is a well-formed regex delimited by /…/ or /…/i.
	KindRegex
	// KindMalformedRegexFallback looks like a regex (leading/trailing /) but
	// its body fails RE2 compilation. Renovate silently degrades to glob here.
	KindMalformedRegexFallback
)

type Verdict

type Verdict int

Verdict classifies the security impact of a finding.

const (
	// Safe means the filter appears structurally sound.
	Safe Verdict = iota
	// Vulnerable means an attacker-controlled path can bypass the filter.
	Vulnerable
	// Broken means the filter is syntactically wrong and silently does nothing.
	Broken
	// NeedsReview means the pattern is ambiguous (e.g., RE2 vs JS divergence).
	NeedsReview
)

func (Verdict) String

func (v Verdict) String() string

String returns a human-readable label for structured log fields.

Jump to

Keyboard shortcuts

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