fix(javascript): keep keyed-collection reads out of endpoints
Static endpoint extraction read the first literal argument of any call
named get, post, put, patch, delete, or request as an HTTP request URL.
Reads of a provable keyed collection also became network endpoints in
application and web bundle analysis: `new URLSearchParams(...).get("q")`,
`response.headers.get("content-type")`, `new Map().get("key")`, and
`url.searchParams.get("page")`.
Skip these calls only when the receiver is a constructed Map, WeakMap,
Set, WeakSet, Headers, FormData, or URLSearchParams, or a platform
`headers`/`searchParams` property. Any other receiver may still be an
HTTP client with a base URL, so `api.get("users")` keeps its endpoint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8e8921d40c
commit
eb68761eb0
@@ -190,6 +190,26 @@ describe("web bundle static-analysis parity", () => {
|
||||
).toEqual(["/dav/", "/xhr-get", "https://xhr.example.test/submit"]);
|
||||
});
|
||||
|
||||
it("keeps HTTP-method-named reads of provable keyed collections out of endpoints", () => {
|
||||
const result = analyzeCapturedWebBundle(
|
||||
inspection(`
|
||||
axios.get("https://api.example.test/users");
|
||||
api.get("users");
|
||||
client.delete("cache-key");
|
||||
new Map().get("map-key");
|
||||
new URLSearchParams(location.search).get("q");
|
||||
new Headers(init).delete("x-trace");
|
||||
new FormData(form).get("file");
|
||||
response.headers.get("content-type");
|
||||
request?.headers.delete("cookie");
|
||||
new URL(location.href).searchParams.get("page");
|
||||
`),
|
||||
);
|
||||
expect(
|
||||
result.observations.endpoints.map(({ value }) => value).sort(),
|
||||
).toEqual(["cache-key", "https://api.example.test/users", "users"]);
|
||||
});
|
||||
|
||||
it("recognizes loadURL endpoints like static analysis", () => {
|
||||
const result = analyzeCapturedWebBundle(
|
||||
inspection('window.win.loadURL("https://embedded.test/app");'),
|
||||
|
||||
Reference in New Issue
Block a user