Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
ci(ghidra): compile the packaged bridge source cohort (#3142)
claudetrail2026-droid1b828dbb1011
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 3873fb4a9..95dbdbed1 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -60,6 +60,7 @@ jobs:web_runtime: ${{ steps.plan.outputs.web_runtime }}web_source_map: ${{ steps.plan.outputs.web_source_map }}nativeaot: ${{ steps.plan.outputs.nativeaot }}+ ghidra_bridge: ${{ steps.plan.outputs.ghidra_bridge }}website: ${{ steps.plan.outputs.website }}matrix: ${{ steps.plan.outputs.matrix }}test_selection: ${{ steps.plan.outputs.test_selection }}@@ -899,6 +900,11 @@ jobs:if: needs.changes.outputs.nativeaot == 'true'uses: ./.github/workflows/nativeaot-fixtures.yml+ ghidra_bridge:+ needs: [changes, static]+ if: needs.changes.outputs.ghidra_bridge == 'true'+ uses: ./.github/workflows/ghidra-bridge-sources.yml+website:needs: [changes, static]if: needs.changes.outputs.website == 'true'@@ -934,6 +940,7 @@ jobs:web_runtime,web_source_map,nativeaot,+ ghidra_bridge,website,]runs-on: ubuntu-24.04diff --git a/.github/workflows/ghidra-bridge-sources.yml b/.github/workflows/ghidra-bridge-sources.ymlnew file mode 100644index 000000000..e5c761baa--- /dev/null+++ b/.github/workflows/ghidra-bridge-sources.yml@@ -0,0 +1,48 @@+name: Ghidra bridge source compilation++on:+ workflow_dispatch:+ workflow_call:++permissions:+ contents: read++env:+ HUSKY: "0"++jobs:+ ghidra-bridge-sources:+ name: Compile packaged Ghidra bridge sources+ runs-on: ubuntu-24.04+ timeout-minutes: 15+ env:+ GHIDRA_RELEASE_URL: https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_12.1.4_build/ghidra_12.1.4_PUBLIC_20260921.zip+ GHIDRA_RELEASE_SHA256: ddac49f903da9d5bac833e5cc79395098b9c33cfd3279be5f31bd00387d2d4db+ steps:+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0+ with:+ node-version-file: .nvmrc+ - name: Validate the SDK pin against the provider's verified release+ run: node scripts/verify-ghidra-bridge-sources.mjs --check-sdk-pin >> "$GITHUB_ENV"+ # Only the jars and application.properties are extracted: the check+ # compiles against them and never launches Ghidra or imports a target.+ - name: Acquire checksum-verified Ghidra jars in isolated runner storage+ shell: bash+ run: |+ ghidra_root="${RUNNER_TEMP}/rea-ghidra"+ mkdir -p "${ghidra_root}"+ curl -fsSL --retry 3 --write-out 'ghidra_download_bytes=%{size_download} ghidra_download_seconds=%{time_total}\n' -o "${ghidra_root}/ghidra.zip" "${GHIDRA_RELEASE_URL}"+ echo "${GHIDRA_RELEASE_SHA256} ${ghidra_root}/ghidra.zip" | sha256sum -c -+ unzip -q "${ghidra_root}/ghidra.zip" '*/Ghidra/*.jar' '*/Ghidra/application.properties' -d "${ghidra_root}"+ rm "${ghidra_root}/ghidra.zip"+ properties="$(find "${ghidra_root}" -path '*/Ghidra/application.properties' -print -quit)"+ test -n "${properties}"+ echo "GHIDRA_INSTALL_DIR=$(dirname "$(dirname "${properties}")")" >> "${GITHUB_ENV}"+ # JAVA_HOME_<major>_X64 comes from the runner image, not the env context.+ - name: Compile bridge sources with the verified runner JDK+ shell: bash+ run: |+ java_home_variable="JAVA_HOME_${GHIDRA_JAVA_MAJOR}_X64"+ test -n "${!java_home_variable}"+ JAVA_HOME="${!java_home_variable}" npm run verify:ghidra:bridge-sources -- --verified-sdkdiff --git a/docs/testing.md b/docs/testing.mdindex 53b26e23c..a8817bfb3 100644--- a/docs/testing.md+++ b/docs/testing.md@@ -989,7 +989,19 @@ the Apple or Windows curated lanes invoke explicitly, which also select thatlane. Edits to verifier entrypoints run only by manual, licensed or self-hostedworkflows run static checks and the Linux suite. Website changes run websitechecks. Provider workflow changes validate the workflow and run that provider's-verifier. Manual-provider/Android workflow changes run workflow validation only.+verifier. Changes under `bridge/ghidra/` also select the `ghidra_bridge` lane,+which compiles the packaged bridge sources against the pinned Ghidra 12.1.4+jars with `npm run verify:ghidra:bridge-sources`. It never launches Ghidra or+imports a target, so a missing import fails the PR instead of every Ghidra+session. The launcher, compiler and package checks share named required source+roles. The manifest must match the complete Java cohort, so deleting a helper+or adding an unregistered dependency cannot silently change the shipped set.+The preflight reuses the provider's Java Properties parser with the pinned Node+toolchain's native type stripping, without an npm install or runtime build.+The shared release policy owns the verified version and JDK major. CI checks+the archive pin before downloading and verifies the extracted SDK version;+changes to these source owners also select the compile lane.+Manual-provider/Android workflow changes run workflow validation only.The four-version SQLite compatibility matrix has its own `sqlite` scope forSQLite implementation, contracts, CLI/MCP registration, fixtures, and sharedruntime boundaries. SQLite and server-lifecycle test edits and the SQLite npmdiff --git a/package.json b/package.jsonindex cf1a4defa..3845c7bf8 100644--- a/package.json+++ b/package.json@@ -273,6 +273,7 @@"verify:windows-native": "node scripts/verify-windows-native.mjs","verify:ghidra:windows:package": "node scripts/verify-packaged-ghidra-windows.mjs","build:ghidra:nativeaot": "node scripts/build-ghidra-nativeaot.mjs",+ "verify:ghidra:bridge-sources": "node scripts/verify-ghidra-bridge-sources.mjs","build:fixtures:nativeaot": "node scripts/generate-nativeaot-fixtures.mjs","verify:ghidra:nativeaot": "npm run build:cached && node scripts/verify-real-ghidra-nativeaot.mjs","verify:browser:scripts": "npm run build:cached && node scripts/verify-browser-scripts.mjs",diff --git a/scripts/build-ghidra-nativeaot.mjs b/scripts/build-ghidra-nativeaot.mjsindex 5d06dd60a..f257bfb28 100644--- a/scripts/build-ghidra-nativeaot.mjs+++ b/scripts/build-ghidra-nativeaot.mjs@@ -157,7 +157,7 @@ function propertyValue(content, name) {return null;}-/** Same 12.1 line as GhidraInstallationPolicy, including a distro suffix. */+/** Release line supported by the separately pinned NativeAOT integration. */function ghidraReleaseLineAccepted(raw) {const match = /^(\d+)\.(\d+)(?:\.(\d+))?([-+].*)?$/u.exec(raw ?? "");return match !== null && Number(match[1]) === 12 && Number(match[2]) === 1;diff --git a/scripts/ci/scopes.mjs b/scripts/ci/scopes.mjsindex f1feacc95..515bc70b4 100644--- a/scripts/ci/scopes.mjs+++ b/scripts/ci/scopes.mjs@@ -104,6 +104,7 @@ export const SCOPES = {"tests/boundary/filesystem/npmRelease.test.ts","tests/boundary/process/releaseArtifactCanary.test.ts","src/windows/**",+ "src/ghidra/GhidraBridgeSources.ts","native/windows/**","src/process/capture/FilesystemSnapshot.ts","src/process/capture/FilesystemSnapshot.test.ts",@@ -436,6 +437,14 @@ export const SCOPES = {"tests/fixtures/nativeaot/**",".github/workflows/nativeaot-fixtures.yml",],+ ghidra_bridge: [+ "bridge/ghidra/**",+ "src/ghidra/GhidraBridgeSources.ts",+ "src/ghidra/GhidraJavaProperties.ts",+ "src/ghidra/GhidraReleasePolicy.ts",+ "scripts/verify-ghidra-bridge-sources.mjs",+ ".github/workflows/ghidra-bridge-sources.yml",+ ],website: ["website/**","scripts/*website*.py",diff --git a/scripts/verify-ghidra-bridge-sources.mjs b/scripts/verify-ghidra-bridge-sources.mjsnew file mode 100644index 000000000..9d5f30a1c--- /dev/null+++ b/scripts/verify-ghidra-bridge-sources.mjs@@ -0,0 +1,182 @@+#!/usr/bin/env node+// Compile the packaged Ghidra bridge sources against an existing Ghidra+// installation's jars. Ghidra's script provider compiles the whole bridge+// directory when a session starts, so one unresolved symbol disables every+// operation and surfaces only after import and auto-analysis. This check+// reports the same javac diagnostics without launching Ghidra or selecting,+// importing or executing a target.+import { spawnSync } from "node:child_process";+import { mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { dirname, join, relative, resolve } from "node:path";+import { fileURLToPath } from "node:url";+// The pinned Node toolchain strips types from these dependency-free owners;+// this preflight therefore uses runtime facts without needing npm ci or a build.+import { GHIDRA_BRIDGE_SOURCES } from "../src/ghidra/GhidraBridgeSources.ts";+import { parseGhidraJavaProperties } from "../src/ghidra/GhidraJavaProperties.ts";+import {+ SUPPORTED_GHIDRA_VERSION,+ SUPPORTED_GHIDRA_JAVA_MAJOR,+ ghidraReleaseAccepted,+ ghidraReleaseLine,+} from "../src/ghidra/GhidraReleasePolicy.ts";++const args = process.argv.slice(2);+if (+ args.length > 1 ||+ (args.length === 1 &&+ !["--check-sdk-pin", "--verified-sdk"].includes(args[0]))+)+ fail(+ "Usage: verify-ghidra-bridge-sources.mjs [--check-sdk-pin|--verified-sdk]",+ );+if (args[0] === "--check-sdk-pin") {+ let url;+ try {+ url = new URL(process.env.GHIDRA_RELEASE_URL);+ } catch {+ fail("GHIDRA_RELEASE_URL must name the checksum-pinned official release");+ }+ const prefix = `/NationalSecurityAgency/ghidra/releases/download/Ghidra_${SUPPORTED_GHIDRA_VERSION}_build/ghidra_${SUPPORTED_GHIDRA_VERSION}_PUBLIC_`;+ if (+ url.origin !== "https://github.com" ||+ url.username ||+ url.password ||+ url.search ||+ url.hash ||+ !url.pathname.startsWith(prefix) ||+ !url.pathname.endsWith(".zip") ||+ !/^[a-f0-9]{64}$/iu.test(process.env.GHIDRA_RELEASE_SHA256 ?? "")+ )+ fail(+ `SDK URL and SHA256 must match verified Ghidra ${SUPPORTED_GHIDRA_VERSION}`,+ );+ console.log(`GHIDRA_JAVA_MAJOR=${SUPPORTED_GHIDRA_JAVA_MAJOR}`);+ process.exit(0);+}++const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");+const bridge = join(root, "bridge/ghidra");+const install = process.env.GHIDRA_INSTALL_DIR;+if (!install)+ fail(+ `Set GHIDRA_INSTALL_DIR to an existing Ghidra ${ghidraReleaseLine()} installation (verified with ${SUPPORTED_GHIDRA_VERSION}). REA does not install Ghidra.`,+ );+const properties = await readFile(+ join(install, "Ghidra/application.properties"),+ "latin1",+).catch((cause) =>+ fail(+ `GHIDRA_INSTALL_DIR has no readable Ghidra/application.properties: ${cause.message}`,+ ),+);+const parsedProperties = parseGhidraJavaProperties(properties);+if (!parsedProperties.ok) fail(parsedProperties.error);+const version = parsedProperties.value.get("application.version");+if (!ghidraReleaseAccepted(version))+ fail(+ `Bridge sources require Ghidra ${ghidraReleaseLine()} (verified with ${SUPPORTED_GHIDRA_VERSION}). Observed application.version=${version === undefined ? "missing" : JSON.stringify(version)}.`,+ );+if (args[0] === "--verified-sdk" && version !== SUPPORTED_GHIDRA_VERSION)+ fail(+ `CI SDK must be verified Ghidra ${SUPPORTED_GHIDRA_VERSION}; observed ${JSON.stringify(version)}`,+ );+const sourceNames = (await readdir(bridge, { withFileTypes: true }))+ .filter((entry) => entry.isFile() && entry.name.endsWith(".java"))+ .map((entry) => entry.name);+for (const name of Object.values(GHIDRA_BRIDGE_SOURCES))+ if (!sourceNames.includes(name))+ fail(`Required Ghidra bridge source is missing: bridge/ghidra/${name}`);+const requiredNames = new Set(Object.values(GHIDRA_BRIDGE_SOURCES));+const unregistered = sourceNames.filter((name) => !requiredNames.has(name));+if (unregistered.length)+ fail(+ `Ghidra bridge sources absent from the manifest: ${unregistered.join(", ")}`,+ );+const sources = sourceNames+ .map((name) => relative(root, join(bridge, name)))+ .sort();++const javac = process.env.JAVA_HOME+ ? join(process.env.JAVA_HOME, "bin", "javac")+ : "javac";+const banner = run(javac, ["-version"]);+if (banner.error || banner.status !== 0)+ fail(`javac is unavailable: ${banner.error?.message ?? output(banner)}`);+const major = Number(/^javac (\d+)/mu.exec(output(banner))?.[1]);+if (!Number.isInteger(major) || major < SUPPORTED_GHIDRA_JAVA_MAJOR)+ fail(+ `Ghidra ${ghidraReleaseLine()} compiles bridge scripts with Java ${SUPPORTED_GHIDRA_JAVA_MAJOR} or newer. Observed: ${output(banner) || "no version"}. REA does not install or upgrade Java.`,+ );++const jars = (+ await readdir(join(install, "Ghidra"), {+ recursive: true,+ withFileTypes: true,+ })+)+ .filter((entry) => entry.isFile() && entry.name.endsWith(".jar"))+ .map((entry) => join(entry.parentPath, entry.name))+ .sort();+if (jars.length === 0) fail(`No jars found under ${join(install, "Ghidra")}.`);++const scratch = await mkdtemp(join(tmpdir(), "rea-ghidra-bridge-"));+try {+ // An argument file keeps the jar class path below Windows' command length.+ const argumentFile = join(scratch, "javac.args");+ await writeFile(+ argumentFile,+ [+ "-proc:none",+ "-encoding",+ "UTF-8",+ "--release",+ String(SUPPORTED_GHIDRA_JAVA_MAJOR),+ "-cp",+ jars.join(process.platform === "win32" ? ";" : ":"),+ "-d",+ join(scratch, "classes"),+ ...sources,+ ]+ .map((s) => `"${s.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`)+ .join("\n"),+ );+ // Sources are repository-relative, so diagnostics name bridge/ghidra/<file>:<line>.+ const result = run(javac, ["-J-Xmx1g", `@${argumentFile}`]);+ if (result.error || result.status !== 0) {+ // Set the status instead of exiting so the scratch directory is removed.+ process.stderr.write(+ `${output(result) || result.error?.message || "javac failed"}\nGhidra ${version} could not compile the packaged bridge sources; the provider would fail at session start.\n`,+ );+ process.exitCode = 1;+ } else {+ console.log(+ JSON.stringify({+ ghidra_version: version,+ javac: output(banner),+ class_path_jars: jars.length,+ sources,+ }),+ );+ }+} finally {+ await rm(scratch, { recursive: true, force: true });+}++function run(command, args) {+ return spawnSync(command, args, {+ cwd: root,+ encoding: "utf8",+ timeout: 300_000,+ maxBuffer: 16 * 1024 * 1024,+ });+}++function output(result) {+ return `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();+}++function fail(message) {+ process.stderr.write(`${message}\n`);+ process.exit(1);+}diff --git a/scripts/verify-packed-bridge.mjs b/scripts/verify-packed-bridge.mjsindex b83dc7715..19f61cae6 100644--- a/scripts/verify-packed-bridge.mjs+++ b/scripts/verify-packed-bridge.mjs@@ -1,21 +1,20 @@import { execFile } from "node:child_process";import { join } from "node:path";import { promisify } from "node:util";+import { GHIDRA_BRIDGE_SOURCES } from "../src/ghidra/GhidraBridgeSources.ts";const exec = promisify(execFile);const packedHopperBridge = "package/bridge/hopper_bridge.py";const packedCutterBridge = "package/bridge/cutter/rea_bridge.py";-const packedGhidraBridge = "package/bridge/ghidra/ReaGhidraBridge.java";-const packedGhidraActivator =- "package/bridge/ghidra/ReaGhidraBundleActivator.java";/** Check shipped bridge files; real-provider lanes verify runtime behavior. */export async function verifyPackedBridge({ workspace, tarball, packedFiles }) {for (const path of [packedHopperBridge,packedCutterBridge,- packedGhidraBridge,- packedGhidraActivator,+ ...Object.values(GHIDRA_BRIDGE_SOURCES).map(+ (name) => `package/bridge/ghidra/${name}`,+ ),]) {if (!packedFiles.includes(path)) throw new Error(`package omitted ${path}`);}diff --git a/scripts/verify-real-ghidra-assertions.mjs b/scripts/verify-real-ghidra-assertions.mjsindex a6db80e3f..ae9dbbbbc 100644--- a/scripts/verify-real-ghidra-assertions.mjs+++ b/scripts/verify-real-ghidra-assertions.mjs@@ -3,7 +3,7 @@ import { hasTypedSwitchEvidence } from "./verify-real-ghidra-switch-assertions.mimport { access } from "node:fs/promises";import { parseBinaryTarget } from "../dist/application/BinaryTargetResolver.js";-import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraInstallationPolicy.js";+import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraReleasePolicy.js";import { GHIDRA_SESSION_CAPABILITIES } from "../dist/ghidra/GhidraSessionValues.js";export function assertLocalProcedureInfo(info, expectedAddress) {diff --git a/scripts/verify-real-ghidra-noreturn.mjs b/scripts/verify-real-ghidra-noreturn.mjsindex 95b70722e..884bcadd9 100644--- a/scripts/verify-real-ghidra-noreturn.mjs+++ b/scripts/verify-real-ghidra-noreturn.mjs@@ -11,7 +11,7 @@ import { parseBinaryTarget } from "../dist/application/BinaryTargetResolver.js";import { parseConfig } from "../dist/config/parseConfig.js";import { GhidraClient } from "../dist/ghidra/GhidraClient.js";import { inspectGhidraInstallation } from "../dist/ghidra/GhidraInstallation.js";-import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraInstallationPolicy.js";+import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraReleasePolicy.js";import { GhidraProvider } from "../dist/ghidra/GhidraProvider.js";import { silentLogger } from "../dist/logger.js";import { cleanupOwnedProcessGroup } from "../dist/process/ProcessOwnership.js";diff --git a/scripts/verify-real-ghidra-windows.mjs b/scripts/verify-real-ghidra-windows.mjsindex 00b4cec16..c3aa8fdd1 100644--- a/scripts/verify-real-ghidra-windows.mjs+++ b/scripts/verify-real-ghidra-windows.mjs@@ -19,7 +19,7 @@ import {parseGhidraInventoryResult,} from "../dist/ghidra/GhidraInventoryValues.js";import { inspectGhidraInstallation } from "../dist/ghidra/GhidraInstallation.js";-import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraInstallationPolicy.js";+import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraReleasePolicy.js";import { GhidraHeadlessLauncher } from "../dist/ghidra/GhidraLauncher.js";import { GHIDRA_PROVIDER_IDENTITY } from "../dist/ghidra/GhidraProviderCapabilities.js";import {diff --git a/scripts/verify-real-ghidra.mjs b/scripts/verify-real-ghidra.mjsindex 8eec5ef03..291185164 100644--- a/scripts/verify-real-ghidra.mjs+++ b/scripts/verify-real-ghidra.mjs@@ -11,7 +11,7 @@ import { parseBinaryTarget } from "../dist/application/BinaryTargetResolver.js";import { resolveGhidraAnalysisProfile } from "../dist/ghidra/GhidraAnalysisProfile.js";import { GhidraClient } from "../dist/ghidra/GhidraClient.js";import { inspectGhidraInstallation } from "../dist/ghidra/GhidraInstallation.js";-import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraInstallationPolicy.js";+import { SUPPORTED_GHIDRA_VERSION } from "../dist/ghidra/GhidraReleasePolicy.js";import { GhidraHeadlessLauncher } from "../dist/ghidra/GhidraLauncher.js";import { GHIDRA_PROVIDER_IDENTITY } from "../dist/ghidra/GhidraProviderCapabilities.js";diff --git a/scripts/verify-windows-package.mjs b/scripts/verify-windows-package.mjsindex fb7a20986..c546ec04d 100644--- a/scripts/verify-windows-package.mjs+++ b/scripts/verify-windows-package.mjs@@ -14,6 +14,7 @@ import { join } from "node:path";import { parse as parseJsonc } from "jsonc-parser";import { supportedClients } from "../dist/application/SupportedClients.js";import { promisify } from "node:util";+import { GHIDRA_BRIDGE_SOURCES } from "../src/ghidra/GhidraBridgeSources.ts";import { Client } from "@modelcontextprotocol/client";import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";@@ -52,7 +53,9 @@ try {);const packagedPaths = new Set(packageResult.files.map(({ path }) => path));for (const required of [- "bridge/ghidra/ReaGhidraBridge.java",+ ...Object.values(GHIDRA_BRIDGE_SOURCES).map(+ (name) => `bridge/ghidra/${name}`,+ ),"native/windows/build/manifest.json","native/windows/build/rea-windows-x64.node","dist/android/JadxWorkspaceRoot.js",diff --git a/src/ghidra/GhidraAnalysisSeeds.ts b/src/ghidra/GhidraAnalysisSeeds.tsindex 7b5ca46d5..e6621c459 100644--- a/src/ghidra/GhidraAnalysisSeeds.ts+++ b/src/ghidra/GhidraAnalysisSeeds.ts@@ -11,7 +11,6 @@ import { err, ok, type Result } from "../domain/result.js";/** Seed file format admitted by this adapter. */export const GHIDRA_SEED_FORMAT = "rea-ghidra-seeds-v1";-export const GHIDRA_SEED_SCRIPT = "ReaGhidraApplySeeds.java";export const MAX_GHIDRA_SEED_BYTES = 32 * 1024 * 1024;export const MAX_GHIDRA_SEED_ENTRIES = 1_000_000;const MAX_SEED_NAME_LENGTH = 2000;diff --git a/src/ghidra/GhidraBridgeSources.ts b/src/ghidra/GhidraBridgeSources.tsnew file mode 100644index 000000000..acb8bf7d7--- /dev/null+++ b/src/ghidra/GhidraBridgeSources.ts@@ -0,0 +1,12 @@+/** Required packaged sources, selected by their runtime role rather than order. */+export const GHIDRA_BRIDGE_SOURCES = Object.freeze({+ bridge: "ReaGhidraBridge.java",+ bundleActivator: "ReaGhidraBundleActivator.java",+ extensions: "ReaGhidraExtensions.java",+ prepareCom: "ReaGhidraPrepareCom.java",+ prepareRaw: "ReaGhidraPrepareRaw.java",+ applySeeds: "ReaGhidraApplySeeds.java",+ analysisOptions: "ReaGhidraAnalysisOptions.java",+ noReturnFix: "ReaGhidraNoReturnFix.java",+ mipsSoftFloat: "ReaGhidraMipsSoftFloat.java",+} as const);diff --git a/src/ghidra/GhidraInstallation.test.ts b/src/ghidra/GhidraInstallation.test.tsindex a60e7b4b1..89d1068a7 100644--- a/src/ghidra/GhidraInstallation.test.ts+++ b/src/ghidra/GhidraInstallation.test.ts@@ -15,11 +15,13 @@ import {type GhidraJavaObservation,} from "./GhidraInstallation.js";import {- SUPPORTED_GHIDRA_JAVA_MAJOR,- SUPPORTED_GHIDRA_VERSION,ghidraApplicationProperties,ghidraJavaRequirement,} from "./GhidraInstallationPolicy.js";+import {+ SUPPORTED_GHIDRA_JAVA_MAJOR,+ SUPPORTED_GHIDRA_VERSION,+} from "./GhidraReleasePolicy.js";import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";// The real Java probe shells out via spawnSync; stub it so one test can rundiff --git a/src/ghidra/GhidraInstallation.ts b/src/ghidra/GhidraInstallation.tsindex 6a77ee1af..a7216a223 100644--- a/src/ghidra/GhidraInstallation.ts+++ b/src/ghidra/GhidraInstallation.ts@@ -28,14 +28,16 @@ import {ghidraJavaMajorAccepted,ghidraJavaRangeLabel,ghidraJavaRequirement,+ type GhidraApplicationProperties,+ type GhidraJavaRequirement,+} from "./GhidraInstallationPolicy.js";+import {ghidraReleaseAccepted,ghidraReleaseCompatibility,ghidraReleaseLine,ghidraVersionDetail,SUPPORTED_GHIDRA_VERSION,- type GhidraApplicationProperties,- type GhidraJavaRequirement,-} from "./GhidraInstallationPolicy.js";+} from "./GhidraReleasePolicy.js";const NATIVE_PLATFORMS: Readonly<Partial<diff --git a/src/ghidra/GhidraInstallationPolicy.ts b/src/ghidra/GhidraInstallationPolicy.tsindex 8a35c66c3..cf6e897e9 100644--- a/src/ghidra/GhidraInstallationPolicy.ts+++ b/src/ghidra/GhidraInstallationPolicy.ts@@ -1,36 +1,5 @@import { parseGhidraJavaProperties } from "./GhidraJavaProperties.js";-/** Ghidra build whose bridge behavior this REA release verifies. */-export const SUPPORTED_GHIDRA_VERSION = "12.1.4";-/** Verified JDK major; admission uses the installation's declared bounds. */-export const SUPPORTED_GHIDRA_JAVA_MAJOR = 21;--/** Numeric Ghidra release read from `application.version`. */-interface GhidraReleaseVersion {- readonly major: number;- readonly minor: number;- readonly patch: number;-}--/** How an observed Ghidra release relates to this adapter's bridge. */-type GhidraReleaseCompatibility =- | {- readonly status: "verified";- readonly version: GhidraReleaseVersion;- readonly raw: string;- }- | {- readonly status: "compatible";- readonly version: GhidraReleaseVersion;- readonly raw: string;- }- | {- readonly status: "unsupported";- readonly version: GhidraReleaseVersion;- readonly raw: string;- }- | { readonly status: "unresolved"; readonly raw: string | null };-/** One Java major bound declared by `application.properties`. */type GhidraJavaBound =| { readonly status: "absent" }@@ -55,8 +24,6 @@ export interface GhidraApplicationProperties {readonly parseError: string | null;}-const GHIDRA_RELEASE_PATTERN = /^(\d+)\.(\d+)(?:\.(\d+))?([-+].*)?$/u;-/** Read the version and Java bounds Ghidra publishes for one installation. */export const ghidraApplicationProperties = (content: string,@@ -82,67 +49,6 @@ export const ghidraApplicationProperties = (};};-/** Classify `application.version` against the verified release line. */-export const ghidraReleaseCompatibility = (- raw: string | null | undefined,-): GhidraReleaseCompatibility => {- if (raw === null || raw === undefined)- return { status: "unresolved", raw: null };- const version = parseGhidraRelease(raw);- if (version === undefined) return { status: "unresolved", raw };- if (raw === SUPPORTED_GHIDRA_VERSION)- return { status: "verified", version, raw };- const verified = verifiedGhidraRelease();- return version.major === verified.major && version.minor === verified.minor- ? { status: "compatible", version, raw }- : { status: "unsupported", version, raw };-};--/**- * Limitation recorded when a session runs a compatible build other than the- * verified release. The observed version stays on the provider identity.- */-export const unverifiedGhidraBuildLimitation = (- providerVersion: string,-): string | undefined => {- const compatibility = ghidraReleaseCompatibility(providerVersion);- if (compatibility.status !== "compatible") return undefined;- return `This session uses Ghidra ${providerVersion}. The bridge is verified against ${SUPPORTED_GHIDRA_VERSION}; other ${ghidraReleaseLine()} builds are accepted and the observed version is reported.`;-};--/** Release line accepted by this bridge, such as `12.1.x`. */-export const ghidraReleaseLine = (): string => {- const verified = verifiedGhidraRelease();- return `${String(verified.major)}.${String(verified.minor)}.x`;-};--/** Detail for the installation version check, including the accepted line. */-export const ghidraVersionDetail = (raw: string | null | undefined): string => {- const compatibility = ghidraReleaseCompatibility(raw);- switch (compatibility.status) {- case "unresolved":- return compatibility.raw ?? "unknown";- case "verified":- return compatibility.raw;- case "compatible":- return `${compatibility.raw}; compatible ${ghidraReleaseLine()} release (verified build ${SUPPORTED_GHIDRA_VERSION})`;- case "unsupported":- return `${compatibility.raw}; accepted releases are ${ghidraReleaseLine()} (verified build ${SUPPORTED_GHIDRA_VERSION})`;- default: {- const unreachable: never = compatibility;- return unreachable;- }- }-};--/** Whether this release line can run the packaged bridge. */-export const ghidraReleaseAccepted = (- raw: string | null | undefined,-): boolean => {- const status = ghidraReleaseCompatibility(raw).status;- return status === "verified" || status === "compatible";-};-/** Resolve JDK majors from `application.java.min` and `application.java.max`. */export const ghidraJavaRequirement = (properties: GhidraApplicationProperties | undefined,@@ -192,25 +98,6 @@ export const ghidraJavaMajorAccepted = (major >= requirement.minimumMajor &&(requirement.maximumMajor === null || major <= requirement.maximumMajor);-const verifiedGhidraRelease = (): GhidraReleaseVersion => {- const version = parseGhidraRelease(SUPPORTED_GHIDRA_VERSION);- if (version === undefined)- throw new TypeError(- `SUPPORTED_GHIDRA_VERSION ${SUPPORTED_GHIDRA_VERSION} is not a Ghidra release`,- );- return version;-};--const parseGhidraRelease = (raw: string): GhidraReleaseVersion | undefined => {- const match = GHIDRA_RELEASE_PATTERN.exec(raw);- const major = integerGroup(match?.[1]);- const minor = integerGroup(match?.[2]);- if (match === null || major === undefined || minor === undefined)- return undefined;- const patch = match[3] === undefined ? 0 : integerGroup(match[3]);- return patch === undefined ? undefined : { major, minor, patch };-};-const parseJavaBound = (raw: string): GhidraJavaBound => {const major = parseJavaInteger(raw);return major === undefined@@ -261,16 +148,8 @@ const javaDecimalDigit = (character: string): number | undefined => {return (code - blockStart) % 10;};-const integerGroup = (value: string | undefined): number | undefined => {- if (value === undefined) return undefined;- const parsed = Number(value);- return Number.isSafeInteger(parsed) ? parsed : undefined;-};-const unresolvedJavaRequirement = (unresolved: string,): GhidraJavaRequirement => ({unresolved,});--/** Parse Java Properties.load(InputStream) syntax from its ISO-8859-1 text. */diff --git a/src/ghidra/GhidraJavaProperties.ts b/src/ghidra/GhidraJavaProperties.tsindex ab3b7bead..d41b446bd 100644--- a/src/ghidra/GhidraJavaProperties.ts+++ b/src/ghidra/GhidraJavaProperties.ts@@ -1,4 +1,4 @@-import { err, ok, type Result } from "../domain/result.js";+import type { Result } from "../domain/result.js";/** Parse Java Properties.load(InputStream) syntax from its ISO-8859-1 text. */export const parseGhidraJavaProperties = (@@ -30,12 +30,12 @@ export const parseGhidraJavaProperties = (if (line[valueStart] === "=" || line[valueStart] === ":") valueStart += 1;while (isPropertyWhitespace(line[valueStart])) valueStart += 1;const key = decodePropertyEscapes(line.slice(start, end));- if (!key.ok) return err(key.error);+ if (!key.ok) return key;const value = decodePropertyEscapes(line.slice(valueStart));- if (!value.ok) return err(value.error);+ if (!value.ok) return value;values.set(key.value, value.value);}- return ok(values);+ return { ok: true, value: values };};const isPropertyWhitespace = (value: string | undefined): boolean =>@@ -98,7 +98,7 @@ const decodePropertyEscapes = (value: string): Result<string, string> => {}const escaped = value[++index];if (escaped === undefined)- return err("Trailing escape in Java properties value");+ return { ok: false, error: "Trailing escape in Java properties value" };if (escaped === "t") result += "\t";else if (escaped === "n") result += "\n";else if (escaped === "r") result += "\r";@@ -106,10 +106,13 @@ const decodePropertyEscapes = (value: string): Result<string, string> => {else if (escaped === "u") {const digits = value.slice(index + 1, index + 5);if (digits.length !== 4 || !/^[0-9a-f]{4}$/iu.test(digits))- return err("Malformed Unicode escape in Java properties file");+ return {+ ok: false,+ error: "Malformed Unicode escape in Java properties file",+ };result += String.fromCharCode(Number.parseInt(digits, 16));index += 4;} else result += escaped;}- return ok(result);+ return { ok: true, value: result };};diff --git a/src/ghidra/GhidraLauncher.ts b/src/ghidra/GhidraLauncher.tsindex 21990183b..c64ba1a7e 100644--- a/src/ghidra/GhidraLauncher.ts+++ b/src/ghidra/GhidraLauncher.ts@@ -1,6 +1,6 @@import { parseGhidraJavaProperties } from "./GhidraJavaProperties.js";+import { GHIDRA_BRIDGE_SOURCES } from "./GhidraBridgeSources.js";import {- GHIDRA_SEED_SCRIPT,snapshotGhidraAnalysisSeeds,type GhidraSeedCommitment,} from "./GhidraAnalysisSeeds.js";@@ -668,14 +668,14 @@ export const ghidraHeadlessArguments = (...(options.dosCom === true? ["-preScript",- scriptPath.join(bridgeDirectory, "ReaGhidraPrepareCom.java"),+ scriptPath.join(bridgeDirectory, GHIDRA_BRIDGE_SOURCES.prepareCom),]: []),...(rawBinary === undefined? []: ["-preScript",- scriptPath.join(bridgeDirectory, "ReaGhidraPrepareRaw.java"),+ scriptPath.join(bridgeDirectory, GHIDRA_BRIDGE_SOURCES.prepareRaw),rawBinary.languageId,rawBinary.baseAddr,]),@@ -684,7 +684,7 @@ export const ghidraHeadlessArguments = (? []: ["-preScript",- scriptPath.join(bridgeDirectory, GHIDRA_SEED_SCRIPT),+ scriptPath.join(bridgeDirectory, GHIDRA_BRIDGE_SOURCES.applySeeds),options.seedPath,]),// Analyzer options must apply before default auto-analysis and before the@@ -694,20 +694,23 @@ export const ghidraHeadlessArguments = (? []: ["-preScript",- scriptPath.join(bridgeDirectory, "ReaGhidraAnalysisOptions.java"),+ scriptPath.join(+ bridgeDirectory,+ GHIDRA_BRIDGE_SOURCES.analysisOptions,+ ),options.disabledAnalyzers.join(","),]),...((options.platform ?? process.platform) === "win32"? []: ["-postScript",- scriptPath.join(bridgeDirectory, "ReaGhidraNoReturnFix.java"),+ scriptPath.join(bridgeDirectory, GHIDRA_BRIDGE_SOURCES.noReturnFix),]),// After analysis and the no-return refit, before the bridge serves results....(options.mipsSoftFloat === true? ["-postScript",- scriptPath.join(bridgeDirectory, "ReaGhidraMipsSoftFloat.java"),+ scriptPath.join(bridgeDirectory, GHIDRA_BRIDGE_SOURCES.mipsSoftFloat),]: []),"-postScript",diff --git a/src/ghidra/GhidraProviderClient.ts b/src/ghidra/GhidraProviderClient.tsindex 08b564a3d..a57e23386 100644--- a/src/ghidra/GhidraProviderClient.ts+++ b/src/ghidra/GhidraProviderClient.ts@@ -1,5 +1,6 @@import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";import { fileURLToPath } from "node:url";+import { GHIDRA_BRIDGE_SOURCES } from "./GhidraBridgeSources.js";import {createAnalysisExecution,@@ -74,7 +75,7 @@ import {} from "./GhidraMipsProfile.js";import { ghidraRiscvLimitations } from "./GhidraRiscvProfile.js";import { ghidraPePdbLimitations } from "./GhidraPeProfile.js";-import { unverifiedGhidraBuildLimitation } from "./GhidraInstallationPolicy.js";+import { unverifiedGhidraBuildLimitation } from "./GhidraReleasePolicy.js";import { GhidraHeadlessLauncher } from "./GhidraLauncher.js";import { attestGhidraNativeLoadImage } from "./GhidraLoadImageAttest.js";import {@@ -584,7 +585,10 @@ export const createGhidraProviderClient = (input: {? {}: { javaVmName: installation.javaVmName }),bridgeScriptPath: fileURLToPath(- new URL("../../bridge/ghidra/ReaGhidraBridge.java", import.meta.url),+ new URL(+ `../../bridge/ghidra/${GHIDRA_BRIDGE_SOURCES.bridge}`,+ import.meta.url,+ ),),...(pspExtension?.success === true? { pspExtension: pspExtension.data }diff --git a/src/ghidra/GhidraReleasePolicy.ts b/src/ghidra/GhidraReleasePolicy.tsnew file mode 100644index 000000000..bc52e9d59--- /dev/null+++ b/src/ghidra/GhidraReleasePolicy.ts@@ -0,0 +1,118 @@+/** Ghidra build whose bridge behavior this REA release verifies. */+export const SUPPORTED_GHIDRA_VERSION = "12.1.4";+/** Verified JDK major; admission uses the installation's declared bounds. */+export const SUPPORTED_GHIDRA_JAVA_MAJOR = 21;++/** Numeric Ghidra release read from `application.version`. */+interface GhidraReleaseVersion {+ readonly major: number;+ readonly minor: number;+ readonly patch: number;+}++/** How an observed Ghidra release relates to this adapter's bridge. */+type GhidraReleaseCompatibility =+ | {+ readonly status: "verified";+ readonly version: GhidraReleaseVersion;+ readonly raw: string;+ }+ | {+ readonly status: "compatible";+ readonly version: GhidraReleaseVersion;+ readonly raw: string;+ }+ | {+ readonly status: "unsupported";+ readonly version: GhidraReleaseVersion;+ readonly raw: string;+ }+ | { readonly status: "unresolved"; readonly raw: string | null };++const GHIDRA_RELEASE_PATTERN = /^(\d+)\.(\d+)(?:\.(\d+))?([-+].*)?$/u;++/** Classify `application.version` against the verified release line. */+export const ghidraReleaseCompatibility = (+ raw: string | null | undefined,+): GhidraReleaseCompatibility => {+ if (raw === null || raw === undefined)+ return { status: "unresolved", raw: null };+ const version = parseGhidraRelease(raw);+ if (version === undefined) return { status: "unresolved", raw };+ if (raw === SUPPORTED_GHIDRA_VERSION)+ return { status: "verified", version, raw };+ const verified = verifiedGhidraRelease();+ return version.major === verified.major && version.minor === verified.minor+ ? { status: "compatible", version, raw }+ : { status: "unsupported", version, raw };+};++/**+ * Limitation recorded when a session runs a compatible build other than the+ * verified release. The observed version stays on the provider identity.+ */+export const unverifiedGhidraBuildLimitation = (+ providerVersion: string,+): string | undefined => {+ const compatibility = ghidraReleaseCompatibility(providerVersion);+ if (compatibility.status !== "compatible") return undefined;+ return `This session uses Ghidra ${providerVersion}. The bridge is verified against ${SUPPORTED_GHIDRA_VERSION}; other ${ghidraReleaseLine()} builds are accepted and the observed version is reported.`;+};++/** Release line accepted by this bridge, such as `12.1.x`. */+export const ghidraReleaseLine = (): string => {+ const verified = verifiedGhidraRelease();+ return `${String(verified.major)}.${String(verified.minor)}.x`;+};++/** Detail for the installation version check, including the accepted line. */+export const ghidraVersionDetail = (raw: string | null | undefined): string => {+ const compatibility = ghidraReleaseCompatibility(raw);+ switch (compatibility.status) {+ case "unresolved":+ return compatibility.raw ?? "unknown";+ case "verified":+ return compatibility.raw;+ case "compatible":+ return `${compatibility.raw}; compatible ${ghidraReleaseLine()} release (verified build ${SUPPORTED_GHIDRA_VERSION})`;+ case "unsupported":+ return `${compatibility.raw}; accepted releases are ${ghidraReleaseLine()} (verified build ${SUPPORTED_GHIDRA_VERSION})`;+ default: {+ const unreachable: never = compatibility;+ return unreachable;+ }+ }+};++/** Whether this release line can run the packaged bridge. */+export const ghidraReleaseAccepted = (+ raw: string | null | undefined,+): boolean => {+ const status = ghidraReleaseCompatibility(raw).status;+ return status === "verified" || status === "compatible";+};++const verifiedGhidraRelease = (): GhidraReleaseVersion => {+ const version = parseGhidraRelease(SUPPORTED_GHIDRA_VERSION);+ if (version === undefined)+ throw new TypeError(+ `SUPPORTED_GHIDRA_VERSION ${SUPPORTED_GHIDRA_VERSION} is not a Ghidra release`,+ );+ return version;+};++const parseGhidraRelease = (raw: string): GhidraReleaseVersion | undefined => {+ const match = GHIDRA_RELEASE_PATTERN.exec(raw);+ const major = integerGroup(match?.[1]);+ const minor = integerGroup(match?.[2]);+ if (match === null || major === undefined || minor === undefined)+ return undefined;+ const patch = match[3] === undefined ? 0 : integerGroup(match[3]);+ return patch === undefined ? undefined : { major, minor, patch };+};++const integerGroup = (value: string | undefined): number | undefined => {+ if (value === undefined) return undefined;+ const parsed = Number(value);+ return Number.isSafeInteger(parsed) ? parsed : undefined;+};diff --git a/tests/boundary/filesystem/ciChangeScope.test.ts b/tests/boundary/filesystem/ciChangeScope.test.tsindex e56c894ba..495d60b9d 100644--- a/tests/boundary/filesystem/ciChangeScope.test.ts+++ b/tests/boundary/filesystem/ciChangeScope.test.ts@@ -652,9 +652,35 @@ it.each([browser: false,},],+ [+ "scripts/verify-ghidra-bridge-sources.mjs",+ { code: true, ghidra_bridge: true, runtime: false, package: false },+ ],+ [+ "src/ghidra/GhidraBridgeSources.ts",+ { code: true, ghidra_bridge: true, runtime: true, package: true },+ ],+ [+ "src/ghidra/GhidraJavaProperties.ts",+ { code: true, ghidra_bridge: true, runtime: true, package: false },+ ],+ [+ "src/ghidra/GhidraReleasePolicy.ts",+ { code: true, ghidra_bridge: true, runtime: true },+ ],+ [+ ".github/workflows/ghidra-bridge-sources.yml",+ { code: false, ghidra_bridge: true, runtime: false, package: false },+ ],["bridge/ghidra/Example.java",- { code: true, runtime: true, package: false, apple: false },+ {+ code: true,+ runtime: true,+ ghidra_bridge: true,+ package: false,+ apple: false,+ },],["src/native/AppleExample.ts",@@ -732,7 +758,10 @@ it.each(["src/domain/analysisErrorProjection.ts",{ code: true, sqlite: true, runtime: true },],- ["src/domain/javascript/example.ts", { code: true, sqlite: false }],+ [+ "src/domain/javascript/example.ts",+ { code: true, sqlite: false, ghidra_bridge: false },+ ],])("selects the appropriate lanes for %s", async (path, expected) => {const { directory, base } = await fixture();const head = await change(directory, [path]);@@ -831,6 +860,7 @@ it.each([["web_runtime", "real-web-runtime"],["web_source_map", "real-web-source-map"],["nativeaot", "nativeaot-fixtures"],+ ["ghidra_bridge", "ghidra-bridge-sources"],["website", "website-check"],])("routes %s through the selector without a duplicate PR trigger",diff --git a/tests/boundary/filesystem/ciRequiredLanes.test.ts b/tests/boundary/filesystem/ciRequiredLanes.test.tsindex d2191eb01..0bfd64a02 100644--- a/tests/boundary/filesystem/ciRequiredLanes.test.ts+++ b/tests/boundary/filesystem/ciRequiredLanes.test.ts@@ -403,6 +403,7 @@ it.each([for (const [scope, lane] of [["sqlite", "sqlite-runtime"],["workflows", "static"],+ ["ghidra_bridge", "ghidra_bridge"],] as const) {// GitHub exposes only direct dependencies in the required job's needs context.const needs: Record<diff --git a/tests/boundary/filesystem/ghidraBridgeSources.test.ts b/tests/boundary/filesystem/ghidraBridgeSources.test.tsnew file mode 100644index 000000000..baf584fba--- /dev/null+++ b/tests/boundary/filesystem/ghidraBridgeSources.test.ts@@ -0,0 +1,290 @@+import { execFile } from "node:child_process";+import {+ chmod,+ copyFile,+ cp,+ mkdir,+ readFile,+ readdir,+ rename,+ unlink,+ writeFile,+} from "node:fs/promises";+import { join, resolve } from "node:path";+import { promisify } from "node:util";+import { expect, it } from "vitest";+import { parse as parseYaml } from "yaml";+import { z } from "zod";++import { GHIDRA_BRIDGE_SOURCES } from "../../../src/ghidra/GhidraBridgeSources.js";+import {+ SUPPORTED_GHIDRA_JAVA_MAJOR,+ SUPPORTED_GHIDRA_VERSION,+} from "../../../src/ghidra/GhidraReleasePolicy.js";+import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";++const execute = promisify(execFile);++/** A stand-in compiler proves admission and cleanup, not real Java compilation. */+const installation = async (+ properties = "application.version=12.1.4\n",+ compilerStatus = 0,+) => {+ const root = await createTestTempDirectory("rea-ghidra-bridge-test-");+ const install = join(root, "Ghidra SDK");+ await mkdir(join(install, "Ghidra/Framework/lib"), { recursive: true });+ await writeFile(+ join(install, "Ghidra/application.properties"),+ properties,+ "latin1",+ );+ await writeFile(join(install, "Ghidra/Framework/lib/Generic.jar"), "");+ const javaHome = join(root, "JDK home");+ await mkdir(join(javaHome, "bin"), { recursive: true });+ const javac = join(javaHome, "bin/javac");+ await writeFile(+ javac,+ [+ "#!/bin/sh",+ 'if [ "$1" = "-version" ]; then echo "javac 21.0.12"; exit 0; fi',+ ...(compilerStatus === 0+ ? ["exit 0"]+ : [+ 'echo "bridge/ghidra/ReaGhidraBridge.java:1: error: cannot find symbol" >&2',+ "exit 1",+ ]),+ ].join("\n"),+ );+ await chmod(javac, 0o755);+ const scratchParent = join(root, "scratch");+ await mkdir(scratchParent);+ return {+ scratchParent,+ environment: {+ ...process.env,+ GHIDRA_INSTALL_DIR: install,+ JAVA_HOME: javaHome,+ TMPDIR: scratchParent,+ },+ };+};++type AdmissionCase = {+ name: string;+ properties: string;+ compilerStatus?: number;+ expectedVersion?: string;+ error?: string;+};+const admissionCases: readonly AdmissionCase[] = [+ { name: "compiler succeeds", properties: "application.version=12.1.4\n" },+ {+ name: "compiler fails",+ properties: "application.version=12.1.4\n",+ compilerStatus: 1,+ error: "bridge/ghidra/ReaGhidraBridge.java:1: error: cannot find symbol",+ },+ { name: "colon separator", properties: "application.version : 12.1.4\n" },+ {+ name: "escaped key and continued value",+ properties: "application\\u002eversion=12.1.\\\n 4\n",+ },+ {+ name: "Latin-1 distro suffix",+ properties: "application.version=12.1.4-é\n",+ expectedVersion: "12.1.4-é",+ },+ {+ name: "trailing version whitespace",+ properties: "application.version=12.1.4 \n",+ error: 'Observed application.version="12.1.4 ".',+ },+ {+ name: "malformed Unicode escape",+ properties: "application.version=12.1.4\nother=\\u00xx\n",+ error: "Malformed Unicode escape in Java properties file",+ },+];++// Only the stand-in executable is POSIX-specific. Real compilation runs in its+// hosted lane; the installed provider's Properties tests cover the parser too.+it.skipIf(process.platform === "win32").each(admissionCases)(+ "preserves version admission and scratch cleanup: $name",+ async ({ properties, compilerStatus, expectedVersion = "12.1.4", error }) => {+ const fixture = await installation(properties, compilerStatus);+ const run = execute(+ process.execPath,+ ["scripts/verify-ghidra-bridge-sources.mjs"],+ {+ cwd: process.cwd(),+ env: fixture.environment,+ timeout: 30_000,+ },+ );+ if (error === undefined)+ await expect(run).resolves.toMatchObject({+ stdout: expect.stringContaining(+ `"ghidra_version":${JSON.stringify(expectedVersion)}`,+ ),+ });+ else+ await expect(run).rejects.toMatchObject({+ code: 1,+ stdout: "",+ stderr: expect.stringContaining(error),+ });+ expect(await readdir(fixture.scratchParent)).toEqual([]);+ },+);++it.skipIf(process.platform === "win32").each([+ { source: GHIDRA_BRIDGE_SOURCES.prepareCom, action: "deleted" },+ { source: GHIDRA_BRIDGE_SOURCES.applySeeds, action: "renamed" },+ { source: "UnregisteredHelper.java", action: "added" },+])(+ "rejects a $action launcher source before compilation: $source",+ async ({ source, action }) => {+ const repository = await createTestTempDirectory("rea-ghidra-source-set-");+ await mkdir(join(repository, "scripts"));+ await mkdir(join(repository, "src/ghidra"), { recursive: true });+ await writeFile(join(repository, "package.json"), '{"type":"module"}\n');+ for (const path of [+ "scripts/verify-ghidra-bridge-sources.mjs",+ "src/ghidra/GhidraBridgeSources.ts",+ "src/ghidra/GhidraJavaProperties.ts",+ "src/ghidra/GhidraReleasePolicy.ts",+ ])+ await copyFile(resolve(path), join(repository, path));+ await cp(resolve("bridge/ghidra"), join(repository, "bridge/ghidra"), {+ recursive: true,+ });+ const path = join(repository, "bridge/ghidra", source);+ if (action === "added")+ await writeFile(path, "class UnregisteredHelper {}\n");+ else if (action === "deleted") await unlink(path);+ else {+ const className = source.slice(0, -".java".length);+ await writeFile(+ path,+ (await readFile(path, "utf8")).replaceAll(+ className,+ `Renamed${className}`,+ ),+ );+ await rename(path, join(repository, "bridge/ghidra", `Renamed${source}`));+ }+ const fixture = await installation();+ await expect(+ execute(+ process.execPath,+ [join(repository, "scripts/verify-ghidra-bridge-sources.mjs")],+ {+ cwd: repository,+ env: fixture.environment,+ timeout: 30_000,+ },+ ),+ ).rejects.toMatchObject({+ code: 1,+ stderr: expect.stringContaining(+ action === "added"+ ? `Ghidra bridge sources absent from the manifest: ${source}`+ : `Required Ghidra bridge source is missing: bridge/ghidra/${source}`,+ ),+ });+ expect(await readdir(fixture.scratchParent)).toEqual([]);+ },+);++it("rejects an omitted auxiliary source at the actual package verification boundary", async () => {+ const source = GHIDRA_BRIDGE_SOURCES.prepareCom;+ const packedFiles = [+ "package/bridge/hopper_bridge.py",+ "package/bridge/cutter/rea_bridge.py",+ ...Object.values(GHIDRA_BRIDGE_SOURCES)+ .filter((name) => name !== source)+ .map((name) => `package/bridge/ghidra/${name}`),+ ];+ await expect(+ execute(process.execPath, [+ "--input-type=module",+ "-e",+ `import { verifyPackedBridge } from "./scripts/verify-packed-bridge.mjs";+ await verifyPackedBridge({ workspace: ".", tarball: "unused-because-admission-must-fail", packedFiles: JSON.parse(process.argv[1]) });`,+ JSON.stringify(packedFiles),+ ]),+ ).rejects.toMatchObject({+ code: 1,+ stderr: expect.stringContaining(+ `package omitted package/bridge/ghidra/${source}`,+ ),+ });+});++it("binds the workflow SDK pin and verified compile mode to the canonical release", async () => {+ const { jobs } = z+ .object({+ jobs: z.object({+ "ghidra-bridge-sources": z.object({+ env: z.object({+ GHIDRA_RELEASE_URL: z.string(),+ GHIDRA_RELEASE_SHA256: z.string(),+ }),+ steps: z.array(+ z.object({ run: z.string().optional() }).passthrough(),+ ),+ }),+ }),+ })+ .parse(+ parseYaml(+ await readFile(+ resolve(".github/workflows/ghidra-bridge-sources.yml"),+ "utf8",+ ),+ ),+ );+ const job = jobs["ghidra-bridge-sources"];+ const pinIndex = job.steps.findIndex((step) =>+ step.run?.includes("--check-sdk-pin"),+ );+ const downloadIndex = job.steps.findIndex((step) =>+ step.run?.includes("curl "),+ );+ expect(pinIndex).toBeGreaterThanOrEqual(0);+ expect(downloadIndex).toBeGreaterThan(pinIndex);+ expect(job.steps.some((step) => step.run?.includes("--verified-sdk"))).toBe(+ true,+ );+ const command = [+ "scripts/verify-ghidra-bridge-sources.mjs",+ "--check-sdk-pin",+ ];+ await expect(+ execute(process.execPath, command, {+ env: { ...process.env, ...job.env },+ }),+ ).resolves.toMatchObject({+ stdout: `GHIDRA_JAVA_MAJOR=${SUPPORTED_GHIDRA_JAVA_MAJOR}\n`,+ });+ for (const env of [+ {+ ...job.env,+ GHIDRA_RELEASE_URL: job.env.GHIDRA_RELEASE_URL.replaceAll(+ SUPPORTED_GHIDRA_VERSION,+ "0.0.0",+ ),+ },+ { ...job.env, GHIDRA_RELEASE_SHA256: "not-a-digest" },+ ])+ await expect(+ execute(process.execPath, command, {+ env: { ...process.env, ...env },+ }),+ ).rejects.toMatchObject({+ code: 1,+ stderr: expect.stringContaining(+ "SDK URL and SHA256 must match verified Ghidra",+ ),+ });+});diff --git a/tests/boundary/filesystem/ghidraJavaProbe.test.ts b/tests/boundary/filesystem/ghidraJavaProbe.test.tsindex d48dc1ece..1bdd4a162 100644--- a/tests/boundary/filesystem/ghidraJavaProbe.test.ts+++ b/tests/boundary/filesystem/ghidraJavaProbe.test.ts@@ -6,7 +6,7 @@ import {inspectGhidraInstallation,ghidraInstallationDiagnostics,} from "../../../src/ghidra/GhidraInstallation.js";-import { SUPPORTED_GHIDRA_VERSION } from "../../../src/ghidra/GhidraInstallationPolicy.js";+import { SUPPORTED_GHIDRA_VERSION } from "../../../src/ghidra/GhidraReleasePolicy.js";import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";const { mockSpawnSync } = vi.hoisted(() => ({ mockSpawnSync: vi.fn() }));