Repository navigation
fix(javascript): keep keyed-store reads out of endpoints - #3036
alfredo1491 wants to merge 2 commits into
Conversation
`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]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
💡 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".
| if (extensionStateReads.length > 0 && importsVsCodeModule(state)) | ||
| for (const start of extensionStateReads) | ||
| facts.set(start, "extension-state"); |
There was a problem hiding this comment.
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 👍 / 👎.
|
The |
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.
|
Closing as superseded: these changes (the |
|
@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). |
Problem
Follow-up to #2402. Static endpoint extraction still reports reads of two key/value stores as
networkendpoints, because their.get(key)/.delete(key)calls look like HTTP client calls:headersList: bundled undici (the implementation behind Node'sfetch) reads and removes headers throughrequest.headersList.get("location")andheadersList.delete("authorization").headersandsearchParamsare already treated as keyed collections, butheadersListwas not.context.globalState.get("lastVersion")andworkspaceState.get("closedRepositories", [])report every literal state key as an endpoint.Across the 38 bundled
dist/*.jsfiles of the extensions shipped with VS Code, only 14 of 309 reported network endpoints are URL- or path-shaped.Change
isKeyedCollectionReceiveralso accepts theheadersListmember, with the same rule asheaders/searchParams: spelling alone never drops URL- or path-shaped literals.classifyParsedJavaScriptOpenReceiversrecords anextension-statefact for.geton aglobalState/workspaceStatemember. VS Code passes theExtensionContexttoactivate, so the member has no import origin of its own; the fact therefore also requires a binding in the same module whose origin isvscode(namespace/default import orrequire), 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.endpointArgumentskips 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
analyzeJavaScriptStaticSourceover the 38 bundled extensiondist/*.jsfiles of VS Code (resources/app/extensions/*/dist), measured againstmain@ 0e6eca4 before rebasing:mainMost 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.jsmeasured 27.8/31.1/30.7 s after vs 27.4/29.5/30.8 s before. The module-levelvscodeproof runs only when a candidateglobalState/workspaceStateread exists.Verification
src/domain/webBundleAnalyzer.test.ts: new two-analyzer case for extension state (namespace import, require, and a non-vscoderequire that keeps every key), and the keyed-collection case extended withheadersListreads 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