Skip to main content

Crate multimatch

Crate multimatch 

Source
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§

MatchEngine
Compiled matching engine.
MatchResult
A match result from scanning.
PatternDef
A single pattern to match against.
PatternSet
A compiled set of patterns ready for scanning.
PatternSetBuilder
Builder for constructing a PatternSet.

Enums§

MatchError
Trait for types that can scan inputs for multiple patterns. Errors from pattern compilation or scanning.
PatternKind
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.