mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 14:31:22 +00:00
Add tests for admission rules a mutation audit showed unguarded: capture_process_scenario reports unsupported_host when process capture is disabled, Mach-O-only operations stay target_unsupported on an open ELF or PE executable, and the Hopper request queue admits a deadline equal to the largest Node timer delay.
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { buildCapabilityInventory } from "./CapabilityInventory.js";
|
|
|
|
const entry = (
|
|
name: string,
|
|
status: Parameters<typeof buildCapabilityInventory>[0],
|
|
processCaptureEnabled = true,
|
|
) =>
|
|
buildCapabilityInventory(status, { processCaptureEnabled }).find(
|
|
(tool) => tool.name === name,
|
|
);
|
|
|
|
it("reports process capture on a host that cannot run it as unsupported_host", () => {
|
|
const status = { open: false, capabilities: [] };
|
|
expect(entry("capture_process_scenario", status, false)).toMatchObject({
|
|
available: false,
|
|
reason: "unsupported_host",
|
|
remediation: expect.stringContaining("Linux or macOS"),
|
|
});
|
|
expect(entry("capture_process_scenario", status, true)).toMatchObject({
|
|
available: true,
|
|
reason: "available",
|
|
});
|
|
});
|
|
|
|
const openExecutable = (format: string, operation: string) => ({
|
|
open: true,
|
|
kind: "executable",
|
|
format,
|
|
capabilities: [
|
|
{
|
|
provider: { id: "fixture", name: "Fixture", version: "1" },
|
|
shared_limitations: [],
|
|
groups: [
|
|
{
|
|
operations: [operation],
|
|
effects: [],
|
|
limitations: [],
|
|
available: true,
|
|
reason: null,
|
|
availability_code: null,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|
|
|
|
it.each(["inspect_macho", "list_architectures"])(
|
|
"keeps %s unavailable on an open ELF or PE executable and names a Mach-O target",
|
|
(name) => {
|
|
for (const format of ["elf", "pe"])
|
|
expect(entry(name, openExecutable(format, name)), format).toMatchObject({
|
|
available: false,
|
|
reason: "target_unsupported",
|
|
remediation: expect.stringContaining("Mach-O executable"),
|
|
});
|
|
expect(entry(name, openExecutable("mach-o", name))).toMatchObject({
|
|
available: true,
|
|
});
|
|
},
|
|
);
|