Expand description
§multimatch
Multi-pattern matching engine for security scanning.
Every security tool needs to search text for many patterns simultaneously: secret scanners match 1000+ credential regexes, vulnerability scanners match response signatures, taint analyzers match sink patterns.
This crate provides a unified interface for the currently implemented backend:
- Aho-Corasick + regex — always available, zero external dependencies
§Usage
use multimatch::{PatternSet, MatchResult};
let patterns = PatternSet::builder()
.add_literal("password", 0)
.add_literal("secret", 1)
.add_regex(r"[A-Za-z0-9]{32,}", 2)
.build()
.unwrap();
let matches = patterns.scan(b"my password is abc123secretXYZ");
assert!(matches.iter().any(|m| m.pattern_id == 0)); // "password"
assert!(matches.iter().any(|m| m.pattern_id == 1)); // "secret"Modules§
- prelude
- Prelude module
Structs§
- Match
Engine - Compiled matching engine.
- Match
Result - A match result from scanning.
- Pattern
Def - A single pattern to match against.
- Pattern
Set - A compiled set of patterns ready for scanning.
- Pattern
SetBuilder - Builder for constructing a
PatternSet.
Enums§
- Match
Error - Trait for types that can scan inputs for multiple patterns. Errors from pattern compilation or scanning.
- Pattern
Kind - Whether a pattern is a literal string or a regex.
Functions§
- from_
literal_ pairs - Convenience: compile a set of patterns given as (pattern, id) pairs.
- from_
literals - Convenience: compile a set of literal strings for matching.
- from_
regexes - Convenience: compile a set of regex patterns for matching.
- from_
regexes_ pairs - Convenience: compile regex pairs.