From 898b0f62d76ea1cf793140cb255cad16ab85b44d Mon Sep 17 00:00:00 2001 From: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Date: Wed, 7 Oct 2026 07:54:09 +0000 Subject: [PATCH] fix(javascript): keep storage open versions out of XHR endpoints #877 reads a computed-method `.open(method, url)` as XMLHttpRequest when the second literal could be a URL. IndexedDB uses the same callee name with a database name and version, so `indexedDB.open(name, "2")` was published as the network endpoint "2". Recognized storage `open` calls (IndexedDB and Cache Storage) are no longer read as XHR. Both the bundle and static analyzers still report them as storage. Co-Authored-By: Claude Opus 5.5 --- src/domain/javascriptStaticAnalysisHelpers.ts | 6 +++++- src/domain/webBundleAnalyzer.test.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/domain/javascriptStaticAnalysisHelpers.ts b/src/domain/javascriptStaticAnalysisHelpers.ts index bd9b27615..96d0d2023 100644 --- a/src/domain/javascriptStaticAnalysisHelpers.ts +++ b/src/domain/javascriptStaticAnalysisHelpers.ts @@ -483,7 +483,11 @@ export const endpointArgument = ( ): string | undefined => { if (name === "fetch" || name.endsWith(".fetch") || name === "WebSocket") return stringValue(args[0]); - if (name.endsWith(".open")) return xhrOpenUrl(name, args[0], args[1]); + // IndexedDB and Cache Storage `open` take a name and a version, not a URL. + if (name.endsWith(".open")) + return storageKind(name) === undefined + ? xhrOpenUrl(name, args[0], args[1]) + : undefined; const method = ["get", "post", "put", "patch", "delete", "request"].find( (candidate) => name === candidate || name.endsWith(`.${candidate}`), ); diff --git a/src/domain/webBundleAnalyzer.test.ts b/src/domain/webBundleAnalyzer.test.ts index 86e6bec90..d6248dc4e 100644 --- a/src/domain/webBundleAnalyzer.test.ts +++ b/src/domain/webBundleAnalyzer.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { webPageInspectionSchema } from "./browserObservation.js"; +import { analyzeJavaScriptStaticSource } from "./javascriptStaticAnalysis.js"; import { analyzeCapturedWebBundle } from "./webBundleAnalyzer.js"; import { webBundleAnalysisSchema } from "./webBundleAnalysis.js"; import { createWebTextArtifact } from "./webContentArtifact.js"; @@ -208,6 +209,22 @@ describe("web bundle static-analysis parity", () => { ]); }); + it("reads storage open versions as storage rather than endpoints in both analyzers", () => { + const source = ` + indexedDB.open(databaseName, "2"); + window.indexedDB.open(databaseName, "/v3"); + `; + expect( + analyzeCapturedWebBundle(inspection(source)).observations.endpoints, + ).toEqual([]); + const analysis = analyzeJavaScriptStaticSource(source); + expect(analysis.endpoints).toEqual([]); + expect(analysis.storage.map(({ kind }) => kind)).toEqual([ + "indexed-db", + "indexed-db", + ]); + }); + it("keeps HTTP-method-named reads of provable keyed collections out of endpoints", () => { const result = analyzeCapturedWebBundle( inspection(`