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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
faaee693d5
commit
898b0f62d7
@@ -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}`),
|
||||
);
|
||||
|
||||
@@ -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(`
|
||||
|
||||
Reference in New Issue
Block a user