Skip to content

fix(javascript): read the target of method-first request(method, url) calls - #9509

Merged
N0zoM1z0 merged 1 commit into
morluto:mainfrom
pedrocormann:endpoint-request-method-first
Nov 21, 2026
Merged

N0zoM1z0 merged 1 commit into
morluto:mainfrom
pedrocormann:endpoint-request-method-first

Conversation

@pedrocormann

@pedrocormann pedrocormann commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

analyze_javascript_application and analyze_web_bundle take the first
literal argument of a request(...) call as its network endpoint candidate.
Method-first clients put the HTTP method there: superagent's
request(method, url), needle's needle.request(method, url, data) and
Angular's HttpClient.request(method, url, options). On this client, both
analyzers report the candidates get, POST and delete, and neither
/api/v1/profile nor /api/v1/items is reported as an endpoint or endpoint
candidate:

const BASE = "https://api.example.test";
class Api {
  static async request(method, path, body) {
    return fetch(BASE + path, { method, body: JSON.stringify(body) });
  }
  static profile() { return Api.request("get", "/api/v1/profile"); }
  static save(item) { return Api.request("POST", "/api/v1/items", item); }
  static remove(id) { return Api.request("delete", `/api/v1/items/${id}`); }
}

With this change, when a request call's first argument is a standard HTTP
method token and its second argument is an exact string, the second argument is
the candidate. Every other call keeps its current result, including a method
token followed by a computed target (remove above still reports delete).

No issue is linked: the trigger is self-contained, and the failure and the fix
are both shown below. Related: #2806 (closed); its fix made the arguments of
unverified receivers low-confidence candidates. #3539 (open) asks for path
literals passed to project-specific request wrappers, a different call shape
that this PR does not address.

Problem and expected behavior

Smallest trigger:
analyzeJavaScriptStaticSource('Api.request("get", "/api/v1/profile");')
returns one endpoint, { value: "get", mechanism: "call:Api.request", interpretation: "candidate" }, and analyze_web_bundle records the same value
as an endpoint_candidate inference.

Violated invariant: an HTTP method token is not a request target. xhrOpenUrl
already applies this to open(method, url): a standard method (XHR_METHODS,
compared after toUpperCase()) makes the second argument the URL. The
request branch of endpointArgument had no such rule, so the method token
became the endpoint value.

Expected: Api.request("get", "/api/v1/profile") yields the candidate
/api/v1/profile. It remains a low-confidence candidate, because the receiver
is still unproven.

