Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(javascript): keep storage open versions out of XHR endpoints

Kaoru0822898b0f62d76e
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(`