Skip to content

fix(javascript): name minified receiverless import calls by their final callee - #9095

Open
sueun-dev wants to merge 6 commits into
morluto:mainfrom
sueun-dev:sueun-dev/brave-chatelet-4c1ca8
Open

sueun-dev wants to merge 6 commits into
morluto:mainfrom
sueun-dev:sueun-dev/brave-chatelet-4c1ca8

Conversation

@sueun-dev

@sueun-dev sueun-dev commented Nov 6, 2026 •

Copy link
Copy Markdown

Summary

Webpack and Next.js minifiers emit (0, module.export)(...) for every imported
function call. calleeName returned "" for that sequence-expression callee, so
the named endpoint detectors in both analyze_web_bundle and
analyzeJavaScriptStaticSource missed calls such as (0, r.fetch)("/api/a") and
(0, o.get)("/api/b"). They now report these calls as unverified endpoint
candidates, the same way they report r.fetch("/api/a").

Fixes #14388. The gap turned up while probing a fetch-wrapper detector.

Problem and expected behavior

Smallest trigger: (0,r.fetch)("/api/a") inside a webpack chunk. Before this
change neither analyzer reported anything. (0, f) only drops the receiver, so
the callee spelling is the final operand r.fetch.

Expected: a low-confidence candidate (call:r.fetch:unverified-network-receiver
in the web bundle, call:r.fetch with interpretation: "candidate" in static
analysis), never an observed endpoint, because the spelling proves no receiver
or intrinsic identity.

Change and scope

  • calleeName (javascriptStaticAnalysisHelpers.ts) now reads the final comma
    operand only when every discarded operand is an exact literal. Any other
    operand may replace the callee before it is read, so (track(), r.fetch) and
    (r.fetch = y, r.fetch) keep an empty name. A final operand that is not a
    member or identifier ((0, r.client()), (0, c ? a : b)) already produced no
    name.
  • Receiver and intrinsic proofs are unchanged and still read the original
    callee: isBrowserNetworkRequest, isUnmodifiedGlobalReference, the XHR
    open proof and the open-receiver facts. (0, navigator.sendBeacon)("/x")
    therefore stays a web-bundle candidate, and static analysis still drops it
    through its familiar-network-spelling guard. Without its receiver that call
    throws, so it never sends a request.
  • The tRPC reader's private rpcFactoryName duplicated this unwrapping and is
    removed. It now shares the literal-operand rule, so
    (track(), t.httpLink)({url}) is no longer recognized.
  • The Electron call-path callLabel keeps its own unwrapping on purpose. It
    labels what the symbolic evaluator followed, and that evaluator takes the last
    operand of any comma expression (value semantics, not callee spelling).
  • One paragraph added to
    docs/guides/javascript/javascript-artifact-reconstruction.md.

Not included: proving (0, fetch) or other receiverless intrinsic calls as
known requests.

Contribution scope: an ordinary fix within existing static-analysis boundaries;
a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: calleeName, the shared producer of
    callee spellings. I audited every consumer. Each one either classifies by
    spelling alone (web-bundle require, importScripts and route-framework names;
    route-scan navigation and structured calls; esbuild wrapper names;
    isFileIdentity for fileURLToPath; Electron senderSubject; static-analysis
    Worker, Vite, SQLite, loadFile and loadURL names) or gates the spelling
    with its own proof on node.callee. For these consumers, (0, x.f) now
    behaves like x.f. The superseded copy in rpcFactoryName was removed.
  • Contribution scope fit and linked maintainer decision: not applicable
    (existing analyzer behavior).
  • CLI and MCP/tool-catalog contract: no schema change. Result content changes:
    new endpoint candidates for literal-prefixed comma callees.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: candidates keep
    their existing low confidence, detector or mechanism, and first-site basis.
    The detector names the final callee spelling (for example call:r.fetch).
  • Target selection, authority, upstream behavior, and cleanup details: not
    applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • webBundleAnalyzer.test.ts adds a webpack-chunk-shaped fixture that runs
      through both analyzers. Positives: (0,r.fetch), (0,o.get), and nested
      or multi-literal (0,0,(0,o.post)). Receiver-dropping case:
      (0,navigator.sendBeacon). Negatives: effectful prefix, rebinding prefix,
      call result, and conditional final operand.
    • javascriptRpcEndpoints.test.ts adds an effectful-prefix tRPC link negative.
  • Base reproduction (executed): on the base revision the new web-bundle test
    failed with expected [] to deeply equal [ [ '/api/a', … ], …(3) ].
  • Controlled breakage (executed): accepting any comma prefix made the new test
    report /api/effect and /api/rebound, and made the tRPC test report
    /api/effect. Both failed at the intended assertions; the guard was then
    restored.
  • Boundary regressions: malformed and effectful sequence shapes, plus a
    receiver-identity negative.
  • Remaining proof gaps: no public CLI/MCP workflow run and no real-site rerun.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:local -- 59 files (webBundle*, javascriptStaticAnalysis*,
    javascriptRoute*, electron*, javascriptRpc*,
    javascriptStaticPathResolution, javascriptSemanticAnalysis.member_depth):
    59 files and 2286 tests passed.
  • npm run check:fast: typecheck and lint passed (uncached); the pre-push hook
    also passed.
  • After merging main (b2b93fed5): the same file groups, now 131 files and
    4749 tests, passed, and npm run check:fast passed. With the two source files
    swapped back to main 42bbf33f2, the two changed test files fail 2 tests.
  • Toolchain caveat: the pinned Node 24.22.1 was unavailable locally. I installed
    dependencies with npm ci --engine-strict=false on Node 24.21.0.
  • Not run: npm run docs:check, npm run check:pr.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Analyses of minified bundles can
    report additional low-confidence candidates and route or edge names for
    (0, x.f) calls.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static source
    analysis only).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no execution, network or
    file effects; parsing captured source only.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…al callee

