Remove REA permission grants, scope ceilings, approval confirmations, and inert settings. Preserve selected local evidence, accept caller-chosen commands and paths, and report actual runtime failures. Harden provider results, schema serialization, snapshot evidence binding, archive paths, source maps, native screenshots, managed EH parsing, and cancellation cleanup. Regenerate tool metadata and document direct invocation. BREAKING CHANGE: Removed permission configuration and policy commands, approval fields, filesystem scope inputs, and fixed confirmation options. Process capture inherits the host environment and accepts command names; callers must refresh tool schemas and migrate removed fields.
73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
import { readFile, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
|
|
|
import { compareManagedMemberPaths } from "../../../../src/application/ManagedMemberComparisonService.js";
|
|
import { parseBinaryTarget } from "../../../../src/application/BinaryTargetResolver.js";
|
|
import { managedMemberComparisonResultSchema } from "../../../../src/domain/managedMemberComparison.js";
|
|
import { buildManagedPeFixture } from "../../../../src/dotnet/ManagedPe.fixture.js";
|
|
|
|
describe("managed member comparison path workflow", () => {
|
|
it("compares two local paths and returns derived Evidence", async () => {
|
|
const directory = await createTestTempDirectory("rea-managed-compare-");
|
|
const leftPath = join(directory, "left.dll");
|
|
const rightPath = join(directory, "right.dll");
|
|
await writeFile(leftPath, buildManagedPeFixture());
|
|
await writeFile(
|
|
rightPath,
|
|
buildManagedPeFixture({ methodName: "Renamed" }),
|
|
);
|
|
|
|
const result = await compareManagedMemberPaths({
|
|
leftPath,
|
|
rightPath,
|
|
});
|
|
|
|
expect(result.ok).toBe(true);
|
|
if (!result.ok) return;
|
|
expect(result.value).toMatchObject({
|
|
operation: "compare_managed_members",
|
|
confidence: "inferred",
|
|
authority: "analyst-inference",
|
|
});
|
|
expect(
|
|
managedMemberComparisonResultSchema.parse(result.value.normalized_result)
|
|
.matching.exact_il_signature,
|
|
).toBe(1);
|
|
});
|
|
|
|
it("rejects a file that changes after target identity is resolved", async () => {
|
|
const directory = await createTestTempDirectory(
|
|
"rea-managed-compare-race-",
|
|
);
|
|
const leftPath = join(directory, "left.dll");
|
|
const rightPath = join(directory, "right.dll");
|
|
await writeFile(leftPath, buildManagedPeFixture());
|
|
await writeFile(rightPath, buildManagedPeFixture());
|
|
const replacement = buildManagedPeFixture({
|
|
methodName: "ChangedAfterOpen",
|
|
});
|
|
|
|
const result = await compareManagedMemberPaths(
|
|
{ leftPath, rightPath },
|
|
{
|
|
resolveTarget: async (path) => {
|
|
const target = await parseBinaryTarget(path);
|
|
if (target.ok && path === leftPath)
|
|
await writeFile(path, replacement);
|
|
return target;
|
|
},
|
|
readBytes: (path) => readFile(path),
|
|
},
|
|
);
|
|
|
|
expect(result.ok).toBe(false);
|
|
if (result.ok) return;
|
|
expect(result.error._tag).toBe("EvidenceIntegrityError");
|
|
expect(result.error.message).toContain(leftPath);
|
|
});
|
|
});
|