Skip to content

Replace recursive glob with iterative two-pointer algorithm (#10) - #20

Merged
jplock merged 2 commits into
mainfrom
fix/issue-10-glob-exponential
May 31, 2026
Merged

Replace recursive glob with iterative two-pointer algorithm (#10)#20
jplock merged 2 commits into
mainfrom
fix/issue-10-glob-exponential

Conversation

@jplock

@jplock jplock commented May 31, 2026

Copy link
Copy Markdown
Member

Fixes #10


Note

Low Risk
Localized algorithm swap with preserved semantics and regression coverage; no API or auth changes.

Overview
Fixes performance and potential DoS in ARN wildcard matching by replacing the recursive glob_match implementation with an iterative two-pointer matcher that backtracks only from the last *.

Pathological patterns such as many interleaved *a* segments against long text could drive exponential recursive retries (~11s on a small example in #10); the new approach targets O(|pattern| × |text|) worst case. Public behavior for * and ? is unchanged; ArnPattern still matches each ARN segment via glob_match.

Adds test_glob_no_exponential_blowup, asserting a known adversarial case finishes in under 100ms and does not match.

Reviewed by Cursor Bugbot for commit 1c16738. Bugbot is set up for automated code reviews on this repo. Configure here.

@jplock
jplock merged commit cfc3106 into main May 31, 2026
10 checks passed
@jplock
jplock deleted the fix/issue-10-glob-exponential branch May 31, 2026 17:14
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.

[Detail Bug] Policy evaluation can hang on certain StringLike patterns due to exponential glob matching

1 participant