#7044

test(javascript): cover the inline-HTML unavailable scope through the public CLI

OpenLopesnextgenwants to merge intofrom

Summary

Valid HTML containing inline <script> bodies is reported through an explicit parse-html-inline-scripts unavailable scope, so an application whose endpoints, storage, or imports live in inline scripts is surfaced as not-analyzed rather than silently empty. That contract was asserted only at the filesystem boundary; the public CLI acceptance surface had no scenario proving it survives transport. This adds the missing acceptance coverage. Tests-only; no source change.

Problem and expected behavior

Trigger: analyze-javascript-application on an app whose index.html has inline scripts (inline fetch/localStorage, a module import) alongside an external <script src>. Expected contract on the public JSON result: an unknown node with operation: "parse-html-inline-scripts" (evidence.state: "unavailable", confidence: "unknown", the HTML byte sha256, partial coverage); the top-level limitations names the unanalyzed inline bodies; the external script still yields its loads edge and recovered endpoint; and the inline-only endpoint/storage facts are absent. Before this change, a regression weakening that scope on the public surface was caught by no acceptance/MCP test.

Change and scope

Adds one acceptance case to tests/acceptance/applications/javascriptUnavailableHtmlCli.test.ts, reusing the file's existing cliTest + schema-parse helpers. It mirrors the existing filesystem-boundary oracle (tests/boundary/filesystem/javascriptHtmlEntrypoints.test.ts) at the public CLI surface. No production/source change and no new capability.

Contribution scope: not applicable — tests-only, within existing boundaries, no target execution, injection, mutation, or protection recovery.

Contract and boundary impact

  • Semantic owner and earliest changed stage: none changed; exercises the src/application/javascript graph projection through the public CLI.
  • Contribution scope fit and linked maintainer decision: tests-only within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: unchanged (asserts the existing analyze-javascript-application --format json output).
  • Provider, bridge, target-format, or platform compatibility: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: asserts the existing unavailable-scope provenance (state/confidence/sha256/coverage); no change.
  • Target selection, authority, upstream behavior, and cleanup: not applicable (synthetic local fixtures in a temp directory).
  • Generated metadata, package, or installation impact: none.

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: tests/acceptance/applications/javascriptUnavailableHtmlCli.test.ts — one new acceptance case.

  • Base reproduction or other evidence: the contract is covered only at the filesystem boundary (javascriptHtmlEntrypoints.test.ts); no acceptance/MCP test hits parse-html-inline-scripts. The new case fails if production stops emitting the scope, mislabels its evidence state/confidence, drops the limitations string, or leaks the inline-only endpoint/storage facts.

  • User-visible CLI/MCP output: unchanged.

  • Remaining proof gaps: MCP-adapter parity not added (CLI only), matching this file's existing surface.

  • 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

  • npm run test:focused -- tests/acceptance/applications/javascriptUnavailableHtmlCli.test.ts — Test Files 1 passed (1); Tests 5 passed (5) (4 pre-existing + the new case), against unmodified source.
  • Pre-push check:fast (turbo typecheck + lint) — 2 tasks successful.
  • Run on Windows x64 after restoring the published prebuilt native addon per native/windows/README.md; Windows native controls are bring-your-own, so CI (Linux) remains the authoritative lane.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (synthetic static fixtures; no real browser execution).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none — tests-only, reserved example.test URLs, no network.

Author readiness

Human owner: @Lopesnextgen

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

Activity

7
chatgpt-codex-connector[bot]1mo ago

Codex Review Summary

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

ReviewStatusCommitReview trigger
📝 Code Review⚠️ Failed 2026-10-25T01:35:58.442767Z
We couldn’t complete this review. Comment @codex review to try again.
57c848fManual request
ℹ️ 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.

greptile-apps[bot]1mo ago

Confidence Score: 5/5

[Low impact] The PR appears safe to merge; the earlier assertion gap is fixed.

Summary

Adds public CLI coverage for unavailable inline JavaScript while checking that external script facts survive.

  • CLI coverage now checks unavailable inline-script results.

Reviews (2) · Last reviewed commit: "test(javascript): pin the external-scrip..." · Reviewed by Greptile

Lopesnextgen1mo ago

@codex review

chatgpt-codex-connector[bot]1mo ago

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

CassieFox2317d ago

TL;DR: The PR's test file passes, 5 of 5 on Node 22.23.4, 24.22.1 and 26.12.1. I also checked that its storage check looks at the right field. A probe put a localStorage call in main.js, and REA reported it under name, with no node for the inline key.

CheckNode 22.23.4Node 24.22.1Node 26.12.1
Head 57c848f794, javascriptUnavailableHtmlCli.test.tspass: 5 of 5 testspass: 5 of 5 testspass: 5 of 5 tests
Head 57c848f794, my probe filepass: 1 of 1 testpass: 1 of 1 testpass: 1 of 1 test

The storage probe

The new test checks that no storage node has properties.name equal to inlineKey (lines 200 to 206). But its main.js makes no storage call (line 113). So if storage facts used some other field, that check would still pass.

My probe copies the new test's setup and adds one line to main.js: localStorage.setItem("probe-key", "v");. The inline script still writes inline-only-key. On all three Node versions, the probe logged one storage node:

storage observation properties [{"storage_kind":"local-storage","name":"probe-key","mechanism":"call:localStorage.setItem"}]

