Skip to content

fix: address code scanning alerts in yok and the CocoaPods service - #6228

Merged
NathanWalker merged 1 commit into
mainfrom
fix/code-scanning-alerts
Dec 1, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/code-scanning-alerts

Conversation

@NathanWalker

@NathanWalker NathanWalker commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What is the current behavior?

CodeQL reports two issues this PR fixes:

  • js/redos (Remove top level tns_modules and hooks folders #80): Yok.dynamicCallRegex uses a nested quantifier, (\((.+)\))*, which backtracks exponentially.
  • js/incomplete-sanitization (integrate with Travis CI #4): this flags a real bug in the CocoaPods service. Plugin Podfile headers were written with + 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?

  • Remove top level tns_modules and hooks folders #80: the argument group is matched once ((\((.+)\))?). 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.
  • integrate with Travis CI #4: headers are written with the plain path, and the section-removal regex is built with regExpEscape. It also matches headers written by older CLI versions with \+, so existing projects get their stale section replaced once on the next prepare.
  • New tests in test/cocoapods-service.ts: add-then-remove with a pnpm-style path, and removing an old-style header. Both fail on main and pass with this change.

Validation

  • npm run build, then npx vitest run: 139 files, 2404 passed and 9 skipped.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed CocoaPods plugin section handling for paths that contain plus signs, including existing Podfile headers where plus signs are escaped. Applying and removing plugin sections now works more reliably with these paths.

- 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).
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes update dynamic-call regex matching and CocoaPods Podfile section matching. The CocoaPods service now uses a shared helper for section matching, and tests cover plugin paths with regular-expression characters.

Changes: Dynamic Call Matching

Layer / File(s) Summary
Dynamic-call regex
lib/common/yok.ts
Yok.dynamicCallRegex now matches the optional parenthesized argument group at most once.

CocoaPods Podfile Sections

Layer / File(s) Summary
Section header and matching helper
lib/services/cocoapods-service.ts
Plugin section headers retain the path unchanged. The new helper matches plus signs in literal or escaped form and escapes the section terminator.
Apply and remove sections
lib/services/cocoapods-service.ts, test/cocoapods-service.ts
Podfile application and removal use the helper. Tests cover plugin paths with plus signs and parentheses, including an existing header with an escaped plus sign.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: rigor789, rosen-vladimirov, miladfm

Merge Risk: Minimal · up to 150d7

This change tightens a help-template regex and fixes CocoaPods Podfile section removal for plugin paths containing plus signs or parentheses. No concrete merge-blocking risk was found, and the new tests cover the changed behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two areas the PR changes: Yok and the CocoaPods service. It states the purpose as fixing code scanning alerts. The raw summary and objectives confirm both changes address CodeQL fi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two areas the PR changes: Yok and the CocoaPods service. It states the purpose as fixing code scanning alerts. The raw summary and objectives confirm both changes address CodeQL findings (js/redos in Yok.dynamicCallRegex, js/incomplete-sanitization in the CocoaPods service). The title is specific enough for a reviewer to see the main change, though it does not name the specific fixes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the headers with care,
Plus signs now match in either form there.
One call group hops once, not twice,
Tests trace the paths and confirm them precise.
The Podfile sections rest in place,
While rabbit ears nod at regex grace.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9e395eb3-f640-4d86-a316-64f7c2e43184
Commits

Reviewing files that changed from the base of the PR and between bae5b1c and 150d777.

Files selected for processing: 3

  • lib/common/yok.ts
  • lib/services/cocoapods-service.ts
  • test/cocoapods-service.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@NathanWalker
NathanWalker merged commit 68d3269 into main Dec 1, 2026
15 checks passed
@NathanWalker
NathanWalker deleted the fix/code-scanning-alerts branch December 1, 2026 23:43
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