Webpack and Next.js emit `(0, module.export)(...)` for every imported call.
`calleeName` returned "" for that sequence callee, so named endpoint
detectors in analyze_web_bundle and analyzeJavaScriptStaticSource missed
calls such as `(0, r.fetch)("/api/a")` and `(0, o.get)("/api/b")`.

`calleeName` now reads the final comma operand when every discarded operand
is an exact literal. Any other operand may replace the callee, so effectful
or rebinding prefixes keep an empty name. The name stays spelling only:
receiver facts and intrinsic proofs still read the original callee, so
`(0, navigator.sendBeacon)(...)` stays an unverified candidate.

The tRPC factory reader's own sequence unwrapping is superseded and removed;
it now shares the literal-operand rule. The Electron call-path label keeps
its value-semantics unwrapping because it labels what the symbolic evaluator
followed.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-06T04:51:52.572374Z
We couldn’t complete this review. Comment @codex review to try again.
3fff214 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches results across JavaScript source-analysis workflows, not runtime behavior.

The code changes appear sound, but the required issue discussion remains outstanding before merge.

Findings

  1. P2 Required issue discussion is missing ▶
Fix with agent prompt
### Issue 1
src/domain/javascript/javascriptStaticAnalysisHelpers.ts:729-733
This change adds shared callee-name recovery, but the PR says there is no linked issue. The repository requires opening or discussing an issue that explains the problem and proposed solution before submitting changes. Open that discussion and link it here; this requirement must be satisfied before merging.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Names literal-prefixed comma calls by their final callee without treating the name as proof of browser API identity.

  • Minified imported calls can now produce endpoint candidates.
  • The tRPC scan uses the shared rule for comma-prefixed calls.

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran the 2 changed test files on Node 22.23.4, 24.22.1 and 26.12.1, and all 176 tests passed on each version. With the 2 source files swapped back to the base, 2 tests failed on each version. The CI run on this head is completed/action_required, and no CI test jobs appear in its check runs.

Results

I ran head aad1eb3. The red run used the same head and test files, with src/domain/javascript/javascriptRpcEndpoints.ts and src/domain/javascript/javascriptStaticAnalysisHelpers.ts swapped back to the merge base 1071ad8.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Head, 2 changed test files pass: 2 of 2 files, 176 of 176 tests pass: 2 of 2 files, 176 of 176 tests pass: 2 of 2 files, 176 of 176 tests
Red run, source swapped to base fail: 2 of 2 files, 2 failed, 174 passed fail: 2 of 2 files, 2 failed, 174 passed fail: 2 of 2 files, 2 failed, 174 passed

On Node 24.22.1, these two tests failed in the red run:

  • tRPC binding identity and bundled syntax > recognizes surviving factory names inside bundled call wrappers in src/domain/javascript/javascriptRpcEndpoints.test.ts
  • web bundle endpoint candidate classification > names minified receiverless import calls by their final callee in both analyzers in src/domain/webBundleAnalyzer.test.ts

Node 22.23.4 and Node 26.12.1 fail the same two tests.

The PR changes 5 files against the merge base. Two are test files, and three are docs/guides/javascript/javascript-artifact-reconstruction.md, src/domain/javascript/javascriptRpcEndpoints.ts and src/domain/javascript/javascriptStaticAnalysisHelpers.ts.

The head is 50 commits behind main c78c8ae.

CI on the head, read live with gh:

  • GitHub shows mergeable true and state blocked.
  • Workflow runs: CI, CodeQL production and PR title are completed/action_required. PR readiness is completed/failure.
  • Check runs: Validate author declaration is failure. Greptile Review is success.
  • Commit status: PR readiness is failure.
  • The CI run has no Source tests, Portable tests or Test shard jobs in its check runs.

Not run

  • A probe that would run calleeName through analyzeJavaScriptStaticSource and analyzeWebBundleFixture. It would use these inputs: (void 0,t.httpLink), (!0,r.fetch), (0,require), (0,fetch), (0,eval), new (0,o.Worker) and (track(),t.createTRPCProxyClient). It would diff the output against base 1071ad8.
  • A grep across the repo for every consumer of calleeName and readExactJavaScriptLiteral, checking each caller against the audited every consumer claim.
  • A merge with current main, c78c8ae.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: aad1eb3 / 1071ad8 (merge base with main)
  • Red run: aad1eb3 with the changed source files from 1071ad8
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/domain/javascript/javascriptRpcEndpoints.test.ts src/domain/webBundleAnalyzer.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto morluto added area: evidence Evidence, artifacts, and reconstruction bug Something isn't working labels Nov 22, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@sueun-dev thanks for the PR — there is 1 open review thread here:

Could you address or reply to this? Once it's resolved and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@sueun-dev also, this branch has merge conflicts with main — please resolve those along with the open threads.

…let-4c1ca8

# Conflicts:
#	docs/guides/javascript/javascript-artifact-reconstruction.md
#	src/domain/javascript/javascriptRpcEndpoints.test.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Endpoint detectors miss minified (0, module.export)(...) import calls

3 participants