Skip to content

fix(javascript): keep unresolved network request targets visible as partial endpoints - #3534

Closed
hemv-857 wants to merge 3 commits into
morluto:mainfrom
hemv-857:fix-3451-partial-network-endpoints
Closed

hemv-857 wants to merge 3 commits into
morluto:mainfrom
hemv-857:fix-3451-partial-network-endpoints

Conversation

@hemv-857

@hemv-857 hemv-857 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3451

Summary

analyze-javascript-application reports a network endpoint observation only when a recognized request call's target is an exact string literal. Any other construction (template literal, variable base, URL object, config property) produced no endpoint observation at all, so an application whose requests are all dynamically shaped read as having no first-party backend. Non-literal request targets of unambiguous network APIs are now retained as partial endpoints carrying the unresolved source expression, and targets that resolve through the existing constant lattice (config properties, new URL(...) bindings) resolve to complete endpoints.

Problem and expected behavior

Smallest trigger (from the issue):

fetch(`https://core.example.com/notes/${id}/audio/`);

Observed before: no endpoint observation; the application graph contained no network endpoint node for the call site. Violated invariant: a recognized request call site must remain visible even when its target is not statically exact.

Expected: the call site produces a network endpoint observation with the unresolved part explicit. Constant shapes resolve fully:

const cfg = { wsUrl: "wss://config.example.com" };
new WebSocket(cfg.wsUrl); // → wss://config.example.com
const u = new URL("wss://realtime.example.com");
new WebSocket(u);
new WebSocket(u.toString()); // → wss://realtime.example.com

Change and scope

One fallback at the single static-analysis choke point inspectEndpointCall (src/domain/javascript/javascriptStaticAnalysisCalls.ts), reusing existing machinery:

  • evaluateSemanticExpression — the bounded constant lattice the semantic analysis already uses. Targets that evaluate to string literals resolve to complete endpoints.
  • A narrow URL-object unwrap: a single immutable binding initialized by new URL(...), forwarded directly or through zero-argument .toString(), following the new URL unwrapping precedent in workerUrlSpecifier in the same file. A single literal argument matches the literal path's exact text; a two-argument new URL(input, base) with literal arguments resolves through the platform URL constructor; a non-literal base, a member write anywhere in the program (u.hostname = ...; the static pass does not collect member mutations, so writes are detected syntactically once per parse), or any other irregularity keeps the target partial rather than reporting a possibly wrong complete URL.
  • sourceSlice — the same specifier/expression retention pattern as JavaScriptStaticReference and ElectronStaticValue. URL userinfo is stripped from retained expression text before storage; interpolations stay untouched.

Applied to unambiguous network APIs: bare fetch, WebSocket, EventSource, member EventSource, sendBeacon, member sendBeacon. Member .fetch is excluded from the partial fallback — local cache and service-worker style methods share the name without making a request, and the literal path's pre-existing behavior is unchanged. HTTP-method-named calls (get, post, request, ...) are excluded on purpose: their first argument is frequently a collection or setting key (map.get(key), configuration reads), and emitting partial endpoints there would flood results with false endpoints.

Partial endpoints carry a disjoint "partial" segment in their artifact-local identity, so a partial expression and a complete literal with the same text (fetch(target) vs fetch("target")) never collapse into one node; complete endpoint identities are unchanged.

Intentionally not included:

  • The semantic graph's requestEndpoint reader (javascriptSemanticDataEffects.ts) remains literal-only. That surface already reports these call sites as request operations with resolution: "partial" and an explicit unknown endpoint; carrying the partial text there touches the semantic IR with a wider blast radius and belongs in a follow-up.
  • Route-property templates are a different endpoint kind with their own guard and are unchanged.
  • analyze_web_bundle has a separate endpoint-candidate path and is unchanged.

