Files
rea/src/composition/binaryDiagnostics.ts
T
Matt Van Horn b4ba96a9a5 feat(firmware): inspect flattened devicetree blobs (#7009)
* feat(firmware): inspect flattened devicetree blobs

Adds inspect-devicetree and inspect_devicetree for FDT v16/v17 blobs
without target execution or external dependencies. Results include
validated headers, reservations, a node/property tree with bounded raw
previews, and derived standard values and selected phandle references.
Parsing enforces file, tree, and decoded representation budgets and
rejects malformed input without partial success. Summary delivery
supports retained Evidence pagination, with tests covering parsing,
service validation, CLI delivery, and MCP access after the input is
removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe

* fix(firmware): reject conflicting devicetree phandles and bound page summaries

A node whose phandle and linux,phandle disagree no longer resolves under
either value; the conflict is reported as a limitation. Finalization
failures after a completed read retain the file-snapshot-hash partial
observation, matching the Go provider. Devicetree view pages carry
fixed-size context and counts instead of repeating summary strings, so a
large bootargs no longer pushes every page over the MCP response budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-10-24 22:45:22 +08:00

77 lines
4.5 KiB
TypeScript

import { PeLoadConfigService } from "../application/binaryDiagnostics/PeLoadConfigService.js";
import { PeLoadConfigProvider } from "../native/pe/PeLoadConfigProvider.js";
import { ByteEntropyService } from "../application/binaryDiagnostics/ByteEntropyService.js";
import { RecordedCrashService } from "../application/binaryDiagnostics/RecordedCrashService.js";
import { PwntoolsRecordedCrashProvider } from "../native/pwntools/PwntoolsRecordedCrashProvider.js";
import { BinaryLayoutService } from "../application/binaryDiagnostics/BinaryLayoutService.js";
import { PwntoolsLayoutProvider } from "../native/pwntools/PwntoolsLayoutProvider.js";
import { pwntoolsHostSupported } from "../native/pwntools/PwntoolsDecoder.js";
import { PeResourcesService } from "../application/binaryDiagnostics/PeResourcesService.js";
import { PeResourcesProvider } from "../native/pe/PeResourcesProvider.js";
import { PeCertificatesService } from "../application/binaryDiagnostics/PeCertificatesService.js";
import { PeCertificatesProvider } from "../native/pe/PeCertificatesProvider.js";
import { PeImportsService } from "../application/binaryDiagnostics/PeImportsService.js";
import { PeImportsProvider } from "../native/pe/PeImportsProvider.js";
import { ElfNotesService } from "../application/binaryDiagnostics/ElfNotesService.js";
import { ElfNotesProvider } from "../native/elf/ElfNotesProvider.js";
import { AppleIpsService } from "../application/binaryDiagnostics/AppleIpsService.js";
import { AppleIpsProvider } from "../native/apple/AppleIpsProvider.js";
import { KernelModuleService } from "../application/binaryDiagnostics/KernelModuleService.js";
import { KernelModuleProvider } from "../native/elf/KernelModuleProvider.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import { NativeExportsService } from "../application/binaryDiagnostics/NativeExportsService.js";
import { NativeExportsProvider } from "../native/exports/NativeExportsProvider.js";
import { DevicetreeService } from "../application/binaryDiagnostics/DevicetreeService.js";
import { DevicetreeProvider } from "../firmware/devicetree/DevicetreeProvider.js";
export const createDevicetreeService = (): DevicetreeService =>
new DevicetreeService(new DevicetreeProvider());
export { pwntoolsHostSupported };
/** Portable PE inspection with no engine, installation or target acquisition. */
export const createPeResourcesService = (): PeResourcesService =>
new PeResourcesService(new PeResourcesProvider());
/** Portable Authenticode table inspection with no engine or catalog verification. */
export const createPeCertificatesService = (): PeCertificatesService =>
new PeCertificatesService(new PeCertificatesProvider());
/** Portable PE import-table inspection with no engine or catalog verification. */
export const createPeImportsService = (): PeImportsService =>
new PeImportsService(new PeImportsProvider());
/** Portable PE/ELF export tables with no engine, toolchain or target acquisition. */
export const createNativeExportsService = (): NativeExportsService =>
new NativeExportsService(new NativeExportsProvider());
/** Portable ELF note-table inspection with no engine or package catalog. */
export const createElfNotesService = (): ElfNotesService =>
new ElfNotesService(new ElfNotesProvider());
/** Portable Apple .ips inspection with no engine, Xcode or target acquisition. */
export const createAppleIpsService = (): AppleIpsService =>
new AppleIpsService(new AppleIpsProvider());
/** Portable Linux kernel-module metadata inspection with no engine or host `modinfo`. */
export const createKernelModuleService = (): KernelModuleService =>
new KernelModuleService(new KernelModuleProvider());
/** Compose the offline adapter without import-time I/O or dependency acquisition. */
export const createBinaryLayoutService = (
environment: Readonly<NodeJS.ProcessEnv> = process.env,
): BinaryLayoutService =>
new BinaryLayoutService(new PwntoolsLayoutProvider(environment));
/** Compose recorded-core inspection without acquiring a debugger or toolchain. */
export const createRecordedCrashService = (
environment: Readonly<NodeJS.ProcessEnv> = process.env,
): RecordedCrashService =>
new RecordedCrashService(new PwntoolsRecordedCrashProvider(environment));
/** Provider-free local byte analysis. */
export const createByteEntropyService = (
resources?: ArtifactResourceScope,
): ByteEntropyService => new ByteEntropyService(undefined, resources);
export const createPeLoadConfigService = (): PeLoadConfigService =>
new PeLoadConfigService(new PeLoadConfigProvider());