mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 18:14:40 +00:00
Add offline ELF dependency, search-path, symbol-version and import inspection with retained Evidence summaries and pages. Bound GNU-hash work and preserve cancellation, stable identity and caller-selected parameters across CLI/MCP. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning) Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { ElfNotesService } from "./ElfNotesService.js";
|
|
import { KernelModuleService } from "./KernelModuleService.js";
|
|
import { ElfDependenciesService } from "./ElfDependenciesService.js";
|
|
import { PeCertificatesService } from "./PeCertificatesService.js";
|
|
import { PeImportsService } from "./PeImportsService.js";
|
|
import { WindowsShortcutService } from "./WindowsShortcutService.js";
|
|
import {
|
|
ELF_NOTES_PROVIDER,
|
|
KERNEL_MODULE_PROVIDER,
|
|
ELF_DEPENDENCIES_PROVIDER,
|
|
PE_CERTIFICATES_PROVIDER,
|
|
PE_IMPORTS_PROVIDER,
|
|
WINDOWS_SHORTCUT_PROVIDER,
|
|
} from "../../domain/investigationProviders.js";
|
|
|
|
const inspect = (): never => {
|
|
throw new Error("An already cancelled request must not reach its provider");
|
|
};
|
|
|
|
it.each([
|
|
[
|
|
"PE imports",
|
|
() => new PeImportsService({ identity: PE_IMPORTS_PROVIDER, inspect }),
|
|
],
|
|
[
|
|
"PE certificates",
|
|
() =>
|
|
new PeCertificatesService({
|
|
identity: PE_CERTIFICATES_PROVIDER,
|
|
inspect,
|
|
}),
|
|
],
|
|
[
|
|
"ELF notes",
|
|
() => new ElfNotesService({ identity: ELF_NOTES_PROVIDER, inspect }),
|
|
],
|
|
[
|
|
"kernel module",
|
|
() =>
|
|
new KernelModuleService({ identity: KERNEL_MODULE_PROVIDER, inspect }),
|
|
],
|
|
[
|
|
"ELF dependencies",
|
|
() =>
|
|
new ElfDependenciesService({
|
|
identity: ELF_DEPENDENCIES_PROVIDER,
|
|
inspect,
|
|
}),
|
|
],
|
|
[
|
|
"Windows shortcut",
|
|
() =>
|
|
new WindowsShortcutService({
|
|
identity: WINDOWS_SHORTCUT_PROVIDER,
|
|
inspect,
|
|
}),
|
|
],
|
|
] as const)(
|
|
"preserves an early cancellation reason for %s before validation",
|
|
async (_label, create) => {
|
|
const service = create();
|
|
try {
|
|
for (const reason of [null, { caller: "selected task" }]) {
|
|
const result = await service.inspect(null, {
|
|
signal: AbortSignal.abort(reason),
|
|
});
|
|
if (result.ok) throw new Error("Expected early cancellation");
|
|
expect(result.error._tag).toBe("AnalysisCancelledError");
|
|
expect(result.error.cause).toBe(reason);
|
|
}
|
|
} finally {
|
|
await service.close();
|
|
}
|
|
},
|
|
);
|