Repository navigation
test(swift): pin bare-import rejection and _dependency_capture ReDoS - #2666
Merged
Merged
Conversation
Salvaged from #2628, whose regex fix was superseded by #2641 landing the identical `[\w.]+` -> `[\w.]*` change first. These two cases were the part of that PR main did not already have: - `import` (bare, no module name) as an explicit invalid case. Relaxing the module-name tail to `*` so `import a` captures is exactly the kind of change that could go one step too far and match a bare `import`; this pins that it does not. - A ReDoS immunity test for `_dependency_capture`. The dotted-module tail is the one unbounded quantifier in that rule, and func_start and args already had this coverage while _dependency_capture did not. Both assertions verified against the current engine; no production code changes, so no golden-master or baseline movement. Co-Authored-By: kanishk083 <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
3 tasks
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvages the two test cases from #2628 that
maindoes not already have. That PR's regex fix —[\w.]+→[\w.]*in swift's_dependency_capture, soimport acaptures — was superseded by #2641 (5813a9cb) landing the byte-identical change first, along with the("import a", "a")regression case. Credit to @kanishk083, who filed #2628 for issue #2543 before the sweep landed; retained asCo-Authored-By.What was left, and is added here:
"import"as an explicit invalid case. Relaxing the module-name tail from+to*is exactly the kind of change that could go one step too far and start matching a bareimportwith no module name. This pins that it does not._dependency_capture. The dotted-module tail is the one unbounded quantifier in that rule.func_startandargsalready have this coverage;_dependency_capturedid not.Test plan
pytest tests/extraction/languages/test_swift.py→ 39 passedruff checkintroduces no new findings — the 7 reported (E402, S101) are pre-existing and identical onmainruff format --checkcleanimportdoes not match, and the 100k-char"import " + "a." * 50000payload completes in ~0.001s against a 3.0s budget🤖 Generated with Claude Code