pub struct PatternLimits {
pub max_pattern_depth: usize,
pub max_fields_per_pattern: usize,
pub arena_byte_budget: usize,
pub max_states_per_pattern: usize,
}Expand description
Limits on pattern complexity to prevent OOM and stack exhaustion.
Four complementary limits, each catching a different attack vector:
- Nesting depth: prevents stack exhaustion and deep-nesting attacks
- Field count: prevents wide patterns with hundreds of fields
- Arena byte budget: essential backstop that catches all forms of automaton complexity
- State count: prevents exponential field-matcher blowup from mixed-type matchers
§Defaults
max_pattern_depth: 256 (jq precedent)max_fields_per_pattern: 256arena_byte_budget: 10 MB (regex crate precedent)max_states_per_pattern: 1024
Fields§
§max_pattern_depth: usizeMaximum nesting depth of a pattern (default: 256)
max_fields_per_pattern: usizeMaximum number of fields per pattern (default: 256)
arena_byte_budget: usizeMaximum arena byte size for the automaton (default: 10 MB)
max_states_per_pattern: usizeMaximum number of field-matcher states during pattern construction (default: 1024).
When a field has N mixed-type matchers (e.g. exact + prefix), the state count multiplies by N for each such field. With K fields of N matchers each, states grow as N^K. This limit caps the product to prevent exponential memory blowup. All-exact fields use a bulk optimization that doesn’t multiply states, so this limit only affects patterns mixing matcher types on the same field.
Trait Implementations§
Source§impl Clone for PatternLimits
impl Clone for PatternLimits
Source§fn clone(&self) -> PatternLimits
fn clone(&self) -> PatternLimits
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more