mirror of
https://github.com/morluto/rea.git
synced 2026-11-20 21:53:51 +00:00
* feat(uefi): add pure-TS UEFI firmware volume/FFS parser with inspect/extract tools
Add a dependency-free rea-uefi provider that maps AMI/Aptio flash images:
- inspect_uefi_firmware: aligned _FVH discovery, volume-relative FFS walking,
guided section/compression classification, conservative PSP-directory probing,
embedded-volume rescan and leftover-region classification; incremental SHA-256
and explicit integrity notes.
- extract_uefi_firmware: whole-image/volume/FFS-file/section extraction with
LZMA-custom/LZMAF86 and AMD-zlib decoding, SafeOutputTree staging, derivations
and extraction_gaps.
- UefiArtifactReader + 'uefi' format wiring across inventory/domain/contracts
so parsed volumes and extracted PE32/TE files hand off to deep-provider
analysis (open_binary -> Ghidra).
* feat(uefi): add inspect_uefi_nvram for AMI NVRAM variable stores
Add a pure-TypeScript tool that maps the vendor AMI NVRAM variable stores
(factory-default "StdDefaults" and peers) inside a flash image:
- scan the raw image for NVAR entry chains ("NVAR" + u16 total size +
u32 attribute 0x8[23]FFFFFF + state + NUL-terminated name + data),
- recurse into a container entry whose data is itself an NVAR chain, so the
StdDefaults setup variables surface as depth/parent_offset rows,
- report attributes, state, data range, SHA-256 and trailing padding per entry.
Verified against B550 AORUS Elite V2 FId: one StdDefaults store at 0x37090 with
the 11 expected nested variables (Setup, PlatformLang, AMITSESetup, XhciDID,
GcSensorVarName, PCI_COMMON, SioSetupData, UsbSupport, NetworkStackVar,
SecureBootSetup, Setup). Exposed as MCP tool and inspect-uefi-nvram CLI command.
* fix(uefi): address review on checksums, compression, guided sections, NVRAM bounds
- FFS file checksum: verify the two's-complement invariant (payload sum +
stored byte == 0 mod 256) instead of comparing sums, and encode the correct
complement in the fixture builder.
- Compression sections (type 0x01): use the 9-byte header and classify EFI
standard compression instead of 'none', so extraction reports a gap rather
than publishing compressed bytes as a raw section.
- GUID-defined sections: derive GUID/data-offset/attributes from the parsed
common header size (compact or extended) and reject out-of-range payload
offsets.
- AMI NVRAM: bound recursive chains to the enclosing container's data end and
report partial coverage when a valid nested chain is cut by max_depth.
* fix(uefi): bound decode memory, serialize operations, enforce deadline, mark truncation
- LZMA worker: enforce max_output_bytes while decoding through a bounded output
sink, so an oversized stream is rejected during expansion instead of after a
full decompression plus a second Buffer copy.
- Provider: serialize admitted operations (the promised single decode-worker
lane must not become one worker per overlapping call) and apply one
whole-request deadline that covers every decode stage, not a fresh per-stream
timer. close() drains the queue and the resource scope.
- Scan: track truncated sections of known type and report coverage partial
instead of complete when a section declares more bytes than are present.
* fix(uefi): cancellable queue, timeout surfacing, availability and reader omissions
- Queue: check the caller signal before enqueue and when a job reaches the head,
and race the queued promise against abort so a cancelled wait returns
immediately instead of blocking behind the active request.
- Deadline: track the internal deadline and return AnalysisTimeoutError instead
of the AnalysisCancelledError that runOwnedCommand reports for any external
abort, preserving the real failure reason for CLI/MCP callers.
- CapabilityInventory: treat inspect_uefi_nvram like the other bundled rea-uefi
tools so discovery does not demand Unblob for it.
- UefiArtifactReader: report image truncation through onOmission so inventory
coverage reflects the unread suffix even when no volume was found.
* fix(uefi): limit early cancellation to unstarted jobs and preserve timeout cleanup
- #raceWithAbort only returns early for jobs that have not started; once a
request is running, await it so worker cleanup and completed output are
preserved instead of being discarded by a bare cancellation.
- Reclassify a deadline-induced cancellation as AnalysisTimeoutError while
keeping its cause and cleanup observations, and never override a different
primary failure.
* docs(licenses): record UEFI decoder dependency notices
* fix(uefi): preserve stream provenance and bound firmware analysis
* feat(uefi): decode LZMAF86 guided sections
* fix(uefi): validate publication before commit and order decoder cleanup
* fix(uefi): preserve unsupported volumes and extraction gaps
---------
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
115 lines
3.1 KiB
JavaScript
115 lines
3.1 KiB
JavaScript
import { matchesGlob } from "node:path";
|
|
|
|
/** Canonical file ownership shared by Vitest and development-test planning. */
|
|
export const SOURCE_TEST_PROJECTS = [
|
|
{
|
|
name: "domain",
|
|
group: "source",
|
|
isolate: false,
|
|
include: ["src/{contracts,domain,kernel,ports}/**/*.test.ts"],
|
|
},
|
|
{
|
|
name: "services",
|
|
group: "source",
|
|
isolate: false,
|
|
include: ["src/application/**/*.test.ts"],
|
|
},
|
|
{
|
|
name: "adapters",
|
|
group: "source",
|
|
include: [
|
|
"src/*.test.ts",
|
|
"src/{android,apkSignature,apktool,jeb,adb,artifacts,browser,compression,config,cutter,desktop,dotnet,electron,erlang,evm,firmware,flutter,frida,pcap,ghidra,go,gpu,hopper,hopperPaths,ida,inspector,java,javascript,kuna,main,native,nuget,process,providers,python,reference,resources,rust,server,sqlite,uefi,v8,wasm,windows}/**/*.test.ts",
|
|
],
|
|
},
|
|
{
|
|
name: "composition",
|
|
group: "source",
|
|
isolate: false,
|
|
include: ["tests/composition/**/*.test.ts"],
|
|
},
|
|
{
|
|
name: "conformance",
|
|
group: "source",
|
|
isolate: false,
|
|
include: ["tests/conformance/**/*.test.ts"],
|
|
exclude: ["tests/conformance/providers/hopper/realHopperSearch.test.ts"],
|
|
},
|
|
{
|
|
name: "evaluation",
|
|
group: "source",
|
|
isolate: false,
|
|
include: ["tests/evaluation/**/*.test.ts"],
|
|
},
|
|
];
|
|
|
|
export const BUILT_TEST_PROJECTS = [
|
|
{
|
|
name: "boundary",
|
|
group: "built",
|
|
include: [
|
|
"tests/boundary/**/*.test.ts",
|
|
"tests/conformance/providers/hopper/realHopperSearch.test.ts",
|
|
],
|
|
exclude: [
|
|
"tests/boundary/cli/**/*.test.ts",
|
|
"tests/boundary/mcp/**/*.test.ts",
|
|
"tests/boundary/process/**/*.test.ts",
|
|
],
|
|
},
|
|
{
|
|
name: "cli-boundary",
|
|
group: "built",
|
|
isolate: false,
|
|
include: ["tests/boundary/cli/**/*.test.ts"],
|
|
},
|
|
{
|
|
name: "process-boundary",
|
|
group: "built",
|
|
include: ["tests/boundary/process/**/*.test.ts"],
|
|
},
|
|
{
|
|
name: "mcp-boundary",
|
|
group: "built",
|
|
isolate: false,
|
|
include: ["tests/boundary/mcp/**/*.test.ts"],
|
|
},
|
|
{
|
|
name: "acceptance",
|
|
group: "built",
|
|
include: ["tests/acceptance/**/*.test.ts"],
|
|
},
|
|
{
|
|
name: "process-global",
|
|
group: "built",
|
|
include: ["tests/process-global/**/*.test.ts"],
|
|
},
|
|
];
|
|
|
|
const ALL_TEST_PROJECTS = [...SOURCE_TEST_PROJECTS, ...BUILT_TEST_PROJECTS];
|
|
|
|
/** Return the unique Vitest owner for an exact repository-relative test path. */
|
|
export const projectForTest = (testPath) => {
|
|
if (
|
|
typeof testPath !== "string" ||
|
|
testPath.startsWith("/") ||
|
|
testPath.includes("\\") ||
|
|
testPath.split("/").some((part) => part === ".." || part === ".") ||
|
|
!testPath.endsWith(".test.ts")
|
|
)
|
|
throw new Error(`Expected a normalized repository test path: ${testPath}`);
|
|
|
|
const owners = ALL_TEST_PROJECTS.filter(
|
|
({ include, exclude = [] }) =>
|
|
include.some((pattern) => matchesGlob(testPath, pattern)) &&
|
|
!exclude.some((pattern) => matchesGlob(testPath, pattern)),
|
|
);
|
|
if (owners.length !== 1)
|
|
throw new Error(
|
|
owners.length === 0
|
|
? `No test project owns ${testPath}`
|
|
: `Multiple test projects own ${testPath}: ${owners.map(({ name }) => name).join(", ")}`,
|
|
);
|
|
return owners[0];
|
|
};
|