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>
178 lines
5.8 KiB
JavaScript
178 lines
5.8 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Exercise the public one-shot CLI on a caller-owned saved project. The report
|
|
// is intentionally synthetic; it is not a claim about Ghidra's analysis history.
|
|
import assert from "node:assert/strict";
|
|
import { createHash } from "node:crypto";
|
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
import { join, resolve } from "node:path";
|
|
import { createVerifierCommands } from "./lib/verify-commands.mjs";
|
|
import {
|
|
VerifierFixture,
|
|
withVerifierFixture,
|
|
} from "./lib/verifier-fixture.mjs";
|
|
const installation = process.env.GHIDRA_INSTALL_DIR;
|
|
if (!installation || !process.env.JAVA_HOME)
|
|
throw new Error(
|
|
"Set GHIDRA_INSTALL_DIR and JAVA_HOME to caller-installed Ghidra 12.2 and JDK 25.",
|
|
);
|
|
const commands = await createVerifierCommands();
|
|
const workspace = await VerifierFixture.open({
|
|
prefix: "rea-function-bundle-",
|
|
private: false,
|
|
});
|
|
// Ghidra and the CLI run as owned commands that may use the root until they close.
|
|
workspace.releaseAfter(() => commands.close());
|
|
const targetHash = await withVerifierFixture(workspace, async () => {
|
|
const root = workspace.path;
|
|
const target = join(root, "fixture");
|
|
const projectDir = join(root, "project");
|
|
const scriptDir = join(root, "scripts");
|
|
const source = join(root, "fixture.c");
|
|
const project = join(projectDir, "SourceControl.gpr");
|
|
const repo = resolve(process.cwd());
|
|
const hash = (data) => createHash("sha256").update(data).digest("hex");
|
|
const tree = async (directory, prefix = "") => {
|
|
const result = [];
|
|
for (const entry of (
|
|
await readdir(directory, { withFileTypes: true })
|
|
).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
const path = join(directory, entry.name);
|
|
const relative = join(prefix, entry.name);
|
|
if (entry.isDirectory()) result.push(...(await tree(path, relative)));
|
|
else if (entry.isFile())
|
|
result.push([relative, hash(await readFile(path))]);
|
|
else throw new Error(`Unexpected project entry: ${relative}`);
|
|
}
|
|
return result;
|
|
};
|
|
const run = async (command, args, options = {}) =>
|
|
commands.exec(command, args, {
|
|
timeout: 120_000,
|
|
maxBuffer: 16 * 1024 * 1024,
|
|
...options,
|
|
});
|
|
await mkdir(projectDir);
|
|
await mkdir(scriptDir);
|
|
await writeFile(
|
|
source,
|
|
"__attribute__((noinline)) int leaf(int x) { return x + 1; }\nint main(void) { return leaf(2); }\n",
|
|
);
|
|
await writeFile(
|
|
join(scriptDir, "SetHistory.java"),
|
|
`import ghidra.app.script.GhidraScript;
|
|
import ghidra.program.model.listing.Program;
|
|
public class SetHistory extends GhidraScript {
|
|
public void run() throws Exception {
|
|
currentProgram.getOptions(Program.PROGRAM_INFO).setString("REA disabled analyzers", "{\\"format\\":\\"rea-ghidra-disabled-analyzers-v1\\",\\"analyzers\\":[{\\"name\\":\\"Synthetic historical control\\",\\"status\\":\\"disabled\\"}]}");
|
|
}
|
|
}
|
|
`,
|
|
);
|
|
await run(process.env.REA_CC ?? "cc", ["-O0", "-g", source, "-o", target]);
|
|
await run(join(installation, "support", "analyzeHeadless"), [
|
|
projectDir,
|
|
"SourceControl",
|
|
"-import",
|
|
target,
|
|
"-scriptPath",
|
|
scriptDir,
|
|
"-postScript",
|
|
"SetHistory.java",
|
|
]);
|
|
const before = await tree(projectDir);
|
|
const targetHash = hash(await readFile(target));
|
|
const env = {
|
|
...process.env,
|
|
REA_GHIDRA_PROJECT_PATH: project,
|
|
REA_GHIDRA_PROGRAM_NAME: "fixture",
|
|
};
|
|
const cli = join(repo, "scripts", "rea.mjs");
|
|
for (const detail of ["complete", "summary"]) {
|
|
const output = join(root, `${detail}.json`);
|
|
const { stdout } = await run(
|
|
process.execPath,
|
|
[
|
|
cli,
|
|
"function",
|
|
target,
|
|
"main",
|
|
"--provider",
|
|
"ghidra",
|
|
"--detail",
|
|
detail,
|
|
"--evidence_output",
|
|
output,
|
|
"--format",
|
|
"json",
|
|
"--full-output",
|
|
],
|
|
{ env },
|
|
);
|
|
assert.equal(JSON.parse(stdout).ok, true);
|
|
const bundle = JSON.parse(await readFile(output, "utf8"));
|
|
const parent = bundle.records.find(
|
|
(record) => record.operation === "analyze_function",
|
|
);
|
|
assert.ok(parent, "function observation missing from bundle");
|
|
assert.ok(
|
|
parent.evidence_links.length,
|
|
"fixture did not produce a linked historical source",
|
|
);
|
|
const records = new Map(
|
|
bundle.records.map((record) => [record.evidence_id, record]),
|
|
);
|
|
for (const record of bundle.records)
|
|
for (const link of record.evidence_links)
|
|
assert.ok(records.has(link), `bundle omits linked Evidence ${link}`);
|
|
assert.ok(
|
|
parent.evidence_links.some(
|
|
(id) => records.get(id)?.operation === "health",
|
|
),
|
|
"historical health source missing",
|
|
);
|
|
}
|
|
const existing = join(root, "existing.json");
|
|
await writeFile(existing, "caller-owned\n");
|
|
let failure;
|
|
try {
|
|
await run(
|
|
process.execPath,
|
|
[
|
|
cli,
|
|
"function",
|
|
target,
|
|
"main",
|
|
"--provider",
|
|
"ghidra",
|
|
"--detail",
|
|
"summary",
|
|
"--evidence_output",
|
|
existing,
|
|
"--format",
|
|
"json",
|
|
"--full-output",
|
|
],
|
|
{ env },
|
|
);
|
|
assert.fail("existing output unexpectedly overwritten");
|
|
} catch (error) {
|
|
if (error.code !== 1) throw error;
|
|
failure = JSON.parse(error.snapshot.stdout.text);
|
|
}
|
|
assert.equal(await readFile(existing, "utf8"), "caller-owned\n");
|
|
assert.equal(failure.ok, false);
|
|
assert.equal(failure.error.details.source_closure.complete, true);
|
|
assert.ok(
|
|
failure.error.details.source_closure.records.some(
|
|
(record) => record.operation === "health",
|
|
),
|
|
);
|
|
assert.equal(hash(await readFile(target)), targetHash);
|
|
assert.deepEqual(await tree(projectDir), before);
|
|
return targetHash;
|
|
});
|
|
process.stdout.write(
|
|
`PASS Ghidra function bundles: complete, summary, no-overwrite; target and project unchanged (${targetHash})\n`,
|
|
);
|