Skip to content

fix: fail closed on invalid regex predicates (#79) - #81

Merged
ababic merged 2 commits into
mainfrom
cursor/regex-fail-closed-predicates-1aeb
Aug 14, 2026
Merged

ababic merged 2 commits into
mainfrom
cursor/regex-fail-closed-predicates-1aeb

Conversation

@ababic

@ababic ababic commented Aug 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #79: regex / iregex predicates previously failed open — invalid or unsupported patterns (including lookaround) compiled to a never-match regex ($^), so configs appeared to work while matching nothing.

Rebased onto latest main (includes keep strategy from #77/#78 and docs from #82). Conflict in src/sql.rs resolved by keeping both the keep pipeline test and the new not_ilike scrub-unless-staff test.

Changes

  • Fail closed at config load: compile every regex / iregex / not_regex / not_iregex pattern during validation; reject unknown predicate ops.
  • Remove silent $^ fallback in the runtime regex cache (panic if an unvalidated pattern somehow slips through).
  • New negation ops: not_like, not_ilike, not_regex, not_iregex so “match unless …” policies don’t need lookaround.
  • lint-policy: compile-check the same patterns (invalid-regex-predicate); invalid configs also fail before lint because load validation rejects them.
  • Docs: README documents the Rust regex crate (not PCRE), lookaround limits, and points at keep / not_ilike alternatives.

Tests

  • Config load rejects unterminated and lookaround patterns with actionable errors.
  • Filter + SQL pipeline tests for not_ilike / not_iregex scrub-unless-staff behavior (issue repro dump).
  • Existing keep staff-email pipeline test retained after rebase.
  • Lint catalog includes invalid-regex-predicate.

CI

cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, and cargo test --all-targets --all-features (161 passed) all pass locally after rebase.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 14, 2026 15:53
Reject unsupported/invalid regex/iregex patterns at config load instead of
silently matching nothing. Add not_like/not_ilike/not_regex/not_iregex so
"match unless" policies do not need lookaround. Document the Rust regex
crate limits and compile patterns in lint-policy.

Co-authored-by: andy <andy@wearecrew.com>
Align #79 docs with the keep strategy cookbook now on main: prefer keep
for small allowlists, and point at not_ilike/not_iregex as the fail-closed
alternative to lookaround.

Co-authored-by: andy <andy@wearecrew.com>
@cursor
cursor Bot force-pushed the cursor/regex-fail-closed-predicates-1aeb branch from 7ea1936 to 02d7a88 Compare August 14, 2026 15:54
@ababic
ababic marked this pull request as ready for review August 14, 2026 15:55
@ababic
ababic merged commit 623ba4c into main Aug 14, 2026
10 checks passed
@ababic
ababic deleted the cursor/regex-fail-closed-predicates-1aeb branch August 14, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iregex/regex: lookaround patterns never match; invalid patterns fail open

2 participants