DLP injection-check perf, bounded variant cache, dedup supervise schema #312
Reference in New Issue
Block a user
Delete Branch "dlp-supervise-quality-fixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Addresses three findings from a quality eval of the DLP / supervise core. No behavior change to the egress decision surface; tests added for the rewritten proximity path.
dlp_detectors._closest_pair— linearize + early-out. The naive-injection detector's disclosure×jailbreak proximity check ran anO(n*m)cross product over regex matches in attacker-controlled response bodies that have already passed the body-size cap — a latent DoS. Replaced with anO(n log n)sort +O(n)two-pointer merge (advance the span that ends first), with an early-out once any pair falls insidePROXIMITY_CHARS. Extracted_match_gapso the caller reuses the same span-gap calculation._compute_encoded_variantswas memoized in an unbounded module-level dict; a long-lived proxy seeing rotating secrets would grow it without limit. Swapped to a boundedfunctools.lru_cache(maxsize=256).egress-allowandegress-blockcarried a ~40-lineroutes_yamlinputSchemablock duplicated verbatim (silent-drift risk). Extracted_ROUTES_YAML_DESCRIPTION+_proposal_input_schema()as a single source of truth.Tests
scan_naive_injectioncases: a near pair hidden among far-apart matches still blocks (exercises the merge, not just first-of-each-list); many far-apart matches staywarn.