Repository navigation
fix: address code scanning alerts in yok and the CocoaPods service - #6228
Conversation
- yok: match the optional argument list of a dynamic call once instead of with a nested quantifier, removing exponential backtracking (js/redos). Matches are unchanged. - cocoapods: write plugin Podfile headers with the raw path and build the section-removal regex with regExpEscape. Paths containing regex characters (pnpm "+" and "(peer@x)" segments) were never matched, so their sections were not removed. Headers written by older versions with "+" escaped as "\+" are still matched (js/incomplete-sanitization).
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What is the current behavior?
CodeQL reports two issues this PR fixes:
Yok.dynamicCallRegexuses a nested quantifier,(\((.+)\))*, which backtracks exponentially.+escaped as\+, and the same escaped text was then used as a regex, where\+matches a plain+. Paths with parentheses were not escaped at all. So for pnpm-style plugin paths (.pnpm/pkg@1.0.0+peer/...or(peer@x)segments), a plugin's Podfile section was never matched and never removed.What is the new behavior?
(\((.+)\))?). A comparison on 300,000 random inputs and the CLI's help templates found no change in matches. The flagged input that took 319 ms now takes well under 1 ms.regExpEscape. It also matches headers written by older CLI versions with\+, so existing projects get their stale section replaced once on the next prepare.test/cocoapods-service.ts: add-then-remove with a pnpm-style path, and removing an old-style header. Both fail onmainand pass with this change.Validation
npm run build, thennpx vitest run: 139 files, 2404 passed and 9 skipped.Summary by CodeRabbit