matcher

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 5 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 matcher provides Aho-Corasick based keyword pre-filtering. It builds an automaton from detector keywords and efficiently identifies which detectors are relevant for a given chunk of data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

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

Matcher performs Aho-Corasick keyword pre-filtering to determine which detectors should be run against a given chunk of data.

func New

func New(detectors []detector.Detector) *Matcher

New builds an Aho-Corasick automaton from the given detectors' keywords. Detectors with no keywords are always included in match results.

func (*Matcher) Match

func (m *Matcher) Match(data []byte) []detector.Detector

Match returns the subset of detectors whose keywords appear in the data. Detectors without keywords are always included.

Match is safe for concurrent use by multiple goroutines: a single Matcher is shared across all engine workers, so the underlying Aho-Corasick automaton is queried via the thread-safe MatchThreadSafe entry point (see below). The non-thread-safe Match method of the ahocorasick library mutates shared trie node counters and would otherwise cause a data race and silently drop matches (missed secrets) under concurrent calls.

Jump to

Keyboard shortcuts

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