Change and scope

  • endpointArgument in src/domain/javascript/javascriptStaticAnalysisHelpers.ts
    is the one owner both analyzers use for method-named calls. For a request
    callee whose first literal is in XHR_METHODS (compared as xhrOpenUrl
    compares it), an exact second string is now the candidate value. "Exact"
    means stringValue: a string literal or a template without substitutions.
  • Unchanged:
    • A computed target keeps the method token as the candidate, so the three
      existing expectations for request("POST", target) stay as they are
      (JavaScriptAnalysisWorkerSchemas.test.ts and two cases in
      webBundleAnalyzer.test.ts).
    • A first argument that is not a bare standard method keeps its current
      value: an RPC name (rpc.request("initialize", "/session")), an Octokit
      route string ("GET /repos/{owner}/{repo}") or a URL-first call
      (request("https://example.test/health", "GET")).
  • Not included: callees with other names (such as superagent bound to
    superagent), extension methods such as PROPFIND, configuration-object
    calls such as axios.request({ url }), and wrapper parameters ([Feature] analyze_web_bundle: surface path- and URL-shaped literals passed to project request wrappers #3539).
  • Docs: one paragraph in
    docs/guides/javascript/javascript-artifact-reconstruction.md, after the
    overloaded .open rule.

Open question for maintainers: should a method token with a computed target be
dropped instead of kept? Angular's own HttpClient methods call
this.request('GET', url, options) with a computed url, and #2806 listed
such method names (call:request) among its Juice Shop results. Dropping them
would remove that noise, but it would change the three existing expectations
above, so this PR keeps the current behavior. The alternative is a small change
to the same branch plus those three expectations.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Scope decision: not applicable; this is a fix within the existing static
analysis boundary.

Contract and boundary impact

  • Semantic owner and earliest changed stage: endpointArgument, which
    interprets the literal arguments of method-named calls. Its consumers are
    inspectLiteralEndpointCall in javascriptStaticAnalysisCalls.ts (static
    endpoint facts and the application graph's endpoint nodes) and inspectCall
    in webBundleAnalyzerInspection.ts (endpoint_candidate inferences). The
    semantic request operations in javascriptSemanticDataEffects.ts read
    request only on proven Node http/https bindings, which take the URL
    first, and are unchanged. No superseded path remains.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema or catalog change. For this call
    shape, the value of an existing endpoint candidate changes from the method
    token to the target string.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: the affected rows
    keep interpretation: "candidate", inferred state, low confidence, their
    mechanism and their source location. Both analyzers still pass the value
    through sanitizeEndpointCandidate.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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

Evidence is executed unless marked source-derived.

  • Tests added or updated:

    • src/domain/webBundleAnalyzer.test.ts, new
      web bundle method-first request candidates case: one source analyzed by
      both analyzeWebBundleFixture and analyzeJavaScriptStaticSource, which
      must report the same candidate set and no endpoint observations. Rows:
      lowercase, uppercase and mixed-case method tokens, a template without
      substitutions, a bare request, and absolute and relative targets.
      Controls: two computed targets that keep the token, an RPC name followed by
      a path, an Octokit route string and a URL-first call.
    • tests/boundary/cli/javascriptRendererEndpoints.test.ts: a
      cliTest.for(["CLI", "stdio MCP"]) case analyzes a variant of the
      summary's Api client through the public analyze-javascript-application
      command and analyze_javascript_application MCP tool. Its
      call:Api.request endpoint observations must be
      /api/v1/items, /api/v1/profile and delete, each with
      interpretation: "candidate", inferred state and low confidence.
  • Base reproduction or other evidence: with the new tests and the base source
    (88cf49803, origin/main when this branch was cut), all three new cases
    fail. The module case stops at its web-bundle assertion; the CLI and stdio
    MCP cases go through the static analyzer:

    × web bundle method-first request candidates > reads the exact target after an HTTP method token in both analyzers
      - Expected  + Received
      [
    -   "/api/v1/items",
    -   "/api/v1/items/1",
    -   "/api/v1/profile",
    +   "DELETE",
        "GET /repos/{owner}/{repo}",
    +   "POST",
        "POST",
    +   "Patch",
        "delete",
    -   "https://api.example.test/items/1",
    +   "get",
        "https://example.test/health",
        "initialize",
    -   "users",
    +   "options",
      ]
    × reports the exact target of method-first request calls through CLI  (same for stdio MCP)
      AssertionError: expected [ 'POST', 'delete', 'get' ] to deeply equal [ '/api/v1/items', …(2) ]
    
  • User-visible CLI/MCP output (if applicable): the fixture below, analyzed
    with rea analyze-javascript-application <dir> --format json. Rows are the
    graph's endpoint observations, selected with the jq filter below and sorted
    by line. "Before" is a build of 88cf49803, "after" a build of this branch,
    each made with npm run build:cached.

    # 88cf49803
    api.js:5 "BASE + path" call:fetch - observed/exact
    api.js:7 "get" call:Api.request candidate inferred/low
    api.js:8 "POST" call:Api.request candidate inferred/low
    api.js:9 "delete" call:Api.request candidate inferred/low
    api.js:11 "url" call:fetch - observed/exact
    api.js:12 "https://example.test/health" call:http.request candidate inferred/low
    api.js:14 "initialize" call:rpc.request candidate inferred/low
    # this branch
    api.js:5 "BASE + path" call:fetch - observed/exact
    api.js:7 "/api/v1/profile" call:Api.request candidate inferred/low
    api.js:8 "/api/v1/items" call:Api.request candidate inferred/low
    api.js:9 "delete" call:Api.request candidate inferred/low
    api.js:11 "url" call:fetch - observed/exact
    api.js:12 "https://example.test/health" call:http.request candidate inferred/low
    api.js:14 "initialize" call:rpc.request candidate inferred/low
    

    The published rea-agents 6.8.0 CLI reports the same three
    call:Api.request rows as 88cf49803 (get, POST, delete).
    analyze_web_bundle's script analysis, run on the same api.js through
    analyzeWebBundleFixture, gives the call:Api.request candidates get,
    POST, delete at base and /api/v1/profile, /api/v1/items, delete on
    this branch; its two other candidates (https://example.test/health,
    initialize) are the same on both.

    Fixture and jq filter

    package.json: { "name": "fx-endpoints", "version": "1.0.0", "main": "api.js" }

    "use strict";
    const BASE = "https://api.example.test";
    class Api {
      static async request(method, path, body) {
        return fetch(BASE + path, { method, body: JSON.stringify(body) });
      }
      static profile() { return Api.request("get", "/api/v1/profile"); }
      static save(item) { return Api.request("POST", "/api/v1/items", item); }
      static remove(id) { return Api.request("delete", `/api/v1/items/${id}`); }
    }
    const http = { request: (url) => fetch(url) };
    http.request("https://example.test/health");
    const rpc = { request: (method, params) => params };
    rpc.request("initialize", {});
    module.exports = Api;
    .normalized_result.graph.nodes[] | select(.kind == "endpoint") | .observations[] as $o | $o.properties as $p
    | "\($o.evidence.location.value.source):\($o.evidence.location.value.start.line) \($p.value | tojson) \($p.mechanism) \($p.interpretation // "-") \($o.evidence.state)/\($o.evidence.confidence)"
  • Remaining proof gaps:

    • analyze_web_bundle ran through its module fixture
      (analyzeWebBundleFixture), not a live browser capture.
    • No application built with superagent, needle or Angular was analyzed. Their
      request(method, url) signatures are source-derived, from each project's
      documentation and source.
    • A method token followed by a computed target still yields the token (see
      the open question above).

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Boundary regressions covered: raw identity and normalization (lowercase,
uppercase and mixed-case method tokens select the same rule, and the target
keeps its source spelling) and missing, empty, and unknown values (a computed
target leaves the existing candidate rather than dropping the row). No resource
ownership or lifecycle stage changes, so no lifecycle regression applies.

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

Run on macOS arm64 with Node 24.22.2 (.nvmrc pins 24.22.1) and dependencies
installed from the unchanged lockfile. "Base" means
javascriptStaticAnalysisHelpers.ts at 88cf49803 with this branch's tests.

  • npx tsx probe calling analyzeJavaScriptStaticSource('Api.request("get", "/api/v1/profile");')
    — base: [{"kind":"network","value":"get","mechanism":"call:Api.request","interpretation":"candidate"}];
    this branch: the same row with "value":"/api/v1/profile".
  • npx tsx probe running analyzeWebBundleFixture on the fixture's api.js
    — base and branch candidates as listed above.
  • npx vitest run src/domain/webBundleAnalyzer.test.ts -t "method-first request candidates"
    — base: Tests 1 failed | 78 skipped (output above).
  • npx vitest run on 19 source suites that exercise endpoint extraction:
    webBundleAnalyzer, webBundleAnalyzerAst, JavaScriptAnalysisWorkerSchemas,
    webBundleView, staticObservedEndpoints, javascriptRpcEndpoints,
    javascriptApplicationEndpointCorrespondence,
    javascriptReturnedReferenceCoverage, javascriptSemanticProvenanceAssignments,
    javascriptRouteScan, javascriptStaticAnalysisCallableReceivers,
    javascriptStaticAnalysisCalleeBoundary, and the javascriptStaticAnalysis.
    suites mapEndpoints, mapOpaqueEffects, partialEndpoints,
    event_source, send_beacon, routeProperties and sqliteStorage — this
    branch: Test Files 19 passed (19), Tests 794 passed (794).
  • npm run test:focused -- tests/boundary/cli/javascriptRendererEndpoints.test.ts
    — this branch: Tests 5 passed (5). Base, rebuilt: Tests 2 failed | 3 passed (5);
    the two failures are the new CLI and stdio MCP cases.
  • npm run test:focused -- on javascriptRendererEndpoints together with
    tests/boundary/mcp/javascriptEndpointCandidate.test.ts,
    tests/acceptance/applications/javascriptEndpointCandidateCli.test.ts,
    tests/boundary/filesystem/javascript-applications/javascriptArtifactGraphEndpoints.test.ts
    and tests/boundary/mcp/webBundleViewsMcp.test.ts — 13 of 14 passed. The
    acceptance case "reports a candidate endpoint through the worker boundary in
    the public CLI" hit its 20 s test timeout while the five files ran in
    parallel at background priority. Run alone, that file passed
    (Tests 2 passed (2), the case in 5.6 s).
  • analyze-javascript-application on the fixture with the base build, this
    branch's build and the published rea-agents 6.8.0 CLI — output above.
  • npm run check:fast (typecheck and lint) — passed. Its first run failed with
    max-lines-per-function (157 > 150) on the describe that first held the new
    module case; the case moved to its own describe, and the rerun passed with
    0 errors. oxlint on javascriptStaticAnalysisHelpers.ts reports the same
    three warnings at base and on this branch; the existing complexity warning
    on endpointArgument rises from 23 to 26.
  • npx oxfmt --check on the four touched files — formatted.
  • npm run verify:test-discovery — "Discovered all 3196 test files exactly once."
  • npm run docs:check — passed, including check-doc-facts and
    readmeConsistency (9 passed).
  • npm run build:cached — passed (used by the CLI runs and boundary tests).
  • Git hooks: pre-commit lint-staged (oxlint --fix, oxfmt) passed with no
    changes; pre-push check:fast passed (Turbo cache of the run above).
  • Not run: the rest of npm run check (repository-wide format:check, knip,
    metadata:check, architecture guards, knip:production and typed lint),
    npm run check:pr, the full test suite, and analyze_web_bundle against a
    live browser.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. For request(<method>, "<string>")
    calls, the candidate value changes from the method token to the string; a
    consumer that matched those token values now sees the target instead.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; static
    JavaScript analysis only. analyze_web_bundle was covered through its module
    fixture, not a live browser.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no analyzed source is
    executed. The new candidate value is a source literal, and both analyzers
    pass it through sanitizeEndpointCandidate, as they do for a first-argument
    URL.

Author readiness

Human owner: @pedrocormann

  • 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.

🤖 Generated with Claude Code

… calls

endpointArgument takes the first literal of a get/post/put/patch/delete/request
call as its endpoint candidate. Method-first clients (superagent's
request(method, url), needle.request, Angular HttpClient.request) put the HTTP
method there, so Api.request("get", "/api/v1/profile") reported the candidate
"get" in both analyze_javascript_application and analyze_web_bundle, and the
path was lost.

For a request callee whose first literal is a standard HTTP method (the
XHR_METHODS set that xhrOpenUrl uses, compared after toUpperCase), an exact
second string is now the candidate. A computed target keeps the method token,
so request("POST", target) is unchanged, as are RPC names, Octokit route
strings and URL-first calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defect was found in the changed behavior.

Summary

Updates the shared endpointArgument helper so request(method, url) uses an exact second string when the first string is a standard HTTP method.

  • Method-first request calls report their target strings as candidates.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["request(first, second)"] --> B{"First is a standard method<br/>and second is an exact string?"}
  B -->|Yes| C["Select second"]
  B -->|No| D["Keep first"]
  C --> E["Shared endpoint candidate"]
  D --> E
  E --> F["Static application analyzer"]
  E --> G["Web bundle analyzer"]
  F --> H["Remove URL credentials; retain candidate status"]
  G --> H
Loading

Reviews (4) · Last reviewed commit: "fix(javascript): read the target of meth..." · Reviewed by Greptile

@pedrocormann
pedrocormann marked this pull request as ready for review November 9, 2026 00:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T00:56:29.417095Z 7b22391 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Reopening to get CI against current main: the earlier runs were created when this branch was pushed, so they tested an older main. The failures in them (javascriptIndirectLoaderOwners, ciPrHealth, sourcePublicationComposed) pass on current main and are unrelated to this change.

@N0zoM1z0 N0zoM1z0 closed this Nov 21, 2026
@N0zoM1z0 N0zoM1z0 reopened this Nov 21, 2026

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified: method-first request(method, url) calls read the target from the second argument only for a standard method token. The web bundle and renderer endpoint suites pass on current main (96), and fresh CI is green. Thanks.

@N0zoM1z0
N0zoM1z0 merged commit 73bc6f4 into morluto:main Nov 21, 2026
89 of 98 checks passed
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 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.

4 participants