Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
test: assert Result reasons instead of bare ok checks (#5821)
morlutod9767eb48f23
diff --git a/src/domain/dosMz.test.ts b/src/domain/dosMz.test.tsindex bd98ca7e8..0a591d23a 100644--- a/src/domain/dosMz.test.ts+++ b/src/domain/dosMz.test.ts@@ -109,15 +109,32 @@ describe("DOS MZ load-module validation", () => {});it.each([- ["page count", (bytes: Buffer) => bytes.writeUInt16LE(0, 4)],- ["final-page size", (bytes: Buffer) => bytes.writeUInt16LE(512, 2)],- ["header size", (bytes: Buffer) => bytes.writeUInt16LE(1, 8)],- ["entry point", (bytes: Buffer) => bytes.writeUInt16LE(128, 20)],+ [+ "page count",+ (bytes: Buffer) => bytes.writeUInt16LE(0, 4),+ "invalid DOS MZ page count or final-page size",+ ],+ [+ "final-page size",+ (bytes: Buffer) => bytes.writeUInt16LE(512, 2),+ "invalid DOS MZ page count or final-page size",+ ],+ [+ "header size",+ (bytes: Buffer) => bytes.writeUInt16LE(1, 8),+ "invalid DOS MZ header size or empty load module",+ ],+ [+ "entry point",+ (bytes: Buffer) => bytes.writeUInt16LE(128, 20),+ "DOS MZ entry point lies outside its initialized load module",+ ],["relocation-table bounds",(bytes: Buffer) => {bytes.writeUInt16LE(2, 6);},+ "DOS MZ relocation table lies outside its header",],["relocation target",@@ -125,11 +142,12 @@ describe("DOS MZ load-module validation", () => {bytes.writeUInt16LE(1, 6);bytes.writeUInt16LE(127, 28);},+ "DOS MZ relocation 0 points outside its load module",],- ] as const)("rejects invalid %s", (_name, damage) => {+ ] as const)("rejects invalid %s", (_name, damage, error) => {const bytes = dosMz();damage(bytes);- expect(parseDosMzHeader(bytes).ok).toBe(false);+ expect(parseDosMzHeader(bytes)).toEqual({ ok: false, error });});it("rejects a truncated relocation table even when the file size is known", () => {diff --git a/src/domain/rawBinary.test.ts b/src/domain/rawBinary.test.tsindex 558e98e00..72da0f6dc 100644--- a/src/domain/rawBinary.test.ts+++ b/src/domain/rawBinary.test.ts@@ -33,7 +33,10 @@ describe("raw-binary entry addresses", () => {it.each(["8000000", "0x", "0xgg", "0X8000000", ""])("rejects malformed entry %s",(value) => {- expect(parseRawBinaryEntryPoint(value).ok).toBe(false);+ expect(parseRawBinaryEntryPoint(value)).toEqual({+ ok: false,+ error: "entry_point must be a hexadecimal address of the form 0x…",+ });},);});diff --git a/src/evm/EvmWorkerLimits.test.ts b/src/evm/EvmWorkerLimits.test.tsindex fcbf8197a..a7631689e 100644--- a/src/evm/EvmWorkerLimits.test.ts+++ b/src/evm/EvmWorkerLimits.test.ts@@ -43,13 +43,44 @@ it("independently preserves CPU and file output restrictions", () => {).toMatchObject({ ok: true, value: { cpuSeconds: 5, fileSizeBytes: 4096 } });});it.each([- ["not-text", null],- ["soft-unlimited-hard-finite", limits("unlimited", "2147483648")],- ["soft-exceeds-hard", limits("3", "2")],- ["missing-row", limits().replace("Max file size", "Max other size")],- ["duplicate-row", limits() + "Max cpu time 1 1 seconds\n"],- ["wrong-unit", limits().replace("bytes", "pages")],- ["oversized", "x".repeat(65537)],-])("rejects malformed/ambiguous resource observations: %s", (_label, input) => {- expect(selectEvmWorkerLimits(input).ok).toBe(false);-});+ [+ "not-text",+ null,+ "Linux resource limits must be text within the 64 KiB parsing budget.",+ ],+ [+ "soft-unlimited-hard-finite",+ limits("unlimited", "2147483648"),+ "Inherited Max address space soft limit exceeds its hard limit.",+ ],+ [+ "soft-exceeds-hard",+ limits("3", "2"),+ "Inherited Max address space soft limit exceeds its hard limit.",+ ],+ [+ "missing-row",+ limits().replace("Max file size", "Max other size"),+ "Linux resource limits must report exactly one Max file size row.",+ ],+ [+ "duplicate-row",+ limits() + "Max cpu time 1 1 seconds\n",+ "Linux resource limits must report exactly one Max cpu time row.",+ ],+ [+ "wrong-unit",+ limits().replace("bytes", "pages"),+ "Malformed inherited Linux resource limit: Max address space.",+ ],+ [+ "oversized",+ "x".repeat(65537),+ "Linux resource limits must be text within the 64 KiB parsing budget.",+ ],+])(+ "rejects malformed/ambiguous resource observations: %s",+ (_label, input, error) => {+ expect(selectEvmWorkerLimits(input)).toEqual({ ok: false, error });+ },+);diff --git a/src/ghidra/GhidraSessionValues.test.ts b/src/ghidra/GhidraSessionValues.test.tsindex a68ed1615..84a5c3653 100644--- a/src/ghidra/GhidraSessionValues.test.ts+++ b/src/ghidra/GhidraSessionValues.test.ts@@ -36,19 +36,30 @@ const session = (},});+const rejectedHandshake = (value: ReturnType<typeof session>) => {+ const parsed = parseGhidraSessionInfo(value, expected);+ if (parsed.ok) throw new Error("expected an invalid Ghidra handshake");+ return parsed.error;+};+describe("Ghidra DOS import commitment", () => {it("accepts the exact admitted real-mode language and compiler", () => {- expect(parseGhidraSessionInfo(session(), expected).ok).toBe(true);+ const parsed = parseGhidraSessionInfo(session(), expected);+ if (!parsed.ok) throw parsed.error;+ expect(parsed.value.target).toMatchObject({+ language_id: expected.expectedLanguageId,+ compiler_spec_id: expected.expectedCompilerSpecId,+ });});it("rejects a 32-bit interpretation even when artifact and profile hashes match", () => {- expect(- parseGhidraSessionInfo(session("x86:LE:32:default"), expected).ok,- ).toBe(false);+ expect(rejectedHandshake(session("x86:LE:32:default")).message).toBe(+ "Ghidra bridge handshake identity is invalid",+ );});it("rejects compiler drift independently of the language", () => {- expect(- parseGhidraSessionInfo(session(undefined, "windows"), expected).ok,- ).toBe(false);+ expect(rejectedHandshake(session(undefined, "windows")).message).toBe(+ "Ghidra bridge handshake identity is invalid",+ );});});