Contribution scope: ordinary bug fix within existing static-analysis boundaries. Maintainer scope decision: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: static JavaScript analysis domain (javascriptStaticAnalysisCalls.ts), consumed by the application-graph projection and the worker schema.
  • Contribution scope fit and linked maintainer decision: fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: no tool input/output schema changes. Advertised JSON Schemas and catalog digests do not move; endpoint observations are result data.
  • Provider, bridge, target-format, or platform compatibility: none; pure static AST analysis.
  • Evidence, artifact, provenance, or reconstruction contract: partial endpoints keep ast-static-analysis / observed / exact evidence for the call site itself, with an added limitation that the value is an unresolved source expression. Node identity is unchanged: partial values are source expressions and complete values are resolved URLs, so they cannot collide.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata impact: none; regenerated catalogs are ignored outputs and do not change from this diff.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • New src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts (11 tests) — all four shapes from the issue (interpolated template, variable base, URL object direct and through .toString(), config property), two-argument URL bases with literal and non-literal bases, mutated URL objects, credential stripping in retained expressions, member .fetch exclusion, and a negative for collection reads.
    • Updated javascriptStaticAnalysis.event_source.test.ts and javascriptStaticAnalysis.send_beacon.test.ts — the two tests that pinned "dynamic URL unreported" now assert the partial observation; they pinned the reported bug.
    • Boundary tests in javascriptArtifactGraphEndpoints.test.ts — partial node/edge properties with evidence and limitation through buildJavaScriptArtifactGraph, and distinct node identities for fetch(target) vs fetch("target").
    • New worker-schema round-trip in JavaScriptAnalysisWorkerSchemas.test.ts — resolution: "partial" survives the strictObject worker handoff.
  • Base reproduction or other evidence: on the affected base (origin/main at 3b79af2), the partial cases produce no endpoint observation at all (the dynamic EventSource and beacon tests asserted []), which is exactly the reported omission; the complete-resolution shapes (config property, URL object) also produced nothing on base.
  • User-visible CLI/MCP output: analyze_javascript_application graph output gains endpoint nodes with properties.resolution: "partial" and the limitation text; no CLI flag or schema change.
  • Remaining proof gaps: this is static AST analysis only; no browser or client-chat runtime reproduction is claimed.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/domain/javascript/ src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts tests/boundary/filesystem/javascript-applications/javascriptArtifactGraphEndpoints.test.ts tests/boundary/filesystem/javascript-applications/javascriptApplicationEmptyLiterals.test.ts tests/acceptance/applications/javascriptEndpointCandidateCli.test.ts tests/acceptance/applications/javascriptEndpointPayload.test.ts — 74 files, 1674 tests passed.
  • npm run check:fast — typecheck + lint successful.
  • npx tsc --noEmit — clean.
  • npx oxfmt --check on changed files — clean.
  • npm run verify:test-discovery — 1276 test files discovered exactly once.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Existing complete endpoint observations are unchanged; new partial observations are additive; node identity keys are unchanged.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static JavaScript analysis).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: partial endpoint values are source expressions already present in the analyzed artifact; no new data leaves the analysis boundary. sanitizeEndpointCandidate continues to pass unparseable expressions through verbatim.

Author readiness

Human owner: @hemv-857

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…artial endpoints

