mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 06:04:03 +00:00
* feat(ghidra)!: verify the bridge on Ghidra 12.2 Admit 12.x from minor 2 upward, with 12.2 and JDK 25 as the verified pair. The bridge now calls the four-argument storage API added in 12.2, so 12.1.x cannot compile it and is no longer accepted. BREAKING CHANGE: Ghidra 12.1.x is rejected. Use Ghidra 12.2 or another 12.x build at or above minor 2, and a JDK inside that installation's declared range (25 or newer for the verified 12.2 build). * docs(ghidra): point remaining lanes at Ghidra 12.2 The Windows, 6502, and m68k prerequisites still named 12.1.4 and JDK 21, which the verified-build check now rejects. The bridge compile lane names the 12.2 jars it actually compiles against. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(ghidra): admit the JDK the verified install declares The Java home framing probe still reported JDK 21 while the verified installation fixture now declares a minimum of 25, so doctor admission failed before the path framing was checked. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(ghidra): derive admitted install fixtures from the verified release Boundary hosts and assertions still named Ghidra 12.1.4 after admission moved to 12.2, so list_procedures evidence and completed property reads disagreed with the install the provider actually reported. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): record the exact 12.2 Clang switch-recovery defect Ghidra 12.2 stays the verified build. Sessions and decompiler results on that exact version name upstream issue 9996 and the 12.2.1 fix commit. Other version strings, including 12.2.1, do not carry the limitation. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(ghidra): check switch-defect facts instead of the warning sentence The policy test keeps the structured defect record and checks that the owning formatter delivers its id, commit, release, and scope fields. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(browser): name the Playwright launch boundary the lifecycle catalog checks Main retitled that case with a platform placeholder. The coverage catalog still required the old literal, so the merged full suite reported a missing title. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(browser): point the lifecycle catalog at main's launch title The merged suite uses main's platform-specific Playwright launch test. The coverage catalog now names that title, and this branch keeps main's test body so the merge stays clean. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(browser): cover the platform launch title on this branch The lifecycle catalog names main's platform launch title. This branch now has that quoted test too, so the check passes before and after the merge. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): record the exact 12.2 masked byte-switch defect Ghidra 12.2 leaves an AArch64 and-0xff byte-offset switch unrecovered. Exact 12.2 sessions now cite open upstream issue 10154, and the AArch64 lane expects that jump table to stay unrecovered. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(browser): keep one platform launch environment check The second launch test repeated the selected environment check. The remaining test is the parameterized title, and the launcher forwards SYSTEMROOT on win32 so that assertion holds. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): keep the open switch defect on admitted builds The exact-version check cleared ghidra-10154 on every build except 12.2. That defect stays on admitted releases until one is known to fix it. ghidra-9996 still clears after the exact 12.2 build. Co-authored-by: morluto <morluto@users.noreply.github.com> * style(docs): format the Ghidra testing-lane table The AArch64 jump-table row wrapped past the formatter width and failed static checks. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(ghidra): give the masked switch its full byte range The unrecovered oracle now uses 256 readable table bytes, and the same object must still recover its compare-bounded switch. Co-authored-by: morluto <morluto@users.noreply.github.com> * docs(website): point Ghidra setup at 12.2 and JDK 25 The public setup pages still told new users to install Ghidra 12.1.4 and JDK 21, which this release rejects. Changed setup sentences are extracted and left untranslated so those editions use the English page. Co-authored-by: morluto <morluto@users.noreply.github.com> * docs(website): keep catalog edits to the changed setup strings The catalog check compares active message ids, not a full rewrite. Restore the previous catalogs and update only the Ghidra 12.2 setup strings, leaving their translations empty. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): apply the closed switch defect from the parsed patch 12.2, 12.2.0, and 12.2.0 with a suffix all precede 12.2.1, so they keep ghidra-9996. The masked-switch table lists all 256 byte entries. Co-authored-by: morluto <morluto@users.noreply.github.com> * fix(ghidra): share the AArch64 switch fixture compiler invocation --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
314 lines
9.8 KiB
TypeScript
314 lines
9.8 KiB
TypeScript
import { execFile } from "node:child_process";
|
|
import {
|
|
chmod,
|
|
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";
|
|
import { copyScriptsWithImports } from "../../support/scriptImportClosure.js";
|
|
|
|
const execute = promisify(execFile);
|
|
|
|
/** A stand-in compiler proves admission and cleanup, not real Java compilation. */
|
|
const installation = async (
|
|
properties = `application.version=${SUPPORTED_GHIDRA_VERSION}\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",
|
|
'printf "invoked\\n" >> "$REA_JAVAC_MARKER"',
|
|
'if [ "$1" = "-version" ]; then echo "javac 25.0.5"; 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,
|
|
javacMarker: join(root, "javac-invocations"),
|
|
environment: {
|
|
...process.env,
|
|
REA_JAVAC_MARKER: join(root, "javac-invocations"),
|
|
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=${SUPPORTED_GHIDRA_VERSION}\n`,
|
|
expectedVersion: SUPPORTED_GHIDRA_VERSION,
|
|
},
|
|
{
|
|
name: "compiler fails",
|
|
properties: `application.version=${SUPPORTED_GHIDRA_VERSION}\n`,
|
|
compilerStatus: 1,
|
|
error: "bridge/ghidra/ReaGhidraBridge.java:1: error: cannot find symbol",
|
|
},
|
|
{
|
|
name: "colon separator",
|
|
properties: `application.version : ${SUPPORTED_GHIDRA_VERSION}\n`,
|
|
expectedVersion: SUPPORTED_GHIDRA_VERSION,
|
|
},
|
|
{
|
|
name: "escaped key and continued value",
|
|
properties: "application\\u002eversion=12.\\\n 2\n",
|
|
expectedVersion: "12.2",
|
|
},
|
|
{
|
|
name: "Latin-1 distro suffix",
|
|
properties: "application.version=12.2-é\n",
|
|
expectedVersion: "12.2-é",
|
|
},
|
|
{
|
|
name: "trailing version whitespace",
|
|
properties: "application.version=12.2 \n",
|
|
error: 'Observed application.version="12.2 ".',
|
|
},
|
|
{
|
|
name: "malformed Unicode escape",
|
|
properties: "application.version=12.2\nother=\\u00xx\n",
|
|
error: "malformed_unicode_escape",
|
|
},
|
|
];
|
|
|
|
// 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 = SUPPORTED_GHIDRA_VERSION,
|
|
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 writeFile(join(repository, "package.json"), '{"type":"module"}\n');
|
|
await copyScriptsWithImports(
|
|
["scripts/verify-ghidra-bridge-sources.mjs"],
|
|
repository,
|
|
);
|
|
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([]);
|
|
await expect(readFile(fixture.javacMarker)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
},
|
|
);
|
|
|
|
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";
|
|
import { createPackageVerifierCommands } from "./scripts/lib/verify-package-commands.mjs";
|
|
import { withVerifierCleanup } from "./scripts/lib/verifier-cleanup.mjs";
|
|
import { PrivateRuntimeRoot } from "./dist/process/PrivateRuntimeRoot.js";
|
|
const root = await PrivateRuntimeRoot.create({ prefix: "rea-bridge-admission-" });
|
|
let commands;
|
|
await withVerifierCleanup(async () => {
|
|
commands = await createPackageVerifierCommands({ workspace: root });
|
|
await verifyPackedBridge({ tarball: "unused-because-admission-must-fail", packedFiles: JSON.parse(process.argv[1]), commands });
|
|
}, [() => commands === undefined ? root.close() : commands.close()]);`,
|
|
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",
|
|
),
|
|
});
|
|
});
|