Skip to content

Update picomatch to address audit findings - #197

Closed
dragonnite1221-lgtm wants to merge 18 commits into
colbymchenry:mainfrom
dragonnite1221-lgtm:fix-picomatch-audit
Closed

dragonnite1221-lgtm wants to merge 18 commits into
colbymchenry:mainfrom
dragonnite1221-lgtm:fix-picomatch-audit

Conversation

@dragonnite1221-lgtm

@dragonnite1221-lgtm dragonnite1221-lgtm commented May 20, 2026 •

Copy link
Copy Markdown

Summary

  • update the production picomatch dependency from ^4.0.3 to ^4.0.4 and lock exactly 4.0.4
  • pin contributor tooling to Node 22.23.1 / npm 10.9.2 via .nvmrc and Volta
  • keep self-contained release bundles on Node 24.16.0
  • preflight both unzip and zip before any Windows bundle download
  • merge the latest upstream main

Scope

This PR now contains only the picomatch ReDoS fix, the contributor/release Node split, and Windows bundle preflight. The accidental Vitest 4.1.10 squash commit was reverted normally; no force-push or destructive reset was used. package.json and package-lock.json are back on Vitest 2.1.9, and no Rolldown package remains in the lockfile.

The Vitest 4 work remains preserved on the fork branch agent/update-vitest-4 at cb19eb4. It can be retargeted or recreated from upstream main after this PR lands.

Verification

  • Node 22.23.1 / npm 10.9.2: npm ci — passed
  • Node 22.23.1: npm run build — passed
  • npm audit --omit=dev — 0 vulnerabilities
  • npm ls picomatch — picomatch@4.0.4
  • Vitest 2.1.9, one worker: framework/Cargo-glob and release tests — 2 files, 125 passed, 0 failed
  • Linux x64 self-contained bundle — built successfully (55 MB)
  • extracted bundle runtime — v24.16.0
  • extracted bundle CLI — 1.5.0
  • extracted production dependency — picomatch@4.0.4
  • direct bundled node:sqlite open — sqlite-ok, no ExperimentalWarning
  • Windows preflight — missing unzip and missing zip each exit 1 before the download message
  • git diff --check — passed

There is no repository CI workflow/status for this PR, so the local logs above are the available validation evidence; maintainer review is still required.