analyze-javascript-application reported no endpoint observation at all when a fetch, WebSocket, EventSource or sendBeacon request target was not an exact string literal (morluto#3451), so an application whose requests were all template-literal, variable-base or URL-object shaped read as having no first-party backend.

Resolve unambiguous network call targets through the existing constant lattice: object-property and alias bindings that evaluate to a string resolve completely, and a once-assigned new URL("literal") binding resolves when forwarded directly or through .toString(). Anything else is retained as a partial endpoint whose value is the exact unresolved source expression, following the specifier/expression pattern already used for references.

HTTP-method-named calls (get, post, request, ...) are excluded: their first argument is often a collection or setting key rather than a request target. The semantic graph already reports these call sites as partial requests; aligning its requestEndpoint reader is left to a follow-up.
@hemv-857
hemv-857 marked this pull request as ready for review October 14, 2026 16:36
Copilot AI balanced review requested due to automatic review settings October 14, 2026 16:36
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 0/5

[Medium impact] Changes how network endpoints are classified and reported.

The PR is not ready to merge because it can report stale backends, omit browser requests, and retain URL passwords.

Findings

  1. P1 Changed config reports old backend ▶
  2. P1 Changed URLs look unchanged ▶
  3. P1 Security URL passwords reach results ▶
  4. P1 Browser request targets disappear ▶
  5. P2 Local lookups become backends ▶
  6. P2 Endpoint expressions lose source text ▶
Fix with agent prompt
### Issue 1
src/domain/javascript/javascriptStaticAnalysisCalls.ts:521-523
`resolvedRequestTarget` reports stale config values as complete endpoints. For `const cfg = { url: 'https://old.example' }; cfg.url = 'https://new.example'; fetch(cfg.url);`, the evaluator reads the initializer and returns `https://old.example`. Users see the old backend as known, even though the application requests a different one.

The static pass does not collect property changes, and this early return skips the new write check. Populate the evaluator's mutation facts before resolving object properties, or keep these targets partial.

### Issue 2
src/domain/javascript/javascriptStaticAnalysisCalls.ts:576-586
`binding.mutable` covers changes to the binding, not changes to the URL object. For `const u = new URL('https://old.example/socket'); u.hostname = 'new.example'; fetch(u);`, this helper still reports the old URL as complete. Users see the wrong backend without warning.

Check the existing `memberWrites` and `escapedPaths` before reading the raw initializer. Keep the target partial when the object may have changed.

### Issue 3
src/domain/javascript/javascriptStaticAnalysisCalls.ts:undefined-496
For ``fetch(`https://alice:[email protected]/items/${id}`)``, the new partial value retains the backticks and credentials. The backticks make URL parsing fail, so `sanitizeEndpointCandidate` returns the password unchanged. Sharing or retaining endpoint results can now expose credentials that an equivalent literal URL would have removed.

Remove URL userinfo inside retained expressions before storing them, while preserving the unresolved parts.

**How this was verified:** The retained template fails URL parsing, the sanitizer returns unparseable values unchanged, and the graph copies that value into its endpoint properties.

### Issue 4
src/domain/javascript/javascriptStaticAnalysisCalls.ts:465-467
Removing all member `.fetch` calls also drops real browser requests such as `window.fetch(endpointUrl)`, `globalThis.fetch(endpointUrl)`, and `self.fetch(endpointUrl)`. `endpointArgument` accepts only literal targets, so these calls now produce no endpoint. Applications using these calls can still appear to have no backend.

Keep known global receivers eligible while excluding local methods such as `cache.fetch`.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 5
src/domain/javascript/javascriptStaticAnalysisCalls.ts:499-500
The fallback treats locally defined functions as network APIs based only on their names. For `function fetch(key) { return records[key]; } fetch(key);`, it now adds an observed network endpoint even though the function only reads local data. Users must sort these false backends out of the results; marking the target partial does not explain that the call itself may not make a request.

Check the callee's binding before treating it as a known browser API. Keep unproven receivers as candidates rather than observed requests.

### Issue 6
src/domain/javascript/javascriptStaticAnalysisCalls.ts:474-475
`stripExpressionCredentials` can delete part of an interpolation rather than credentials. Given ``fetch(`https://${hosts['a@b']}/items`)``, the regex consumes `https://${hosts['a@` and leaves the broken text `` `https://b']}/items` ``. Users can no longer recover the original dynamic host from the reported value.

Read the template structure before removing userinfo so an `@` inside JavaScript does not damage the retained expression.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR keeps unresolved request targets visible as partial endpoints and resolves some constant targets.

  • JavaScript analysis keeps dynamic request targets as partial endpoints.
  • Application graphs show partial endpoints without merging complete values.

The full PR diff was used because the current and previous heads have different merge bases with the supplied target commit. Whether another PR supersedes this one could not be checked because GitHub access was unavailable. No runtime verification was performed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Request call] --> B{Literal target?}
  B -->|Yes| C[Complete endpoint]
  B -->|No| D{Eligible API name?}
  D -->|No| E[No new endpoint]
  D -->|Yes| F{Constant or URL binding resolves?}
  F -->|Yes| C
  F -->|No| G[Retained expression with partial resolution]
  C --> H[Worker handoff]
  G --> H
  H --> I[Graph endpoint with separate partial identity]
Loading

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment on lines +535 to +538
const binding = resolveSemanticBindingState(bindings, target, target.name);
if (binding === undefined || binding.mutable) return undefined;
const [initializer, ...rest] = binding.initializers;
if (initializer === undefined || rest.length > 0) return undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Changed URLs look unchanged

binding.mutable covers changes to the binding, not changes to the URL object. For const u = new URL('https://old.example/socket'); u.hostname = 'new.example'; fetch(u);, this helper still reports the old URL as complete. Users see the wrong backend without warning.

Check the existing memberWrites and escapedPaths before reading the raw initializer. Keep the target partial when the object may have changed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptStaticAnalysisCalls.ts
Line: 535-538

Comment:
**Changed URLs look unchanged**

`binding.mutable` covers changes to the binding, not changes to the URL object. For `const u = new URL('https://old.example/socket'); u.hostname = 'new.example'; fetch(u);`, this helper still reports the old URL as complete. Users see the wrong backend without warning.

Check the existing `memberWrites` and `escapedPaths` before reading the raw initializer. Keep the target partial when the object may have changed.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

);
return {
kind: "endpoint",
value: resolved ?? sourceSlice(context.source, argument),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security URL passwords reach results

For fetch(`https://alice:[email protected]/items/${id}`), the new partial value retains the backticks and credentials. The backticks make URL parsing fail, so sanitizeEndpointCandidate returns the password unchanged. Sharing or retaining endpoint results can now expose credentials that an equivalent literal URL would have removed.

Remove URL userinfo inside retained expressions before storing them, while preserving the unresolved parts.

How this was verified: The retained template fails URL parsing, the sanitizer returns unparseable values unchanged, and the graph copies that value into its endpoint properties.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptStaticAnalysisCalls.ts
Line: 496

Comment:
**URL passwords reach results**

For ``fetch(`https://alice:[email protected]/items/${id}`)``, the new partial value retains the backticks and credentials. The backticks make URL parsing fail, so `sanitizeEndpointCandidate` returns the password unchanged. Sharing or retaining endpoint results can now expose credentials that an equivalent literal URL would have removed.

Remove URL userinfo inside retained expressions before storing them, while preserving the unresolved parts.

**How this was verified:** The retained template fails URL parsing, the sanitizer returns unparseable values unchanged, and the graph copies that value into its endpoint properties.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Resolve URL objects against a literal base with the platform URL constructor, keep targets partial when the base is not literal or the object's members are written anywhere in the program (the static pass does not collect member mutations), strip URL userinfo from retained expression text, keep partial and complete endpoint identities disjoint when their text matches, and exclude member .fetch methods from the partial fallback.
@hemv-857

Copy link
Copy Markdown
Contributor Author

All five findings addressed in 8b97278.

  1. URL bases: two-argument new URL(input, base) now resolves through the platform URL constructor when both arguments are literals (/socket + https://api.example.com → https://api.example.com/socket); a non-literal base keeps the target partial.
  2. Mutated URL objects: the static pass does not run the semantic member-mutation collector (memberWrites/escapedPaths are only filled by collectSemanticMemberMutationsSteps, which indexJavaScriptBindingsSteps never calls), so writes are detected syntactically once per parse — any u.<member> assignment or update anywhere in the program forces the target partial. Name-based matching only forces partials, never wrong completes.
  3. Credentials: URL userinfo is stripped from retained partial expression text before storage (interpolations untouched); parseable complete values were already sanitized by sanitizeEndpointCandidate.
  4. Identity: partial endpoints now carry a disjoint "partial" identity segment, so fetch(target) and fetch("target") produce distinct nodes; complete identities are byte-identical to before, so the empty-literal seed tests stay green. Boundary test added.
  5. Member .fetch: excluded from the partial fallback (the literal path's pre-existing behavior is unchanged); negative test added.

Validation: 11 domain partial-endpoint tests (6 new), the identity boundary test, the full javascript domain + boundary + acceptance surface (74 files, 1674 tests) all pass; npm run check:fast and npx tsc --noEmit clean.

Comment on lines +459 to +461
const isUnambiguousNetworkCall = (name: string): boolean =>
name === "fetch" ||
name === "WebSocket" ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Browser request targets disappear

Removing all member .fetch calls also drops real browser requests such as window.fetch(endpointUrl), globalThis.fetch(endpointUrl), and self.fetch(endpointUrl). endpointArgument accepts only literal targets, so these calls now produce no endpoint. Applications using these calls can still appear to have no backend.

Keep known global receivers eligible while excluding local methods such as cache.fetch.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptStaticAnalysisCalls.ts
Line: 459-461

Comment:
**Browser request targets disappear**

Removing all member `.fetch` calls also drops real browser requests such as `window.fetch(endpointUrl)`, `globalThis.fetch(endpointUrl)`, and `self.fetch(endpointUrl)`. `endpointArgument` accepts only literal targets, so these calls now produce no endpoint. Applications using these calls can still appear to have no backend.

Keep known global receivers eligible while excluding local methods such as `cache.fetch`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +468 to +469
const stripExpressionCredentials = (expression: string): string =>
expression.replace(/\b([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/giu, "$1");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Endpoint expressions lose source text

stripExpressionCredentials can delete part of an interpolation rather than credentials. Given fetch(`https://${hosts['a@b']}/items`), the regex consumes https://${hosts['a@ and leaves the broken text `https://b']}/items`. Users can no longer recover the original dynamic host from the reported value.

Read the template structure before removing userinfo so an @ inside JavaScript does not damage the retained expression.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptStaticAnalysisCalls.ts
Line: 468-469

Comment:
**Endpoint expressions lose source text**

`stripExpressionCredentials` can delete part of an interpolation rather than credentials. Given ``fetch(`https://${hosts['a@b']}/items`)``, the regex consumes `https://${hosts['a@` and leaves the broken text `` `https://b']}/items` ``. Users can no longer recover the original dynamic host from the reported value.

Read the template structure before removing userinfo so an `@` inside JavaScript does not damage the retained expression.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

# Conflicts:
#	src/domain/javascript/javascriptStaticAnalysisCalls.ts
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Merged latest main into this branch to resolve the javascriptStaticAnalysisCalls.ts conflict. No rebase or force-push was used. Main's service-worker reference (now specifier: undefined) is kept, along with this PR's added bindings argument to inspectEndpointCall. Validation on the merged tree: 161 JavaScript/domain test files (3,000 passed, including this PR's partial-endpoint, event-source and send-beacon tests), JavaScriptAnalysisWorkerSchemas.test.ts (4 passed), the javascriptArtifactGraphEndpoints boundary test (3 passed), and typecheck and lint via the pre-push hook.

Comment on lines +521 to +523
const evaluated = evaluateSemanticExpression(node, bindings);
if (evaluated.status === "literal" && typeof evaluated.value === "string")
return evaluated.value;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Changed config reports old backend

resolvedRequestTarget reports stale config values as complete endpoints. For const cfg = { url: 'https://old.example' }; cfg.url = 'https://new.example'; fetch(cfg.url);, the evaluator reads the initializer and returns https://old.example. Users see the old backend as known, even though the application requests a different one.

The static pass does not collect property changes, and this early return skips the new write check. Populate the evaluator's mutation facts before resolving object properties, or keep these targets partial.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptStaticAnalysisCalls.ts
Line: 521-523

Comment:
**Changed config reports old backend**

`resolvedRequestTarget` reports stale config values as complete endpoints. For `const cfg = { url: 'https://old.example' }; cfg.url = 'https://new.example'; fetch(cfg.url);`, the evaluator reads the initializer and returns `https://old.example`. Users see the old backend as known, even though the application requests a different one.

The static pass does not collect property changes, and this early return skips the new write check. Populate the evaluator's mutation facts before resolving object properties, or keep these targets partial.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +499 to +500
if (receiverFact === "window" || !isUnambiguousNetworkCall(name))
return undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Local lookups become backends

The fallback treats locally defined functions as network APIs based only on their names. For function fetch(key) { return records[key]; } fetch(key);, it now adds an observed network endpoint even though the function only reads local data. Users must sort these false backends out of the results; marking the target partial does not explain that the call itself may not make a request.

Check the callee's binding before treating it as a known browser API. Keep unproven receivers as candidates rather than observed requests.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/javascript/javascriptStaticAnalysisCalls.ts
Line: 499-500

Comment:
**Local lookups become backends**

The fallback treats locally defined functions as network APIs based only on their names. For `function fetch(key) { return records[key]; } fetch(key);`, it now adds an observed network endpoint even though the function only reads local data. Users must sort these false backends out of the results; marking the target partial does not explain that the call itself may not make a request.

Check the callee's binding before treating it as a known browser API. Keep unproven receivers as candidates rather than observed requests.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: Fixed: a network call with a target that is not plain text now keeps a partial endpoint. On current main, 14 of 25 test cases fail. With the PR merged in, all 25 pass on Node 22, 24 and 26. I also ran 78 older JavaScript analysis test files, and all passed.

Thanks, Hemang Varshney, for the careful fix and the many small test cases. This checks the fix for #3451.

Results

Before: main 62bf098 (#4169) plus only this PR's test files. After: main plus this PR's files, merged with git merge-file. One file needed a real 3-way merge, javascriptStaticAnalysisCalls.ts, because main gained 10 lines there. It merged with no conflict. The PR head 06dd652 is a merge of main into the branch by Kaoru0822. I tested the merged tree, not that head.

The six test files are the five the PR adds or changes, plus childProcessOptionsRegression.test.ts as a control. That file is unchanged by the PR.

Check (25 test cases, 6 files) Node 22.23.1 Node 24.18.0 Node 26.11.1
Before: main with the PR's tests 14 fail, 11 pass 14 fail, 11 pass 14 fail, 11 pass
After: main with the PR 25 pass 25 pass 25 pass
78 older JavaScript analysis test files, after not run 2,007 pass not run
npm run typecheck, after not run pass not run

Before the fix, 9 cases fail in the new partialEndpoints file, which has 11. One case each fails in the EventSource, beacon and worker-schema tests. Two fail in the artifact-graph test. All 14 are assertion errors, mostly an empty list where a network endpoint was expected. None is an import error. The 11 that pass before are controls, for example a local .fetch method that must not count as a network target.

The 78 older files are every src/domain/javascript/*.test.ts plus four neighbours that use the same code. I grepped each for doctor first. None called it.

Not run

  • Any test outside the named files above and those 78. No full suite.
  • Lint, and the other platforms.
  • A real bundle or real website through the CLI.
  • Real CI: it ran its full set on the PR head, with 17 checks passing and 15 skipped. I did not read why the 15 were skipped.

No test made a network call. Words such as fetch( and http.request in these tests are source text that the analyser reads. I found this by reading and grepping, not by tracing.

Commands
export PATH=~/.local/opt/node24/bin:$PATH
npm ci
npm run test:focused -- src/domain/javascript/javascriptStaticAnalysis.partialEndpoints.test.ts src/domain/javascript/javascriptStaticAnalysis.event_source.test.ts src/domain/javascript/javascriptStaticAnalysis.send_beacon.test.ts src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts tests/boundary/filesystem/javascript-applications/javascriptArtifactGraphEndpoints.test.ts src/domain/javascript/childProcessOptionsRegression.test.ts
npm run typecheck

The same test command ran on Node 22.23.1 and 26.11.1 by putting that Node first on PATH. The 78-file run used the same command with every src/domain/javascript/*.test.ts file, plus these four files: src/application/javascript/JavaScriptArtifactPathResolution.test.ts, src/application/javascript/JavaScriptSemanticGraphElectronProjection.test.ts, src/domain/webBundleAnalyzer.test.ts and tests/boundary/filesystem/javascript-applications/javascriptArtifactReconstruction.test.ts.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: 06dd652 / 62bf098 (the PR head, then main)
  • Merge base: ab45bf6
  • Other: three other test agents shared the box, so I give no timings.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@hemv-857

Copy link
Copy Markdown
Contributor Author

Thanks for the cross-version verification — Node 22/24/26 all 25/25, 2,007 older JavaScript analysis tests green, typecheck clean. The 14-fail/11-pass pre-change split you measured matches the intent: the 11 that pass before are controls (local methods that must not count as network targets), and the 14 failures are exactly the partial-endpoint, EventSource, send-beacon, worker-schema and artifact-graph assertions this PR fixes.

Noted on your "Not run" list: no full suite, lint or other platforms on your box — real CI on the PR head has 17 checks passing with 15 path-gated skips (the full 5-shard suite ran when the PR first opened; the skips are the Classify-changes job limiting to touched paths on later commits).

morluto added a commit that referenced this pull request Oct 16, 2026
Resolve stable lexical and URL targets using shared effects, and preserve unresolved request expressions as partial facts. Carry their uncertainty through workers, artifact graphs, and the CLI. Scope partial endpoint identity to the source site.

Refs: #3451, #3534

Co-authored-by: Hemang Varshney <[email protected]>
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Conflict check from the CI/conflict track. I did not push anything.

main already carries this change as 018ab2c5d (fix(javascript): retain unresolved network targets with provenance), whose message references this PR and credits its author as co-author. The merge conflicts come from that landed version, so this PR looks superseded. Leaving it for the author or maintainer to close.

@hemv-857

Copy link
Copy Markdown
Contributor Author

Closing as superseded, per @kaoru0822-kitauji's conflict check: main carries this change landed as 018ab2c5d (fix(javascript): retain unresolved network targets with provenance) with my authorship credited as co-author, so the outcome is on main and this branch's conflicts are only against that landed version.

Thanks to kaoru for the merge attempt and the conflict audit, and to CassieFox23 for the cross-version verification (Node 22/24/26, 25/25 with the change, 14/25 without it).

@hemv-857 hemv-857 closed this Oct 16, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Static endpoint discovery omits template-literal, variable-base and URL-object request targets

5 participants