Skip to content

fix(javascript): keep keyed-store reads out of endpoints - #3036

Closed
alfredo1491 wants to merge 2 commits into
morluto:mainfrom
alfredo1491:fix/javascript-keyed-store-endpoints
Closed

alfredo1491 wants to merge 2 commits into
morluto:mainfrom
alfredo1491:fix/javascript-keyed-store-endpoints

Conversation

@alfredo1491

Copy link
Copy Markdown
Contributor

Problem

Follow-up to #2402. Static endpoint extraction still reports reads of two key/value stores as network endpoints, because their .get(key) / .delete(key) calls look like HTTP client calls:

  • undici headersList: bundled undici (the implementation behind Node's fetch) reads and removes headers through request.headersList.get("location") and headersList.delete("authorization"). headers and searchParams are already treated as keyed collections, but headersList was not.
  • VS Code extension state (Memento): context.globalState.get("lastVersion") and workspaceState.get("closedRepositories", []) report every literal state key as an endpoint.

Across the 38 bundled dist/*.js files of the extensions shipped with VS Code, only 14 of 309 reported network endpoints are URL- or path-shaped.

Change

  • isKeyedCollectionReceiver also accepts the headersList member, with the same rule as headers/searchParams: spelling alone never drops URL- or path-shaped literals.
  • classifyParsedJavaScriptOpenReceivers records an extension-state fact for .get on a globalState/workspaceState member. VS Code passes the ExtensionContext to activate, so the member has no import origin of its own; the fact therefore also requires a binding in the same module whose origin is vscode (namespace/default import or require), reusing the origins the configuration receiver check from fix(javascript): keep configuration setting reads out of endpoints #2402 relies on. Without that proof, the endpoint is kept.
  • endpointArgument skips non-URL literals for the new fact, in both application and web bundle analysis.

Two commits, one per store, so either can be reviewed or dropped independently.

Measurements

analyzeJavaScriptStaticSource over the 38 bundled extension dist/*.js files of VS Code (resources/app/extensions/*/dist), measured against main @ 0e6eca4 before rebasing:

main this PR
network endpoints 309 284
copilot 194 171
git 8 7
microsoft-authentication 3 2

Most of the gain is undici (headersList). Memento contributes little here because most extensions read state through constant keys, which were never endpoints; only 11 literal-key Memento reads exist in these bundles.

Receiver classification time is unchanged: 3 runs on copilot's 19.7 MB extension.js measured 27.8/31.1/30.7 s after vs 27.4/29.5/30.8 s before. The module-level vscode proof runs only when a candidate globalState/workspaceState read exists.

Verification

  • src/domain/webBundleAnalyzer.test.ts: new two-analyzer case for extension state (namespace import, require, and a non-vscode require that keeps every key), and the keyed-collection case extended with headersList reads plus URL/path literals that stay endpoints.
  • vitest run src/domain/webBundleAnalyzer.test.ts src/domain/javascript/ src/application/javascript/ (rebased on main @ 80592b8): 1595 passed.
  • npm run check:fast (typecheck + lint, via the Husky pre-push hook): passed.

Unavailable coverage: boundary/acceptance projects and the source CLI were not run on this Windows host (the native addon cannot be built outside the Linux/MinGW lane); measurements come from the domain analyzer directly. No real-provider lanes apply.

🤖 Generated with Claude Code

alfredo1491 and others added 2 commits October 13, 2026 17:09
`context.globalState.get(key)` and `workspaceState.get(key)` read VS Code
extension Memento keys, but static endpoint extraction reported each
literal key as a network endpoint.

The lexical receiver classifier now records an `extension-state` fact for
a `.get` call on a `globalState` or `workspaceState` member. VS Code passes
the ExtensionContext to `activate`, so the member has no import origin;
the fact therefore also requires a binding in the same module that
originates from `vscode` (import or require), using the origins that
configuration receivers already use. Without that proof, and for URL- or
path-shaped literals, the endpoint is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bundled undici, the implementation behind Node's fetch, reads and removes
headers through `request.headersList.get(name)` and
`headersList.delete(name)`. Endpoint extraction already skips the platform
`headers` and `searchParams` members, but `headersList` header names such
as `location`, `vary`, and `authorization` were reported as network
endpoints.

`headersList` now joins those spelled keyed-collection members. As before,
spelling alone keeps URL- and path-shaped literals as requests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

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 ✅ Completed 2026-10-13T23:22:57.551108Z c579f5c 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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defect was established.

Summary

The PR stops reporting non-URL keys from headersList and VS Code extension state as network endpoints.

  • Header-list reads no longer look like network endpoints.
  • Extension state reads stop appearing as network endpoints.

alfredo1491 explicitly identifies module-wide import proof plus member spelling as intentional. That design was not reported as a defect.

Supersession could not be checked because GitHub access required authentication. The code review found no security issue.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["get or delete with a literal argument"] --> B{"URL or path-shaped?"}
  B -->|Yes| C["Keep endpoint"]
  B -->|No| D{"Keyed collection?"}
  D -->|Yes| E["Skip key"]
  D -->|No| F{"get with configuration or extension-state fact?"}
  F -->|Yes| E
  F -->|No| C
Loading

Reviews (1) · Last reviewed commit: "fix(javascript): treat undici headersLis..." · Reviewed by Greptile

@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: c579f5c566

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +365 to +367
if (extensionStateReads.length > 0 && importsVsCodeModule(state))
for (const start of extensionStateReads)
facts.set(start, "extension-state");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Scope the VS Code proof to the candidate receiver

In a bundled script, collectDefinitionsSteps puts bindings from every factory/scope into state.bindingsById, so one factory's require("vscode") makes this module-wide condition label every collected api.globalState.get("users") or api.workspaceState.get("users") as extension state. In both static and captured-bundle analysis, endpointArgument then drops that unrelated endpoint even when the receiver belongs to another factory/import; the call's receiver identity is never checked. Associate the vscode origin with the candidate's scope/virtual module (and reject known non-context roots) instead of broadcasting one Boolean.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

@alfredo1491

Copy link
Copy Markdown
Contributor Author

The Source tests failure is the 3 src/ghidra/GhidraPowerPcProfile.test.ts cases (resolve_analysis_profile), which currently fail the same way on other open PRs (#3036 is one of 8 recent CI runs with this exact failure). The changes here are limited to JavaScript endpoint classification; all JavaScript suites pass.

@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working labels Oct 13, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
Preserve CommonJS literal paths and confined ESM URL semantics, including package main fallback, directory intent, Unicode identity, and present opaque modules. Parse extraction inputs at their AST/source owner, retain skipped HTML and source-map coverage, and distinguish endpoint candidates from proven receiver facts. Version structural fingerprints with computed literal contents and propagate them through worker contracts.

Reviewed fixes include #1810, #1840, #2642, #2700, #2702, #2714, #2803, #2960, #2968, #2986, #3035, and #3036.

Validation: 158 resolver tests passed; public CLI/MCP module lookup controls, package-main/Unicode workflows, and six builtin workflows passed in the current compiled lane. Worker schema/fingerprint regressions passed. Large public pdf.js completion and real Electron analysis remain unverified.
@alfredo1491

Copy link
Copy Markdown
Contributor Author

Closing as superseded: these changes (the extension-state receiver fact and headersList as a keyed collection, with their tests) were integrated into main in b58adaf as part of the endpoint candidate rework. Thanks for folding them in!

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

@alfredo1491, thank you for catching keyed-store reads being misreported as network endpoints. The static-analysis helpers now keep those collection operations out of endpoint evidence, with a focused WebBundle assertion (main).

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

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants