refactor(ghidra): remove redundant schema markers

This commit is contained in:
morluto 2026-09-29 11:38:16 +08:00
parent 1860d4f0e5
commit c2a6f4bc43
3 changed files with 39 additions and 32 deletions

View File

@ -78,7 +78,7 @@ See [docs/architecture.mermaid](docs/architecture.mermaid) for a visual architec
- `npm run verify:browser`: build and run the real Chrome verifier against `REA_BROWSER_EXECUTABLE` or a platform-default Chrome-family executable, including browser-scenario CLI parity, attach disconnect-only ownership, launched-process termination, and temporary-profile cleanup.
- `npm run verify:inspector`: build and run the real attach-only Node Inspector verifier through the public CLI.
- `npm run verify:managed`: build and run the source-owned managed PE/CLI conformance verifier for artifact triage, member inspection, managed/native boundary declarations, token drift comparison, malformed metadata, non-managed degradation, managed application-graph projection, manifest-verifier self-test, and optional BYO ILSpy oracle checks; set `REA_MANAGED_APP_MANIFEST_PATH` to verify an operator-local managed app manifest, including optional graph/trace assertions, and set `REA_ILSPY_CMD_PATH` to an absolute `ilspycmd` path to run the real ILSpy reconstruction oracle.
- `npm run evidence:generate`: regenerate the managed conformance manifest and Evidence v2 completion ledger from live verifier output.
- `npm run evidence:generate`: regenerate the managed conformance manifest and evidence completion ledger from live verifier output.
- `npm run evidence:check`: rerun managed conformance and fail on generated manifest, completion ledger, or bundled skill drift.
- `npm run verify:replay`: build and run the real Linux Bubblewrap/seccomp/cgroup verifier against source-owned replay fixtures; set `REA_REPLAY_INPUT_PATH` to verify an operator-local manifest.
- `npm run verify:package`: pack and test the CLI, setup transaction, skill, and canonical target-free MCP catalog in an isolated environment.

View File

@ -85,7 +85,6 @@ public final class ReaGhidraBridge extends HeadlessScript {
private static final int DECOMPILE_PAYLOAD_MBYTES = 8;
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private static final Set<String> DESCRIPTOR_KEYS = Set.of(
"schema_version",
"transport",
"endpoint_path",
"token",
@ -203,7 +202,6 @@ public final class ReaGhidraBridge extends HeadlessScript {
server.bind(new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 0));
InetSocketAddress address = (InetSocketAddress) server.getLocalAddress();
JsonObject endpoint = new JsonObject();
endpoint.addProperty("schema_version", 1);
endpoint.addProperty("host", "127.0.0.1");
endpoint.addProperty("port", address.getPort());
Files.writeString(
@ -1749,9 +1747,6 @@ public final class ReaGhidraBridge extends HeadlessScript {
JsonParser.parseString(Files.readString(path, StandardCharsets.UTF_8)),
DESCRIPTOR_KEYS
);
if (requireInteger(object, "schema_version") != 2) {
throw new IllegalArgumentException("REA session descriptor version is invalid");
}
return new SessionDescriptor(
requireString(object, "transport"),
requireString(object, "endpoint_path"),

View File

@ -22,6 +22,39 @@ const fixturePath = fileURLToPath(
);
const roots: string[] = [];
const expectIsolatedEnvironment = (
environment: Record<string, string>,
runtimeRoot: string,
javaHome: string,
) => {
expect(environment).toMatchObject({
HOME: join(runtimeRoot, "home"),
...(process.platform === "win32"
? {
USERPROFILE: join(runtimeRoot, "home"),
TEMP: join(runtimeRoot, "tmp"),
TMP: join(runtimeRoot, "tmp"),
}
: {}),
TMPDIR: join(runtimeRoot, "tmp"),
XDG_CACHE_HOME: join(runtimeRoot, "cache"),
XDG_CONFIG_HOME: join(runtimeRoot, "config"),
XDG_DATA_HOME: join(runtimeRoot, "data"),
GHIDRA_HEADLESS_MAXMEM: "2G",
GHIDRA_JAVA_OPTIONS: "",
JAVA_TOOL_OPTIONS: "",
JDK_JAVA_OPTIONS: "",
_JAVA_OPTIONS: "",
JAVA_HOME: javaHome,
REA_PROCESS_RUN_ID: "d6fcbb66-e829-4ff6-a535-0035aec63139",
});
expect(environment.PATH).toMatch(
process.platform === "win32"
? /^C:\\Java\\jdk-21\\bin;/u
: /^\/opt\/jdk-21\/bin:/u,
);
};
beforeAll(async () => {
if (process.platform !== "win32") await chmod(fixturePath, 0o755);
});
@ -139,40 +172,19 @@ describe("Ghidra headless launcher", () => {
const capturePath = join(runtimeRoot, "launch-capture.json");
await waitFor(capturePath);
const capture = JSON.parse(await readFile(capturePath, "utf8"));
const descriptor = JSON.parse(
await readFile(join(runtimeRoot, "session.json"), "utf8"),
);
const encodedArguments = JSON.stringify(capture.arguments);
const encodedEnvironment = JSON.stringify(capture.environment);
expect(descriptor).not.toHaveProperty("schema_version");
expect(encodedArguments).not.toContain(token);
expect(encodedEnvironment).not.toContain(token);
expect(capture).toMatchObject({
...(process.platform === "win32" ? {} : { descriptor_mode: 0o600 }),
descriptor_has_token: true,
environment: {
HOME: join(runtimeRoot, "home"),
...(process.platform === "win32"
? {
USERPROFILE: join(runtimeRoot, "home"),
TEMP: join(runtimeRoot, "tmp"),
TMP: join(runtimeRoot, "tmp"),
}
: {}),
TMPDIR: join(runtimeRoot, "tmp"),
XDG_CACHE_HOME: join(runtimeRoot, "cache"),
XDG_CONFIG_HOME: join(runtimeRoot, "config"),
XDG_DATA_HOME: join(runtimeRoot, "data"),
GHIDRA_HEADLESS_MAXMEM: "2G",
GHIDRA_JAVA_OPTIONS: "",
JAVA_TOOL_OPTIONS: "",
JDK_JAVA_OPTIONS: "",
_JAVA_OPTIONS: "",
JAVA_HOME: javaHome,
REA_PROCESS_RUN_ID: "d6fcbb66-e829-4ff6-a535-0035aec63139",
},
});
expect(capture.environment.PATH).toMatch(
process.platform === "win32"
? /^C:\\Java\\jdk-21\\bin;/u
: /^\/opt\/jdk-21\/bin:/u,
);
expectIsolatedEnvironment(capture.environment, runtimeRoot, javaHome);
expect(capture.environment.GHIDRA_HEADLESS_JAVA_OPTIONS).toContain(
`-Duser.home=${join(runtimeRoot, "home")}`,
);