mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 21:23:45 +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>
179 lines
5.6 KiB
JavaScript
179 lines
5.6 KiB
JavaScript
#!/usr/bin/env node
|
|
import { spawnSync } from "node:child_process";
|
|
import { createHash } from "node:crypto";
|
|
import {
|
|
mkdir,
|
|
mkdtemp,
|
|
readdir,
|
|
readFile,
|
|
rm,
|
|
writeFile,
|
|
} from "node:fs/promises";
|
|
import { dirname, join, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import {
|
|
SUPPORTED_GHIDRA_JAVA_MAJOR,
|
|
SUPPORTED_GHIDRA_VERSION,
|
|
ghidraReleaseAccepted,
|
|
ghidraReleaseLine,
|
|
} from "../src/ghidra/GhidraReleasePolicy.ts";
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const source = resolve(
|
|
process.env.REA_NATIVEAOT_SOURCE ??
|
|
join(root, "third_party/ghidra-nativeaot"),
|
|
);
|
|
const install = process.env.GHIDRA_INSTALL_DIR;
|
|
if (!install)
|
|
throw new Error(
|
|
`NativeAOT build lane requires existing GHIDRA_INSTALL_DIR (Ghidra ${ghidraReleaseLine()}, verified with ${SUPPORTED_GHIDRA_VERSION}).`,
|
|
);
|
|
const properties = await readFile(
|
|
join(install, "Ghidra/application.properties"),
|
|
"utf8",
|
|
);
|
|
const ghidraVersion = propertyValue(properties, "application.version");
|
|
if (!ghidraReleaseAccepted(ghidraVersion))
|
|
throw new Error(
|
|
`NativeAOT build lane accepts Ghidra ${ghidraReleaseLine()} (verified with ${SUPPORTED_GHIDRA_VERSION}). Observed application.version=${ghidraVersion ?? "missing"}.`,
|
|
);
|
|
const output = resolve(
|
|
process.env.REA_NATIVEAOT_BUILD_ROOT ??
|
|
join(root, "_reference/nativeaot-integration/extension"),
|
|
);
|
|
const java = process.env.JAVA_HOME ? join(process.env.JAVA_HOME, "bin") : null;
|
|
const run = (command, args) => {
|
|
const result = spawnSync(command, args, {
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
timeout: 120_000,
|
|
maxBuffer: 4 * 1024 * 1024,
|
|
});
|
|
if (result.error || result.status !== 0)
|
|
throw new Error(
|
|
`NativeAOT build prerequisite/action ${command} failed: ${result.error?.message ?? ""}\n${result.stdout ?? ""}${result.stderr ?? ""}`,
|
|
);
|
|
return result.stdout.trim();
|
|
};
|
|
const javac = java ? join(java, "javac") : "javac";
|
|
const javacBanner = capture(javac, ["-version"]);
|
|
const javacMajor = Number(/^javac (\d+)/mu.exec(javacBanner)?.[1]);
|
|
if (!Number.isInteger(javacMajor) || javacMajor < SUPPORTED_GHIDRA_JAVA_MAJOR)
|
|
throw new Error(
|
|
`NativeAOT build lane requires javac ${String(SUPPORTED_GHIDRA_JAVA_MAJOR)} or newer and compiles with --release ${String(SUPPORTED_GHIDRA_JAVA_MAJOR)}. Observed: ${javacBanner || "no version"}. REA does not install or upgrade Java.`,
|
|
);
|
|
const revision = run("git", ["-C", source, "rev-parse", "HEAD"]);
|
|
if (
|
|
revision !== "effeb734fc570c32650f88b159608979dc7b423e" ||
|
|
run("git", ["-C", source, "status", "--porcelain"])
|
|
)
|
|
throw new Error(
|
|
"NativeAOT build requires the clean pinned upstream source; initialize third_party/ghidra-nativeaot.",
|
|
);
|
|
const files = async (path, extension) => {
|
|
const result = [];
|
|
for (const entry of await readdir(path, { withFileTypes: true })) {
|
|
const child = join(path, entry.name);
|
|
if (entry.isDirectory()) result.push(...(await files(child, extension)));
|
|
else if (entry.isFile() && child.endsWith(extension)) result.push(child);
|
|
}
|
|
return result.sort();
|
|
};
|
|
await mkdir(output, { recursive: true });
|
|
const classes = await mkdtemp(join(output, "classes-"));
|
|
try {
|
|
const sources = [
|
|
...(await files(join(source, "src/main/java"), ".java")),
|
|
...(await files(join(root, "bridge/nativeaot"), ".java")),
|
|
];
|
|
const jars = await files(join(install, "Ghidra"), ".jar");
|
|
const args = [
|
|
"-proc:none",
|
|
"-cp",
|
|
jars.join(process.platform === "win32" ? ";" : ":"),
|
|
"-d",
|
|
classes,
|
|
...sources,
|
|
];
|
|
await writeFile(
|
|
join(output, "javac.args"),
|
|
args
|
|
.map((s) => `"${s.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`)
|
|
.join("\n"),
|
|
);
|
|
run(javac, [
|
|
"-J-Xmx512m",
|
|
"-J-XX:ActiveProcessorCount=1",
|
|
"--release",
|
|
String(SUPPORTED_GHIDRA_JAVA_MAJOR),
|
|
`@${join(output, "javac.args")}`,
|
|
]);
|
|
await writeFile(
|
|
join(classes, "LICENSE-ghidra-nativeaot.md"),
|
|
await readFile(join(source, "LICENSE.md")),
|
|
);
|
|
const jar = join(output, "rea-ghidra-nativeaot.jar");
|
|
run(java ? join(java, "jar") : "jar", [
|
|
"--create",
|
|
"--file",
|
|
jar,
|
|
"--date=2025-01-01T00:00:00Z",
|
|
"-C",
|
|
classes,
|
|
".",
|
|
]);
|
|
const sha256 = createHash("sha256")
|
|
.update(await readFile(jar))
|
|
.digest("hex");
|
|
await writeFile(
|
|
join(output, "build.json"),
|
|
JSON.stringify(
|
|
{
|
|
jar,
|
|
sha256,
|
|
upstream_revision: revision,
|
|
ghidra_version: ghidraVersion,
|
|
integration_api: 1,
|
|
},
|
|
null,
|
|
2,
|
|
) + "\n",
|
|
);
|
|
console.log(
|
|
JSON.stringify({
|
|
jar,
|
|
sha256,
|
|
upstream_revision: revision,
|
|
ghidra_version: ghidraVersion,
|
|
integration_api: 1,
|
|
}),
|
|
);
|
|
} finally {
|
|
await rm(classes, { recursive: true, force: true });
|
|
}
|
|
|
|
/** Read one application.properties value. Empty and missing values stay unknown. */
|
|
function propertyValue(content, name) {
|
|
for (const line of content.split(/\r?\n/u)) {
|
|
const separator = line.indexOf("=");
|
|
if (separator < 0 || line.slice(0, separator).trim() !== name) continue;
|
|
const value = line.slice(separator + 1).trim();
|
|
return value.length === 0 ? null : value;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function capture(command, args) {
|
|
const result = spawnSync(command, args, {
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
timeout: 120_000,
|
|
maxBuffer: 4 * 1024 * 1024,
|
|
});
|
|
if (result.error || result.status !== 0)
|
|
throw new Error(
|
|
`NativeAOT build prerequisite/action ${command} failed: ${result.error?.message ?? ""}\n${result.stdout ?? ""}${result.stderr ?? ""}`,
|
|
);
|
|
return `${result.stdout ?? ""}\n${result.stderr ?? ""}`.trim();
|
|
}
|