Skip to main content

guard_core_engine/redos/
mod.rs

1//! The pattern-safety chain: the full port of the reference's ReDoS
2//! defenses (`guard_core/detection_engine/_redos_*`).
3//!
4//! Module map (reference -> port):
5//!
6//! | Reference module | Port |
7//! |---|---|
8//! | `_redos_structural_prefilters.py` | [`prefilters`] |
9//! | `_redos_structure_primitives.py` / `_redos_structure_rules.py` / `_redos_structure.py` | [`structure`] |
10//! | `_redos_unreachable_terminator.py` | [`unreachable_terminator`] |
11//! | `_redos_literal_in_wildcard.py` | [`literal_in_wildcard`] |
12//! | `_redos_ambiguous_tail.py` | [`ambiguous_tail`] |
13//! | `_redos_intervals.py` | [`intervals`] |
14//! | `_redos_ignorecase_fold.py` | [`fold`] |
15//! | `re._parser` (op tree) | [`ast`] |
16//! | `_redos_parse_slots.py` | [`parse_slots`] |
17//! | category predicate scan | [`categories`] |
18//! | `_redos_exact_state.py` | [`exact_state`] |
19//! | `_redos_class_intersection.py` | [`class_intersection`] |
20//! | `_redos_repeat_alphabet.py` | [`repeat_alphabet`] |
21//! | `_redos_repeat_prefix_state.py` | [`repeat_prefix_state`] |
22//! | `_redos_prefix_history.py` | [`prefix_history`] |
23//! | `_redos_repeat_lookbehind.py` | [`repeat_lookbehind`] |
24//! | `_redos_repeat_prefix.py` | [`repeat_prefix`] |
25//! | `_redos_repeat_units.py` | [`repeat_units`] |
26//! | `_redos_stray_chooser.py` | [`stray_chooser`] |
27//! | `_redos_reach_probe.py` | [`reach_probe`] |
28//! | `_redos_probe_batches.py` | [`probe_batches`] |
29//! | `_redos_probe_fill.py` | [`probe_fill`] |
30//! | `_redos_cost_arbiter.py` | [`cost_arbiter`] |
31//! | the `python -c` child scripts | [`child`] |
32//! | `compiler.validate_pattern_safety` | [`safety`] |
33
34// The port mirrors the reference's Python control flow closely, which
35// trips a number of pedantic and nursery style lints (const-fn suggestions
36// on reference-shaped helpers, boolean flag structs mirroring the
37// reference's int bitmask, long matcher functions). The tree opts out of
38// those two groups; everything else still denies.
39
40#[allow(clippy::pedantic, clippy::nursery)]
41pub mod ambiguous_tail;
42#[allow(clippy::pedantic, clippy::nursery)]
43pub mod ast;
44#[allow(clippy::pedantic, clippy::nursery)]
45pub mod categories;
46#[allow(clippy::pedantic, clippy::nursery)]
47pub mod child;
48#[allow(clippy::pedantic, clippy::nursery)]
49pub mod class_intersection;
50#[allow(clippy::pedantic, clippy::nursery)]
51pub mod cost_arbiter;
52#[allow(clippy::pedantic, clippy::nursery)]
53pub mod exact_state;
54#[allow(clippy::pedantic, clippy::nursery)]
55pub mod fold;
56#[allow(clippy::pedantic, clippy::nursery)]
57pub mod intervals;
58#[allow(clippy::pedantic, clippy::nursery)]
59pub mod literal_in_wildcard;
60#[allow(clippy::pedantic, clippy::nursery)]
61pub mod literal_runs;
62#[allow(clippy::pedantic, clippy::nursery)]
63pub mod parse_slots;
64#[allow(clippy::pedantic, clippy::nursery)]
65pub mod prefilters;
66#[allow(clippy::pedantic, clippy::nursery)]
67pub mod prefix_history;
68#[allow(clippy::pedantic, clippy::nursery)]
69pub mod probe_batches;
70#[allow(clippy::pedantic, clippy::nursery)]
71pub mod probe_fill;
72#[allow(clippy::pedantic, clippy::nursery)]
73pub mod reach_probe;
74#[allow(clippy::pedantic, clippy::nursery)]
75pub mod repeat_alphabet;
76#[allow(clippy::pedantic, clippy::nursery)]
77pub mod repeat_lookbehind;
78#[allow(clippy::pedantic, clippy::nursery)]
79pub mod repeat_prefix;
80#[allow(clippy::pedantic, clippy::nursery)]
81pub mod repeat_prefix_state;
82#[allow(clippy::pedantic, clippy::nursery)]
83pub mod repeat_units;
84#[allow(clippy::pedantic, clippy::nursery)]
85pub mod safety;
86#[allow(clippy::pedantic, clippy::nursery)]
87pub mod stray_chooser;
88#[allow(clippy::pedantic, clippy::nursery)]
89pub mod structure;
90#[allow(clippy::pedantic, clippy::nursery)]
91pub mod timeout;
92#[allow(clippy::pedantic, clippy::nursery)]
93pub mod unreachable_terminator;
94#[allow(clippy::pedantic, clippy::nursery)]
95pub mod validation_cache;
96
97pub use safety::{
98    SafetyMode, SafetyReason, SafetyVerdict, StructuralRule, default_flags,
99    validate_pattern_safety, validate_pattern_safety_compat, validate_pattern_safety_with_flags,
100};