matcher

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 4 Imported by: 0

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