recognize

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package recognize routes parsed input to modules. It combines two sources: gitleaks (the broad net for prefixed/checksummed single strings) and a registry of custom recognizer funcs for the set-shaped and file-shaped credentials gitleaks handles poorly. Modules register their rule mappings and custom recognizers here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRecognizer

func RegisterRecognizer(f RecognizerFunc)

RegisterRecognizer adds a custom recognizer (called by modules in init()).

Types

type Match

type Match struct {
	Module string        // module name
	Fields module.Fields // extracted inputs (token, secret, tenant, endpoint, …)
	Secret string        // raw secret, for redaction in the note title
	Label  string        // where it came from, e.g. ".env: GITHUB_TOKEN"
	Line   int           // 1-based source line, 0 if unknown
	// Overrides lists module names this match supersedes for the same credential
	// (matched by secret containment). Lets a structured recognizer suppress a
	// broad-net hit that misattributed the same value — e.g. a WorkOS key claimed
	// over the gitleaks Stripe rule it collides with.
	Overrides []string
}

Match is a recognized credential routed to a module.

func Recognize

func Recognize(b parse.Blob, endpoint string, reg *module.Registry) []Match

Recognize returns all matches for a blob: gitleaks hits routed by rule id, plus every custom recognizer's matches. Matches are deduped by (module, secret) keeping the richest one, and generic "unknown" matches whose value is already consumed by a recognized set/file match are suppressed as noise.

type RecognizerFunc

type RecognizerFunc func(b parse.Blob, endpoint string, reg *module.Registry) []Match

RecognizerFunc inspects a parsed blob and returns any matches. endpoint is the --endpoint override (may be empty). reg lets a recognizer check which rule names route to modules.

Jump to

Keyboard shortcuts

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