Skip to main content

Module scan_window

Module scan_window 

Source
Expand description

Bounded scan windows ported from guard_core/detection_engine/scan_window.py (spec 4.0.2).

Several built-in detection patterns have the shape literal_prefix + unbounded_negated_class + terminator. When the terminator is absent, the regex engine rescans to end-of-input from every prefix occurrence, which is quadratic in input length. This module locates prefix and terminator occurrences with linear passes, then runs the caller’s UNMODIFIED pattern against a bounded span per prefix candidate: from that candidate to the rightmost terminator occurrence reachable from it. The pattern itself is never rewritten.

Functions§

bounded_finditer
bounded_finditer_guarded
bounded_finditer with a per-candidate guard (the reference runs the UNMODIFIED pattern inside the window; a guard failure abandons the prefix candidate exactly like a failed window match).