Skip to content

test(swift): pin bare-import rejection and _dependency_capture ReDoS - #2666

Merged
squid-protocol merged 1 commit into
mainfrom
test/swift-dependency-capture-coverage
Sep 2, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
test/swift-dependency-capture-coverage

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Salvages the two test cases from #2628 that main does not already have. That PR's regex fix — [\w.]+ → [\w.]* in swift's _dependency_capture, so import a captures — 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 as Co-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 bare import with no module name. 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. func_start and args already have this coverage; _dependency_capture did not.

Test plan

  • pytest tests/extraction/languages/test_swift.py → 39 passed
  • ruff check introduces no new findings — the 7 reported (E402, S101) are pre-existing and identical on main
  • ruff format --check clean
  • Both assertions verified against the current engine before writing them: bare import does not match, and the 100k-char "import " + "a." * 50000 payload completes in ~0.001s against a 3.0s budget
  • No production code changes, so no golden-master or baseline movement expected

🤖 Generated with Claude Code

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]>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 025c0b2 into main Sep 2, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the test/swift-dependency-capture-coverage branch September 2, 2026 15:36
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.

1 participant