* feat(process): add owned debugger shutdown lifecycle * feat(reverse): add local inspection commands * feat(gdb): add persistent debugger integration * feat(cutter): add Cutter bridge integration * test(reverse): enforce complete integration coverage * fix(process): preserve debugger shutdown ownership * fix(reverse): retain evidence across interrupted commands * fix(gdb): honor captured provider environment * test(process): cover debugger shutdown retries * fix(reverse): retain evidence for interrupted providers * test(process): cover debugger shutdown retries * fix(reverse): retain evidence for interrupted providers * fix(server): snapshot provider environment at creation * fix(reverse): close review gaps with complete coverage * fix(reverse): address inspection review findings * fix(gdb): bound sessions and retain cleanup ownership * fix(ci): require reverse-tools quality lane * fix(process): unref inherited debugger output pipes * fix(reverse): address remaining PR 1960 findings * fix(gdb): address remaining PR 1961 findings * fix(reverse): account for unrestricted provider execution * fix(process): retain debugger ownership until safe shutdown * fix(process): preserve replacement debugger sessions * fix(reverse): preserve admission and output provenance * fix(process): retain exited debugger until output settles * fix(mcp): bound provider admission and debugger cleanup * fix(reverse): preserve failure provenance and classify E2BIG * fix(gdb): preserve startup cleanup and detach safety * fix(process): retain debugger ownership after detach failure * fix(reverse): preserve mutation and failure provenance * fix(gdb): address debugger review findings * fix(reverse): rebind sessions after external mutation * fix(process): cap debugger output after exit * fix(gdb): protect one-shot detach verification * feat(debugger): add reverse tool coverage gate * test(debugger): cover integrated failure paths * fix(gdb): bound and preserve session observations * fix(gdb): address review regressions * style: format merged integration files * fix(reverse): preserve session and output evidence * refactor(gdb): share repeated test and partial result setup * fix(gdb): invalidate TTY proof for Python aliases * fix(reverse): retain failure output byte counts * test(process): synchronize late debugger output * fix(gdb): invalidate TTY proof for wrapped commands * fix(gdb): recognize wit command abbreviation * test(reverse): wait for cancelled descendant readiness * test(reverse): bound descendant cancellation cleanup * style(reverse): format integration tests and adapters * style: format reverse engineering integration files * test(reverse): remove duplicate environment harness * test(gdb): share session startup assertions * fix(gdb): invalidate output proof for command abbreviations * test(reverse): share composition edge case scenarios * fix(ci): recognize verification and mutation tool entries * test(rizin): cover successful fake inferior detach * test(cli): align full output failure envelope * test(cli): isolate reverse command lifecycle service * test(process): share debugger output fixture setup * fix(binary): preserve high-bit Windows signature bytes * style(binary): format Windows signature parser * test(mcp): preserve call coverage in unchanged comparison * fix(ci): include reverse tools Vitest configs in lint cache * fix(mcp): preserve target content on delivery errors * ci: align duplication ceiling with expanded suite * test(reverse): allow signal admission mutants * fix(reverse): bound retained cleanup failures to process owners * fix(test): replace drifting mutation ranges with owned selectors * fix(reverse): admit persistent commands and retain cleanup ownership * fix(cutter): recover timed-out commands from exact receipts * fix(cutter): reject unsupported bridge request kinds * fix(ci): repair client format and shared verification fixtures * fix(native): preserve debugger cleanup ownership and bridge authentication * test(native): retain diagnostics without perfect coverage requirements * chore(licenses): refresh locked dependency inventory and notices * fix(test): exclude transient command locks from mutation sandboxes * fix(gdb): admit only platforms with safe detach verification * fix(cutter): retain bounded completion receipts until acknowledgement * fix(cutter): acknowledge commands rejected before UI dispatch * test(reverse): fail cancellation checks before fixture teardown * test(gdb): clean up the retained broken-stdin fixture owner * docs(test): clarify focused provider verification scope * fix(rizin): retain close cleanup failures * fix(gdb): wait for inferior stop and bound MI buffering * fix(cutter): retain failed receipt acknowledgements * fix(rizin): return retained session identity on rebind failure * fix(gdb): preserve startup cancellation and lossy status * fix(rizin): retain launch provenance and assemble frames once * fix(cutter): recover receipts across callers and bound discovery * docs: describe debugger evidence and bridge recovery * fix(process): keep cleanup incomplete while writers remain Stopping a debugger no longer reports success when inherited output streams stay open, so BinarySession cannot reopen a binary a child is still changing. Concurrent Cutter cleanup retries share one receipt acknowledgement instead of treating a consumed receipt as failure. * fix(debuggers): recover cleanup with captured process identities * fix(analysis): retire sessions after unrestricted commands * fix(cli): preserve completed evidence after cleanup recovery * fix(cutter): bound frame collection and coalesce cleanup * fix(windows): resolve selected provider paths absolutely * fix(gdb): report decoding loss in failed startup evidence * fix(rizin): scope decoding loss to collected command frames * test(mcp): cover snapshot retirement in reverse tools CI --------- Co-authored-by: Daniel Gonçalves Araujo <47118053+dandgabr@users.noreply.github.com> Co-authored-by: REA Maintainers <noreply@github.com> Co-authored-by: OpenAI Codex <codex@users.noreply.github.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
310 lines
10 KiB
TypeScript
310 lines
10 KiB
TypeScript
import { copyFile, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
import { SUPPORTED_CLIENT_DEFINITIONS } from "../../../src/application/SupportedClients.js";
|
|
import { CLI_COMMAND_NAMES } from "../../../src/cliCommandNames.js";
|
|
import { createCli } from "../../../src/cli.js";
|
|
import { FRIDA_PROVIDER_IDENTITY } from "../../../src/frida/FridaInstrumentationManager.js";
|
|
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
|
import {
|
|
HOPPER_OPERATIONS,
|
|
HOPPER_PROVIDER_IDENTITY,
|
|
} from "../../../src/hopper/HopperProviderCapabilities.js";
|
|
import {
|
|
GHIDRA_PROVIDER_IDENTITY,
|
|
GHIDRA_OPERATIONS,
|
|
} from "../../../src/ghidra/GhidraProviderCapabilities.js";
|
|
import { OBJDUMP_PROVIDER_IDENTITY } from "../../../src/objdump/ObjdumpCommand.js";
|
|
import { RIZIN_PROVIDER_IDENTITY } from "../../../src/rizin/RizinCommand.js";
|
|
import { GDB_PROVIDER_IDENTITY } from "../../../src/gdb/GdbSessionManager.js";
|
|
import {
|
|
documentationFactIssues,
|
|
skillReferenceIssues,
|
|
} from "../../../scripts/lib/docs-facts.mjs";
|
|
import { ensureGeneratedFile } from "../../../scripts/lib/generated-file.mjs";
|
|
import {
|
|
createCliInventory,
|
|
cliCommandDescriptionIssues,
|
|
cliCommandOptionNames,
|
|
} from "../../../scripts/lib/catalog-cli.mjs";
|
|
import {
|
|
createProductCatalog,
|
|
serializeProductCatalog,
|
|
} from "../../../scripts/lib/product-catalog.mjs";
|
|
|
|
const root = fileURLToPath(new URL("../../..", import.meta.url));
|
|
const temporaryRoots: string[] = [];
|
|
|
|
const README_FACT_FIXTURE_PATHS = [
|
|
"README.md",
|
|
"docs/readme/README_zh.md",
|
|
"docs/readme/README_ja.md",
|
|
"docs/readme/README_ko.md",
|
|
"docs/readme/README_ar.md",
|
|
"website/locales/languages.json",
|
|
"docs/installation.md",
|
|
"AGENTS.md",
|
|
".github/pull_request_template.md",
|
|
] as const;
|
|
|
|
const README_LINK_DRIFT_MUTATIONS = [
|
|
[
|
|
"(../installation.md#supported-agents)",
|
|
"(../installation.md#missing-agents)",
|
|
],
|
|
[
|
|
"https://rea.tools/zh-CN/guides/native/",
|
|
"https://rea.tools/zh-CN/missing/",
|
|
],
|
|
[
|
|
"https://rea.tools/zh-CN/guides/native/",
|
|
"https://rea.tools/zh-TW/guides/native/",
|
|
],
|
|
[
|
|
"https://rea.tools/zh-CN/guides/native/",
|
|
"https://rea.tools/zh-CN/guides/native/?other=1",
|
|
],
|
|
[
|
|
'src="../assets/rea-hopper-analysis.png"',
|
|
'src="../assets/missing-hopper.png"',
|
|
],
|
|
['href="https://discord.gg/GkcryMnJDM"', 'href="https://discord.gg/missing"'],
|
|
] as const;
|
|
|
|
const seedReadmeFactFixture = async (directory: string) => {
|
|
for (const path of README_FACT_FIXTURE_PATHS) {
|
|
const destination = join(directory, path);
|
|
await mkdir(dirname(destination), { recursive: true });
|
|
await copyFile(join(root, path), destination);
|
|
}
|
|
await mkdir(join(directory, "skills/reverse-engineer-anything"), {
|
|
recursive: true,
|
|
});
|
|
};
|
|
|
|
afterEach(async () => {
|
|
await Promise.all(
|
|
temporaryRoots
|
|
.splice(0)
|
|
.map((path) => rm(path, { recursive: true, force: true })),
|
|
);
|
|
});
|
|
|
|
describe("canonical product catalog", () => {
|
|
it("admits every documented browser scenario through the named contract", async () => {
|
|
const guide = await readFile(
|
|
join(root, "docs/browser-scenario-contract.md"),
|
|
"utf8",
|
|
);
|
|
const examples = [
|
|
...guide.matchAll(/```json\r?\n([\s\S]*?)\r?\n```/gu),
|
|
].map((match) => match[1] ?? "");
|
|
expect(examples.length).toBeGreaterThanOrEqual(2);
|
|
const contract = TOOL_CONTRACTS.find(
|
|
({ name }) => name === "capture_browser_scenario",
|
|
);
|
|
if (contract === undefined)
|
|
throw new Error("Missing browser scenario contract");
|
|
for (const example of examples)
|
|
expect(contract.inputSchema.safeParse(JSON.parse(example)).success).toBe(
|
|
true,
|
|
);
|
|
});
|
|
|
|
it("matches every source-derived build-generated product fact", async () => {
|
|
const catalog = await createProductCatalog(root);
|
|
expect(catalog.setup_clients.map(({ id }) => id)).toEqual(
|
|
SUPPORTED_CLIENT_DEFINITIONS.map(({ name }) => name),
|
|
);
|
|
expect(catalog.cli.commands).toHaveLength(CLI_COMMAND_NAMES.length);
|
|
expect(catalog.providers.map(({ id }) => id)).toEqual(
|
|
expect.arrayContaining(
|
|
[
|
|
OBJDUMP_PROVIDER_IDENTITY,
|
|
RIZIN_PROVIDER_IDENTITY,
|
|
GDB_PROVIDER_IDENTITY,
|
|
].map(({ id }) => id),
|
|
),
|
|
);
|
|
expect(
|
|
catalog.providers.find(({ id }) => id === HOPPER_PROVIDER_IDENTITY.id)
|
|
?.capabilities,
|
|
).toEqual([...HOPPER_OPERATIONS].sort());
|
|
expect(
|
|
catalog.providers.find(({ id }) => id === GHIDRA_PROVIDER_IDENTITY.id)
|
|
?.capabilities,
|
|
).toEqual([...GHIDRA_OPERATIONS].sort());
|
|
expect(
|
|
catalog.providers.find(({ id }) => id === FRIDA_PROVIDER_IDENTITY.id)
|
|
?.capabilities,
|
|
).toEqual(
|
|
TOOL_CONTRACTS.filter(({ name }) => name.includes("frida"))
|
|
.map(({ name }) => name)
|
|
.sort(),
|
|
);
|
|
expect(
|
|
JSON.parse(await readFile("docs/public/product-catalog.json", "utf8")),
|
|
).toEqual(catalog);
|
|
expect(await serializeProductCatalog(catalog)).toBe(
|
|
await readFile("docs/public/product-catalog.json", "utf8"),
|
|
);
|
|
await expect(documentationFactIssues(root, catalog)).resolves.toEqual([]);
|
|
}, 60_000);
|
|
});
|
|
|
|
describe("canonical CLI catalog", () => {
|
|
it("uses the same primary command names as the actual Incur router", () => {
|
|
const inventory = createCliInventory(createCli());
|
|
expect(inventory.primary).toEqual([...CLI_COMMAND_NAMES].sort());
|
|
expect(inventory.aliases).toEqual([
|
|
{ name: "compare-bundles", target: "compare" },
|
|
]);
|
|
}, 30_000);
|
|
|
|
it("describes every primary command argument and option", () => {
|
|
expect(cliCommandDescriptionIssues(createCli())).toEqual([]);
|
|
});
|
|
|
|
it("exposes the shared provider selector on every deep-analysis command", () => {
|
|
const cli = createCli();
|
|
for (const name of [
|
|
"analyze",
|
|
"inspect",
|
|
"decompile",
|
|
"xrefs",
|
|
"trace",
|
|
"function",
|
|
"annotate-native-function",
|
|
"inspect-native-api",
|
|
"search",
|
|
]) {
|
|
expect(cliCommandOptionNames(cli, name)).toContain("provider");
|
|
}
|
|
});
|
|
|
|
it("does not impose a private result limit on feature tracing", () => {
|
|
expect(cliCommandOptionNames(createCli(), "trace")).not.toContain("limit");
|
|
});
|
|
});
|
|
|
|
describe("canonical product catalog drift", () => {
|
|
it("rejects missing and repository-only links in an independently installed skill", async () => {
|
|
const directory = await createTestTempDirectory("rea-skill-references-");
|
|
const bundle = join(directory, "skill");
|
|
await mkdir(bundle);
|
|
await writeFile(join(directory, "repo-only.md"), "Repository-only guide");
|
|
await writeFile(join(bundle, "local.md"), "Bundled guide");
|
|
await writeFile(
|
|
join(bundle, "SKILL.md"),
|
|
[
|
|
"[bundled](local.md#guide)",
|
|
"[missing](missing.md)",
|
|
"[repository-only](../repo-only.md)",
|
|
"[public](https://example.test/guide)",
|
|
].join("\n"),
|
|
);
|
|
expect(await skillReferenceIssues(bundle)).toEqual([
|
|
"SKILL.md: missing skill reference: missing.md",
|
|
"SKILL.md: reference escapes installed skill bundle: ../repo-only.md",
|
|
]);
|
|
});
|
|
|
|
it("requires setup-client facts in the canonical installation guide", async () => {
|
|
const catalog = await createProductCatalog(root);
|
|
const drifted = {
|
|
...catalog,
|
|
setup_clients: [
|
|
...catalog.setup_clients,
|
|
{
|
|
id: "future_client",
|
|
display_name: "Future Client",
|
|
format: "json",
|
|
configuration: "managed",
|
|
},
|
|
],
|
|
};
|
|
const issues = await documentationFactIssues(root, drifted);
|
|
expect(issues).toContain("docs/installation.md: missing Future Client");
|
|
expect(issues).not.toContain("README.md: missing Future Client");
|
|
});
|
|
|
|
it("keeps translated readmes linked to canonical setup and tool details", async () => {
|
|
const directory = await createTestTempDirectory("rea-readme-facts-");
|
|
temporaryRoots.push(directory);
|
|
await seedReadmeFactFixture(directory);
|
|
const translatedPath = join(directory, "docs/readme/README_zh.md");
|
|
const translated = await readFile(translatedPath, "utf8");
|
|
const catalog = await createProductCatalog(root);
|
|
await expect(documentationFactIssues(directory, catalog)).resolves.toEqual(
|
|
[],
|
|
);
|
|
for (const [original, changed] of README_LINK_DRIFT_MUTATIONS) {
|
|
expect(translated).toContain(original);
|
|
await writeFile(
|
|
translatedPath,
|
|
translated.replace(original, changed),
|
|
"utf8",
|
|
);
|
|
await expect(
|
|
documentationFactIssues(directory, catalog),
|
|
).resolves.toEqual([
|
|
"docs/readme/README_zh.md: documentation links differ from README.md",
|
|
]);
|
|
}
|
|
});
|
|
it("fails check mode without rewriting a stale generated artifact", async () => {
|
|
const directory = await createTestTempDirectory("rea-generated-check-");
|
|
temporaryRoots.push(directory);
|
|
const path = join(directory, "catalog.json");
|
|
await writeFile(path, "stale\n", "utf8");
|
|
await expect(
|
|
ensureGeneratedFile({
|
|
path,
|
|
source: "current\n",
|
|
check: true,
|
|
generateCommand: "npm run docs:generate",
|
|
}),
|
|
).rejects.toThrow("missing or stale");
|
|
expect(await readFile(path, "utf8")).toBe("stale\n");
|
|
await expect(
|
|
ensureGeneratedFile({
|
|
path,
|
|
source: "current\n",
|
|
check: false,
|
|
generateCommand: "npm run docs:generate",
|
|
}),
|
|
).resolves.toEqual({ changed: true });
|
|
expect(await readFile(path, "utf8")).toBe("current\n");
|
|
});
|
|
|
|
it("accepts and preserves native generated-file line endings", async () => {
|
|
const directory = await createTestTempDirectory("rea-generated-eol-");
|
|
temporaryRoots.push(directory);
|
|
const path = join(directory, "catalog.json");
|
|
await writeFile(path, "current\r\n", "utf8");
|
|
await expect(
|
|
ensureGeneratedFile({
|
|
path,
|
|
source: "current\n",
|
|
check: true,
|
|
generateCommand: "npm run docs:generate",
|
|
}),
|
|
).resolves.toEqual({ changed: false });
|
|
expect(await readFile(path, "utf8")).toBe("current\r\n");
|
|
await expect(
|
|
ensureGeneratedFile({
|
|
path,
|
|
source: "updated\n",
|
|
check: false,
|
|
generateCommand: "npm run docs:generate",
|
|
}),
|
|
).resolves.toEqual({ changed: true });
|
|
expect(await readFile(path, "utf8")).toBe("updated\r\n");
|
|
});
|
|
});
|