Filter patterns match in linear time, so a catastrophic regex no longer fails open #277

Merged
claude merged 6 commits from feature/53-nonbacktracking-filters into develop 2026-11-05 03:06:08 -05:00
Owner

Wildcard and regex filter entries now run on .NET's non-backtracking regex engine. Matching takes time linear in the name, so a catastrophic pattern such as ^(a+)+$ can no longer time out and let a name through.

  • A pattern the linear engine refuses (backreferences, lookarounds, atomic groups) keeps the backtracking engine with its 250 ms timeout and the no-match rule.
  • Which patterns count as valid is unchanged: only the backtracking compile decides it, so the list-entry and pattern-preview endpoints behave as before. No API field was added.
  • The linear regex is built the first time a query reaches a pattern. Building it for every entry when a list loads grew the Large filter footprint from 49.3 MB to 12,576 MB. Built lazily, the footprint is 50.5 MB, against 49.3 MB before.
  • The README's filter "Entry kinds" bullet says which patterns run in linear time and what a linear regex costs in memory.

Benchmarks (SQLite, Large, short job): every FilterEngine and FilterCacheReload benchmark is within 10 % of develop. The largest change is ResponseBlockedUnidentified at +7.9 %, within its noise; index builds and reloads are within about 3 %.

Tests: Ninlil.Dns.Server.Filtering.Tests passes 258 of 258 on repeated runs, and the FilterListEntries and FilterPatternPreview web tests pass. The verifier passed the branch and re-ran the red check.

Closes #53

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

Wildcard and regex filter entries now run on .NET's non-backtracking regex engine. Matching takes time linear in the name, so a catastrophic pattern such as `^(a+)+$` can no longer time out and let a name through. - A pattern the linear engine refuses (backreferences, lookarounds, atomic groups) keeps the backtracking engine with its 250 ms timeout and the no-match rule. - Which patterns count as valid is unchanged: only the backtracking compile decides it, so the list-entry and pattern-preview endpoints behave as before. No API field was added. - The linear regex is built the first time a query reaches a pattern. Building it for every entry when a list loads grew the Large filter footprint from 49.3 MB to 12,576 MB. Built lazily, the footprint is 50.5 MB, against 49.3 MB before. - The README's filter "Entry kinds" bullet says which patterns run in linear time and what a linear regex costs in memory. Benchmarks (SQLite, Large, short job): every FilterEngine and FilterCacheReload benchmark is within 10 % of develop. The largest change is ResponseBlockedUnidentified at +7.9 %, within its noise; index builds and reloads are within about 3 %. Tests: `Ninlil.Dns.Server.Filtering.Tests` passes 258 of 258 on repeated runs, and the FilterListEntries and FilterPatternPreview web tests pass. The verifier passed the branch and re-ran the red check. Closes #53 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Patterns compile with the non-backtracking engine; one it cannot run keeps the backtracking engine, its 250 ms timeout and the no-match rule.

Refs #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Refs #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
Closes #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The filter tests describe the catastrophic and nested-quantifier patterns without history or work-item references
All checks were successful
Build / Pack and Push NuGet Packages (common) (pull_request) Successful in -2m23s
Build / Build Binary (windows-amd64) (pull_request) Successful in 3m22s
Build / Pack and Push NuGet Packages (dhcp) (pull_request) Successful in -1m44s
Build / Build Binary (macos-arm64) (push) Successful in 7m16s
Build / Pack and Push NuGet Packages (dns-core) (push) Successful in -1m12s
Build / Build Arch Linux Packages (push) Successful in 24s
Build / Pack and Push NuGet Packages (dns-server) (push) Successful in -55s
Build / Build Binary (linux-arm64) (push) Successful in 5m36s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in -1m41s
Build / Build Binary (windows-amd64) (push) Successful in -25s
Build / Smoke Test the Windows Binary (push) Successful in 18s
Build / Build and Push Image (push) Successful in -2m25s
Build / Build Binary (linux-arm64) (pull_request) Successful in 1m37s
Build / Test .NET (pull_request) Successful in 10m50s
Build / Build Binary (macos-amd64) (push) Successful in 5m43s
Build / Build Binary (linux-amd64) (push) Successful in 5m44s
Build / Stage Draft Release (pull_request) Successful in -2m35s
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in 1m31s
Build / Build Binary (linux-amd64) (pull_request) Successful in 38s
Build / Build Binary (macos-amd64) (pull_request) Successful in 1m24s
Build / Build Binary (macos-arm64) (pull_request) Successful in 1m23s
Build / Build and Push Image (pull_request) Successful in -2m32s
Build / Smoke Test the Windows Binary (pull_request) Successful in 17s
Build / Build Arch Linux Packages (pull_request) Successful in 30s
Build / Build and Test Deb and RPM Packages (push) Successful in 4m27s
Build / Publish Release (push) Successful in -2m36s
Build / Pipeline (push) Successful in 0s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in 2m41s
Build / Publish Release (pull_request) Successful in -2m35s
Build / Pipeline (pull_request) Successful in 0s
818ca806f2
Refs #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit b395421d1a into develop 2026-11-05 03:06:08 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!277
No description provided.