ymstar and others added 5 commits May 19, 2026 17:17
…tion (colbymchenry#191)

* feat(mcp): steer agents to explore-first; fix Kotlin/Swift test detection

Two changes from diagnosing why Claude Code's Explore agent wasn't using
codegraph_explore on a benchmark run (37 calls / ~90k tokens via
search+Read+grep, vs a general-purpose agent that led with explore: 13
calls / ~55k tokens for the same question).

1. Tool guidance reframed across server-instructions.ts,
   instructions-template.ts, and .cursor/rules/codegraph.mdc (+ the
   explore/search tool descriptions): codegraph_explore is the workhorse
   for understanding/architecture/"how does X work" questions. Seed it with
   the key symbol names (a quick search/context first if the question names
   nothing concrete), read its output, and fill gaps with node/Read —
   instead of searching then Reading each file. The old "search first to
   find names, then explore" wording was short-circuiting: agents searched,
   got file:line locations, and Read them, never reaching explore.

2. isTestFile now recognizes Kotlin (*Test.kt, jvmTest/commonTest/
   androidTest source sets), Swift (*Tests.swift), and other camelCase test
   conventions, so test code is deprioritized in explore/context ranking.
   Previously only Java/JS/Python were known, letting tests dominate
   Kotlin/Swift exploration (OkHttp "trace a request" went from 8/9 test
   files to surfacing Call.kt/OkHttpClient.kt/Request.kt/Response.kt).
   Capital-led matching keeps latest.kt/manifest.kt unflagged.

An IDF common-term down-weighting was prototyped for the cold-query case
but dropped — it was a measured no-op (the "common" terms weren't actually
common in the test indexes); the test-detection gap was the real cause.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(agent-eval): add agent-behavior eval harness for codegraph MCP usage

Tooling to measure how a Claude Code agent actually uses the codegraph
MCP tools on a real repo — does it lead with codegraph_explore, how many
Read/Grep follow-ups, token cost — for validating tool-guidance changes
(server-instructions, tool descriptions) against real agent behavior.

- itrun.sh drives the real interactive TUI via tmux (the faithful
  Explore path). Hardened for unattended runs: type-and-verify prompt
  delivery (the ❯ glyph is drawn ~6s before the input accepts keys),
  auto-accepts the "trust this folder" dialog, busy-detection keys on
  the universal "(Ns · …)" spinner so the pre-stream thinking phase
  counts as busy, and fails loudly instead of capturing an empty pane.
- parse-session.mjs reports the tool breakdown + token accounting
  (gen / fresh-in / cached-in / billable) from the session and subagent
  logs, consistent across main-thread and subagent runs; counts
  main-thread Bash in the grep verdict.
- run-agent.sh / parse-run.mjs are the headless stream-json complement
  (exact per-tool tokens/cost via claude -p).
- run-interactive-test.md documents how to run it and how completion is
  detected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Folds all changes since 0.7.10 into 0.7.12 (0.7.11 was unpublished from
npm): size-adaptive codegraph_explore output budget (colbymchenry#185/colbymchenry#187), line
numbers in explore source sections (colbymchenry#188), explore-first tool guidance
(colbymchenry#191), language-neutral source-omission markers, and Kotlin/Swift
test-file detection (colbymchenry#191).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@inth3shadows

Copy link
Copy Markdown
Contributor

This bump is worth prioritizing — the picomatch@4.0.3 ReDoS (GHSA-c2c7-rcm5-vvqj) is reachable with attacker-controlled input, not just a transitive-audit alert.

The Rust framework resolver compiles workspace-member globs read straight from an indexed repo's Cargo.toml:

getCachedCargoWorkspaceCrateMap   src/resolution/frameworks/rust.ts:14
  → getCargoWorkspaceCrateMap     src/resolution/frameworks/cargo-workspace.ts:224   // context.readFile('Cargo.toml')
    → expandMembers               src/resolution/frameworks/cargo-workspace.ts:200
      → expandGlobMember          src/resolution/frameworks/cargo-workspace.ts:169
        → picomatch(member, …)    src/resolution/frameworks/cargo-workspace.ts:178   // `member` = raw glob from Cargo.toml

parseWorkspaceMembers lifts the members = [...] array verbatim and each entry is handed to picomatch(member, { dot: false }). A hostile Rust repo can therefore supply a member glob crafted for catastrophic backtracking, hanging the resolution phase during codegraph index — a local DoS on the user's machine.

The change here (^4.0.3 → 4.0.4, inside the existing semver range) is the right fix. Two notes for whoever merges:

  • The PR has drifted from main since May — the lockfile likely needs a rebase / regen (npm install --package-lock-only).
  • The lockfile is the release-bundled artifact, so the per-platform bundle should be rebuilt after merge so published installs actually carry 4.0.4.

(Reachability verified against the current code graph. Filed a standalone issue for this and am closing it as a duplicate of this PR.)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ddd75c9ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/build-bundle.sh Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Addresses the review note that this branch had drifted from main since May and
that its lockfile needed regenerating. The branch was 76 commits behind, and
package-lock.json is the release-bundled artifact, so merging a lockfile built
against a May tree would have reverted dependency work that landed since.

Merged upstream/main (no conflicts) and re-ran npm install --package-lock-only.
The regeneration produced no further diff, i.e. the merged lockfile was already
the tree npm resolves from package.json; npm ci then installs from it cleanly,
which is the check that actually proves lockfile and manifest agree.

Also drops a duplicate `import type { FrameworkResolver }` in
__tests__/frameworks.test.ts. That duplicate predates this branch and exists on
main too, where the older transform tolerated it. The dependency bump this PR
carries brings vite 8, whose oxc transform rejects it as a parse error, so the
file stopped loading entirely. Line 2 already imports the symbol, so the second
import is removed rather than the two merged.

Verification against upstream/main as the baseline, two full runs each:

  upstream/main   58 failed / 2451 passed   (16 files, identical across runs)
  this branch     22-25 failed / ~2492 passed  (4 files, identical file set)

  npm ci                    exit 0
  npm audit --omit=dev      0 vulnerabilities
  installed picomatch       4.0.5   (no 4.0.3 anywhere in the tree)
  npm run build             exit 0

Two of this branch's four failing files, extraction.test.ts and
multi-repo-workspace.test.ts, do not fail on main. They pass in isolation
(631 tests, exit 0) and fail only in the full parallel run, always as
"Test timed out in 5000ms" -- 18 of the 21 timeouts in the run -- with no
assertion failures among them. That reads as contention against the default 5s
timeout under vitest 4's scheduling on a loaded machine rather than a behaviour
change, but it is reported here rather than smoothed over; the bundle default
stays pinned at Node v24.16.0 as agreed earlier in review.
@dragonnite1221-lgtm

Copy link
Copy Markdown
Author

Scope repair complete on 8c219a3.

The accidental Vitest 4 change is removed with a normal revert, latest upstream main is merged, and the final comparison is only 4 files / +20 -10: .nvmrc, package.json, package-lock.json, and scripts/build-bundle.sh. The lock resolves picomatch@4.0.4, remains on vitest@2.1.9, and contains no Rolldown packages. The separate fork branch agent/update-vitest-4 still preserves the Vitest work at cb19eb4.

Local validation on final tree:

  • Node 22.23.1 / npm 10.9.2: npm ci and npm run build passed
  • production audit: 0 vulnerabilities; npm ls picomatch: 4.0.4
  • one-worker relevant tests: 125 passed / 0 failed
  • Linux x64 bundle: 55 MB; runtime v24.16.0; CLI 1.5.0; bundled picomatch 4.0.4
  • direct bundled node:sqlite: no ExperimentalWarning
  • missing unzip and missing zip: both fail in preflight before download
  • git diff --check: passed

There is still no CI workflow/status attached to this PR. @colbymchenry, please review the now-minimal diff and the local evidence; I am not treating the PR as merge-ready without maintainer review.

@colbymchenry

Copy link
Copy Markdown
Owner

Thanks for flagging the picomatch advisory! main's lockfile has carried picomatch 4.0.7 since 1.6.1, which is past the 4.0.4 fix for CVE-2026-33671, and the release bundles install from that lockfile, so 1.6.1 and 1.6.2 already ship the patched version. The bundle script has since been reworked (Node 24.22.1 plus a checksum check against nodejs.org), so the other changes no longer apply cleanly. Closing this one.

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.

4 participants