So name is the right field. The key from main.js shows up, and the inline-only key does not.

CI

  • CI is completed/action_required, so no test jobs ran. PR title is completed/action_required too.
  • PR readiness has one success, one failure and two cancelled runs. Validate author declaration shows the same mix.
  • GitHub reports mergeable MERGEABLE and state BLOCKED. The head is 1355 commits behind main 99d00d1041.

Not run

  • A merge with current main, 99d00d1041.
Probe file

Saved as tests/acceptance/applications/javascriptUnavailableHtmlCliProbe.test.ts on the head.

import { createHash } from "node:crypto";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect } from "vitest";

import { parseEvidence } from "../../../src/domain/evidence.js";
import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascript/javascriptApplicationAnalysis.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { cliTest } from "../../support/cli/cliFixture.js";

cliTest(
  "reports a storage node when main.js writes localStorage after HTML is unavailable",
  async ({ cli }) => {
    const root = await createTestTempDirectory("rea-inline-html-cli-probe-");
    const inlineKey = "probe-key";
    const moduleBody = 'import "./main.js";';
    const mainJs = [
      'fetch("https://example.test/external");',
      `localStorage.setItem("${inlineKey}", "v");`,
    ].join("\n");
    const htmlBytes = Buffer.from(
      [
        "<!doctype html><html><head>",
        '<script src="main.js"></script>',
        "<script>",
        `fetch("https://example.test/inline-only"); localStorage.setItem("inline-only-key", "value");`,
        "</script>",
        `<script type="module">${moduleBody}</script>`,
        '<script type="application/json">{"value":42}</script>',
        "</head></html>",
      ].join("\n"),
    );
    await writeFile(
      join(root, "package.json"),
      '{"name":"inline-html-scope","main":"main.js"}',
    );
    await writeFile(join(root, "main.js"), mainJs);
    await writeFile(join(root, "index.html"), htmlBytes);
    const response = await cli.run({
      arguments: [
        "analyze-javascript-application",
        root,
        ...["package.json", "main.js", "index.html"].flatMap((path) => [
          "--source-path",
          path,
        ]),
        "--format",
        "json",
      ],
    });
    expect(response.exitCode, response.stderr).toBe(0);
    const result = javascriptApplicationAnalysisResultSchema.parse(
      parseEvidence(response.json).normalized_result,
    );
    const scopes = result.graph.nodes
      .filter(({ kind }) => kind === "unknown")
      .flatMap(({ observations }) => observations)
      .filter(
        ({ properties }) =>
          properties.operation === "parse-html-inline-scripts" &&
          properties.path === "index.html",
      );
    expect(scopes).toHaveLength(1);
    expect(scopes[0]).toMatchObject({
      properties: {
        operation: "parse-html-inline-scripts",
        path: "index.html",
        inline_script_count: 2,
        inline_scripts: [
          {
            script_type: "classic",
            location: {
              start: { line: 3, column: 8 },
              end: { line: 5, column: 0 },
            },
          },
          {
            script_type: "module",
            location: {
              start: { line: 6, column: 22 },
              end: { line: 6, column: 22 + moduleBody.length },
            },
          },
        ],
      },
      evidence: {
        state: "unavailable",
        confidence: "unknown",
        artifact: {
          sha256: createHash("sha256").update(htmlBytes).digest("hex"),
        },
        coverage: { status: "partial" },
      },
    });
    expect(result.graph.coverage).toMatchObject({
      status: "partial",
      truncated: false,
    });
    expect(result.graph.limitations).toContain(
      "index.html has 2 inline JavaScript bodies starting at lines 3, 6 that were not analyzed; endpoints, storage, imports and other facts in them are absent from the evidence.",
    );
    expect(
      result.graph.edges.some(
        ({ relation, properties }) =>
          relation === "loads" &&
          properties.script_path === "main.js" &&
          properties.resolved_path === "main.js",
      ),
    ).toBe(true);
    expect(
      result.graph.nodes
        .filter(({ kind }) => kind === "endpoint")
        .flatMap(({ observations }) => observations)
        .map(({ properties }) => properties.value),
    ).toContain("https://example.test/external");
    expect(
      result.graph.nodes.some(
        ({ kind, observations }) =>
          kind === "endpoint" &&
          observations.some(({ properties }) => properties.value === inlineKey),
      ),
    ).toBe(false);
    const storageNodes = result.graph.nodes.filter(
      ({ kind }) => kind === "storage",
    );
    console.log(
      "storage nodes count",
      JSON.stringify(storageNodes.map(({ observations }) => observations.map(({ properties }) => properties.name))),
    );
    const storageObservations = storageNodes.flatMap(
      ({ observations }) => observations,
    );
    console.log(
      "storage observation properties",
      JSON.stringify(storageObservations.map(({ properties }) => properties)),
    );
    const hasProbeKey = storageObservations.some(
      ({ properties }) => properties.name === inlineKey,
    );
    expect(hasProbeKey).toBe(true);
  },
);
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 57c848f794 / 149b43ee61 (merge base with main)
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/acceptance/applications/javascriptUnavailableHtmlCli.test.ts
xvfb-run -a npm run test:focused -- tests/acceptance/applications/javascriptUnavailableHtmlCliProbe.test.ts

🤖 Written and tested with Claude Code (Opus 5.5), posted with my OK 🦊