Files
reverse-engineering-anything/tests/conformance/providerCapabilityCases.ts
T
bartman081523andmorluto d380dc2409 feat(uefi): add pure-TypeScript UEFI firmware analysis tools (#12342)
* 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>
2026-11-19 21:19:35 +00:00

173 lines
7.3 KiB
TypeScript

import type { CAPABILITY_DECLARATIONS } from "../../src/composition/capabilityDeclarations.js";
/**
* The public-workflow conformance case for each declared provider capability.
* A case is a CLI, MCP or acceptance test that exercises one of the
* capability's operations; an exemption must say why no such case exists.
* `providerCapabilityConformance.test.ts` iterates the capability
* declarations, so a newly declared capability fails until it is listed here.
*/
export type ProviderCapabilityConformance =
| { readonly cases: readonly [string, ...string[]] }
| { readonly exempt: string };
export const PROVIDER_CAPABILITY_CONFORMANCE: Readonly<
Partial<
Record<keyof typeof CAPABILITY_DECLARATIONS, ProviderCapabilityConformance>
>
> = {
adbDevice: { cases: ["tests/boundary/mcp/adbDeviceProperties.test.ts"] },
analysisView: { cases: ["tests/boundary/cli/analysisViewCli.test.ts"] },
android: { cases: ["tests/boundary/cli/androidPackageViewCli.test.ts"] },
androidApplicationGraph: {
cases: ["tests/boundary/mcp/mobileApplicationGraphMcp.test.ts"],
},
apkSignature: {
cases: ["tests/acceptance/apkSignatureLimitsCliMcp.test.ts"],
},
apktool: { cases: ["tests/boundary/cli/apktoolCli.test.ts"] },
appleApplicationGraph: {
cases: ["tests/boundary/mcp/mobileApplicationGraphMcp.test.ts"],
},
appleIps: { cases: ["tests/acceptance/appleIpsArmJoinCli.test.ts"] },
applicationWorkflows: {
cases: [
"tests/acceptance/applications/applicationVersionMatchingCli.test.ts",
],
},
artifactGraph: {
cases: ["tests/acceptance/artifactAdmittedIdentityMcp.test.ts"],
},
binaryHardening: { cases: ["tests/acceptance/binaryHardeningCli.test.ts"] },
binaryLayout: { cases: ["tests/boundary/mcp/binaryDiagnosticsMcp.test.ts"] },
browserObservation: {
cases: ["tests/acceptance/browser/observationDurationCli.test.ts"],
},
browserScenarioCapture: {
cases: ["tests/acceptance/browser/browserScenarioCancellationCli.test.ts"],
},
byteEntropy: {
cases: ["tests/acceptance/byteEntropyWindowsIdentity.test.ts"],
},
cutter: { cases: ["tests/boundary/cli/cutterStatusAttributionCli.test.ts"] },
desktopApplication: {
cases: ["tests/boundary/cli/desktopApplicationCli.test.ts"],
},
devicetree: { cases: ["tests/acceptance/devicetreeCli.test.ts"] },
dwarfUnits: {
cases: [
"tests/acceptance/dwarfUnitsCli.test.ts",
"tests/boundary/mcp/dwarfUnitsMcp.test.ts",
],
},
electronActiveObservation: {
cases: ["tests/acceptance/applications/electronBlankPathCli.test.ts"],
},
electronFuses: { cases: ["tests/acceptance/electronFusesCli.test.ts"] },
electronObservation: { cases: ["tests/boundary/cli/electronCli.test.ts"] },
elfDebugLink: {
cases: [
"tests/acceptance/elfDebugLinkCli.test.ts",
"tests/boundary/mcp/elfDebugLinkMcp.test.ts",
],
},
elfNotes: { cases: ["tests/acceptance/elfNotesCli.test.ts"] },
elfDependencies: {
cases: [
"tests/acceptance/elfDependenciesCli.test.ts",
"tests/boundary/mcp/elfDependenciesMcp.test.ts",
],
},
elfUnwindRanges: { cases: ["tests/acceptance/elfUnwindRangesCli.test.ts"] },
erlangBeam: { cases: ["tests/acceptance/erlangBeamCli.test.ts"] },
evmInterface: { cases: ["tests/boundary/mcp/evmInterfaceMcp.test.ts"] },
firmwareAnalysis: { cases: ["tests/boundary/mcp/firmwareMcp.test.ts"] },
uefiAnalysis: { cases: ["tests/acceptance/uefiFirmware.test.ts"] },
flutter: { cases: ["tests/boundary/cli/flutterCli.test.ts"] },
fridaInstrumentation: { cases: ["tests/boundary/cli/fridaCli.test.ts"] },
gdbSessions: { cases: ["tests/boundary/cli/gdbStartupCleanupCli.test.ts"] },
ghidra: { cases: ["tests/boundary/mcp/ghidraInventoryMcp.test.ts"] },
goBinary: { cases: ["tests/acceptance/goBinaryCli.test.ts"] },
gpuCodeObjects: { cases: ["tests/acceptance/gpuCodeObjectsCli.test.ts"] },
harmonyApplicationGraph: {
cases: ["tests/boundary/mcp/mobileApplicationGraphMcp.test.ts"],
},
hopper: { cases: ["tests/boundary/cli/hopperLaunchFailureCli.test.ts"] },
ida: { cases: ["tests/boundary/cli/idaStartupAttributionCli.test.ts"] },
il2cppMetadata: { cases: ["tests/acceptance/il2cppMetadataCli.test.ts"] },
javascriptApplication: {
cases: [
"tests/acceptance/applications/analyzeJavaScriptDeliveryCli.test.ts",
],
},
javascriptRecovery: {
cases: ["tests/boundary/mcp/javascriptRecoveryMcp.test.ts"],
},
javascriptRuntimeObservation: {
cases: ["tests/boundary/mcp/javascriptRuntimeObservationMcp.test.ts"],
},
javascriptRuntimeReconciliation: {
cases: [
"tests/acceptance/applications/javascriptNodeTargetReconciliationCli.test.ts",
],
},
jeb: { cases: ["tests/boundary/cli/jebCli.test.ts"] },
kernelBuildConfig: {
cases: ["tests/acceptance/kernelBuildConfigCli.test.ts"],
},
kernelModule: { cases: ["tests/acceptance/kernelModuleCli.test.ts"] },
kuna: { cases: ["tests/boundary/mcp/kunaCloseRetryMcp.test.ts"] },
managedStatic: { cases: ["tests/acceptance/managedCliOutput.test.ts"] },
managedWorkflow: {
cases: ["tests/boundary/mcp/managedWorkflowUnknownIdentityMcp.test.ts"],
},
mavenGradleMetadata: {
cases: ["tests/acceptance/mavenGradleMetadataCli.test.ts"],
},
modelArtifact: { cases: ["tests/acceptance/modelArtifactCli.test.ts"] },
nativeExports: {
cases: [
"tests/acceptance/applications/nativeExportsDynamicSegment.test.ts",
],
},
nativeInitializers: {
cases: ["tests/acceptance/nativeInitializersCli.test.ts"],
},
nativeMacOS: {
cases: ["tests/acceptance/nativeMachoParenthesizedCli.test.ts"],
},
packetCapture: { cases: ["tests/boundary/mcp/packetCaptureMcp.test.ts"] },
pcap: { cases: ["tests/acceptance/pcapCredentialErrorsCliMcp.test.ts"] },
peCertificates: { cases: ["tests/acceptance/peCertificatesCli.test.ts"] },
peImports: { cases: ["tests/acceptance/peImportsCli.test.ts"] },
peLoadConfig: { cases: ["tests/acceptance/peLoadConfigCli.test.ts"] },
peResources: { cases: ["tests/acceptance/applications/peResources.test.ts"] },
nugetNupkg: { cases: ["tests/acceptance/nugetNupkgCli.test.ts"] },
pythonPyc: { cases: ["tests/acceptance/pythonPycCli.test.ts"] },
recordedCrash: { cases: ["tests/boundary/mcp/recordedCrashMcp.test.ts"] },
releaseExposure: { cases: ["tests/acceptance/releaseExposureCli.test.ts"] },
reverseEngineering: {
cases: ["tests/boundary/mcp/reverseEngineeringEnvironmentMcp.test.ts"],
},
rizinDebugSessions: {
cases: ["tests/boundary/mcp/rizinDebuggerCancellationMcp.test.ts"],
},
rustBinary: { cases: ["tests/acceptance/rustBinaryCli.test.ts"] },
signalRecording: { cases: ["tests/boundary/mcp/signalRecordingMcp.test.ts"] },
sqliteDatabase: { cases: ["tests/acceptance/sqliteDatabaseCli.test.ts"] },
v8CodeCache: { cases: ["tests/acceptance/v8CodeCacheCli.test.ts"] },
wasmArtifact: { cases: ["tests/boundary/mcp/wasmArtifactMcp.test.ts"] },
webModuleTrace: { cases: ["tests/boundary/mcp/webModuleTraceMcp.test.ts"] },
webNetworkCapture: {
cases: ["tests/boundary/mcp/webNetworkCaptureMcp.test.ts"],
},
webRuntime: { cases: ["tests/acceptance/webRuntimeCli.test.ts"] },
webScriptExport: {
cases: ["tests/acceptance/applications/webScriptPortablePathsCli.test.ts"],
},
webSourceLocation: {
cases: ["tests/acceptance/webSourceLocationCli.test.ts"],
},
windowsShortcut: { cases: ["tests/acceptance/windowsShortcutCli.test.ts"] },
};