mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
refactor(artifacts): break the artifacts-firmware and artifacts-gpu import cycles (#11331)
* refactor(domain): move BinaryContainer into src/domain BinaryContainer imports only domain modules and is shared by artifacts, firmware, gpu, go, il2cpp, python, rust and native. Living under src/native made artifacts and firmware import native for its failure types and BinaryReader. Pure move: git mv plus import specifier updates. * refactor(firmware): move the devicetree parser into src/domain/firmware The FIT artifact reader in src/artifacts parses embedded devicetree blobs with the parser that lived under src/firmware, while firmware's providers import src/artifacts: the two units imported each other. The parser and its fixture are pure and now sit beside domain/firmware/devicetree.ts. Pure move: git mv plus import specifier and baseline key updates. * refactor(artifacts): break the artifacts-gpu import cycle (#11335) * refactor(artifacts): move the LZ4 block decoder into src/artifacts Pure move: git mv plus import specifier updates. The next commit removes its GPU-specific budget. * refactor(artifacts): take the LZ4 output budget from the caller decodeLz4Block bounded every decode by the GPU object budget and threw through rejectGpu, so UnityFS decoding in src/artifacts imported src/gpu while gpu imports artifacts. Callers now pass their budget: GPU payloads keep GPU_OBJECT_BYTES; UnityFS passes its 64 MiB block bound, which its size checks already enforce before decoding. Malformed blocks still throw BinaryFormatFailure with the same messages. * test(architecture): drop the artifacts-firmware and artifacts-gpu cycles from the layer baseline * refactor(artifacts): move the PE resource reader into src/artifacts/pe (#11347) refactor(artifacts): move the PE resource layout and parser into src/artifacts/pe The Node SEA and Deno standalone readers in src/artifacts locate PE resources with the layout and parser that lived under src/native/pe, while those modules already read through src/artifacts (ArtifactReaderFailure, assertArtifactReadActive). Pure move: git mv plus import specifier, baseline key and spec path updates.
This commit is contained in:
1 parent
0c8d8cc879
commit
264dcd5fee
113 files changed
+191
-167
No files matched your search
@@ -312,7 +312,7 @@ omissions alone explain it; independently proven differences still survive.
|
||||
A byte-format parser reports failure with `ParseFailureError` from
|
||||
`src/domain/parseFailure.ts`: `malformed`, `truncated`, `unsupported`, or
|
||||
`limit`, with the format and, when known, the offset and field. Read bounded
|
||||
fields through `BinaryReader` (`src/native/metadata/BinaryContainer.ts`), which
|
||||
fields through `BinaryReader` (`src/domain/binaryContainer.ts`), which
|
||||
raises that failure instead of a bare `RangeError`. Providers project the
|
||||
failure with `parseFailureAnalysisError` rather than their own `instanceof`
|
||||
ladder; a `limit` stays with its producer, which knows the budget to name.
|
||||
|
||||
@@ -17,7 +17,7 @@ section placement:
|
||||
|
||||
- `DenoStandaloneLocation.ts` confirms the carrier name before claiming a file.
|
||||
It reads ELF and note headers, walks PE resource directories to the named
|
||||
payload through `src/native/pe/PeResourceLayout.ts`, and scans Intel trailers
|
||||
payload through `src/artifacts/pe/PeResourceLayout.ts`, and scans Intel trailers
|
||||
to the slice start so an enclosing app wins over a stored executable.
|
||||
- `DenoSectionLayout.ts` parses metadata JSON, the virtual-filesystem header,
|
||||
specifier, redirect and remote tables, and the npm snapshot length.
|
||||
|
||||
@@ -55,8 +55,6 @@
|
||||
"application <-> frida",
|
||||
"application <-> providers",
|
||||
"artifacts <-> dotnet",
|
||||
"artifacts <-> firmware",
|
||||
"artifacts <-> gpu",
|
||||
"artifacts <-> javascript",
|
||||
"artifacts <-> native",
|
||||
"artifacts <-> process",
|
||||
|
||||
@@ -514,7 +514,7 @@ checkCounted(
|
||||
);
|
||||
|
||||
// Byte-format parsers read untrusted input. Bounds, truncation and failure
|
||||
// kind belong to BinaryReader (src/native/metadata/BinaryContainer.ts) and
|
||||
// kind belong to BinaryReader (src/domain/binaryContainer.ts) and
|
||||
// the ParseFailure algebra (src/domain/parseFailure.ts), not to each parser.
|
||||
const PARSER_FOLDERS = [
|
||||
"src/android/",
|
||||
@@ -564,11 +564,11 @@ const parserFiles = files.filter((file) =>
|
||||
// An unchecked Buffer or DataView read throws a bare RangeError past the end,
|
||||
// which a catch site cannot tell from a host stack or string limit.
|
||||
checkCounted(
|
||||
"raw Buffer or DataView numeric read (use BinaryReader from src/native/metadata/BinaryContainer)",
|
||||
"raw Buffer or DataView numeric read (use BinaryReader from src/domain/binaryContainer)",
|
||||
"raw-buffer-read",
|
||||
files,
|
||||
/\.(?:read(?:Big)?U?Int(?:8|16|32|64)?(?:LE|BE)?|readBigUint64(?:LE|BE)|readUint(?:8|16|32)(?:LE|BE)?|read(?:Float|Double)(?:LE|BE)|get(?:Big)?(?:Uint|Int)(?:8|16|32|64)|getFloat(?:32|64))\(/gu,
|
||||
["src/native/metadata/BinaryContainer.ts"],
|
||||
["src/domain/binaryContainer.ts"],
|
||||
);
|
||||
|
||||
// An input fault is a ParseFailureError; a broken internal assumption is a
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"src/browser/WebSourceMapFetcher.ts": 1,
|
||||
"src/captures/parseFieldDiscovery.ts": 1,
|
||||
"src/firmware/devicetree/DevicetreeParser.ts": 1,
|
||||
"src/domain/firmware/devicetreeParser.ts": 1,
|
||||
"src/signals/SigrokRecordingProvider.ts": 1,
|
||||
"src/signals/parseDecoderDiscovery.ts": 1,
|
||||
"src/v8/V8CodeCache.errors.ts": 1
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
"src/artifacts/fit/FitStructure.ts": 3,
|
||||
"src/artifacts/nodeSea/NodeSeaBlob.ts": 4,
|
||||
"src/artifacts/nodeSea/NodeSeaLocation.ts": 2,
|
||||
"src/artifacts/pe/PeResourceLayout.ts": 3,
|
||||
"src/artifacts/pe/PeResourceParser.ts": 11,
|
||||
"src/artifacts/pe/PeResourceTreeFacts.ts": 9,
|
||||
"src/artifacts/pyinstaller/CArchiveLayout.ts": 8,
|
||||
"src/artifacts/pyinstaller/PyzArchive.ts": 1,
|
||||
"src/browser/PngVisualDiff.ts": 7,
|
||||
@@ -45,6 +48,7 @@
|
||||
"src/domain/elfRelocation.ts": 6,
|
||||
"src/domain/elfSectionHeader.ts": 6,
|
||||
"src/domain/elfSymbol.ts": 8,
|
||||
"src/domain/firmware/devicetreeParser.ts": 4,
|
||||
"src/domain/firmware/fitImage.ts": 1,
|
||||
"src/domain/gamecubeDol.ts": 6,
|
||||
"src/domain/godotPckFormat.ts": 5,
|
||||
@@ -83,7 +87,6 @@
|
||||
"src/dotnet/ManagedPeReader.ts": 5,
|
||||
"src/dotnet/ManagedTypeDefinitionRows.ts": 1,
|
||||
"src/erlang/BeamParser.ts": 3,
|
||||
"src/firmware/devicetree/DevicetreeParser.ts": 4,
|
||||
"src/flutter/DartElf.ts": 2,
|
||||
"src/ghidra/GhidraLoadImageValues.ts": 1,
|
||||
"src/ghidra/extensions/GhidraExtensions.ts": 1,
|
||||
@@ -123,9 +126,6 @@
|
||||
"src/native/pe/PeCertificateAsn1.ts": 2,
|
||||
"src/native/pe/PeCertificateParser.ts": 3,
|
||||
"src/native/pe/PeLoadConfigParser.ts": 7,
|
||||
"src/native/pe/PeResourceLayout.ts": 3,
|
||||
"src/native/pe/PeResourceParser.ts": 11,
|
||||
"src/native/pe/PeResourceTreeFacts.ts": 9,
|
||||
"src/native/pwndbg/CoreFileMappingAuthority.ts": 1,
|
||||
"src/native/pwntools/PwntoolsRecordedCrashProvider.ts": 1,
|
||||
"src/native/pwntools/RecordedCrashSourceBindings.ts": 6,
|
||||
|
||||
@@ -3,8 +3,8 @@ import { expect, it } from "vitest";
|
||||
import { PeResourcesService } from "./PeResourcesService.js";
|
||||
import { PE_RESOURCES_PROVIDER } from "../../domain/investigationProviders.js";
|
||||
import { inspectPeResourcesInputSchema } from "../../domain/native/peResources.js";
|
||||
import { parsePeResources } from "../../native/pe/PeResourceParser.js";
|
||||
import { peResourceFixture } from "../../native/pe/PeResources.fixture.js";
|
||||
import { parsePeResources } from "../../artifacts/pe/PeResourceParser.js";
|
||||
import { peResourceFixture } from "../../artifacts/pe/PeResources.fixture.js";
|
||||
import { ok } from "../../domain/result.js";
|
||||
import { parseEvidence } from "../../domain/evidence.js";
|
||||
import {
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
import {
|
||||
cells,
|
||||
devicetreeFixture,
|
||||
} from "../firmware/devicetree/Devicetree.fixture.js";
|
||||
} from "../domain/firmware/devicetree.fixture.js";
|
||||
import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js";
|
||||
import { phaseGate } from "../../tests/support/lifecycleHarness.js";
|
||||
import { scanCanonicalArtifactInventory } from "../../tests/fixtures/artifactInventory.js";
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { BinaryResourceFailure } from "../domain/binaryContainer.js";
|
||||
import { decodeLz4Block } from "./Lz4Block.js";
|
||||
it("decodes overlapping matches by repeating the newly produced pattern", async () => {
|
||||
// The initial match is the same overlap shape observed in nvcc 12.9 speed-mode PTX.
|
||||
const input = Buffer.from("3c0a2f2f0300504142434445", "hex");
|
||||
expect((await decodeLz4Block(input, 24)).toString()).toBe(
|
||||
expect((await decodeLz4Block(input, 24, 24)).toString()).toBe(
|
||||
"\n//".repeat(6) + "\nABCDE",
|
||||
);
|
||||
});
|
||||
it.each(["10000000", "10000100", "f0ff", "f001", "00"])(
|
||||
"rejects malformed or mismatched block %s",
|
||||
async (hex) => {
|
||||
await expect(decodeLz4Block(Buffer.from(hex, "hex"), 8)).rejects.toThrow();
|
||||
await expect(
|
||||
decodeLz4Block(Buffer.from(hex, "hex"), 8, 8),
|
||||
).rejects.toThrow();
|
||||
},
|
||||
);
|
||||
it("preserves an already-aborted caller's cancellation", async () => {
|
||||
const signal = AbortSignal.abort("caller stopped");
|
||||
await expect(
|
||||
decodeLz4Block(Buffer.from("10aa", "hex"), 1, signal),
|
||||
decodeLz4Block(Buffer.from("10aa", "hex"), 1, 1, signal),
|
||||
).rejects.toMatchObject({ reason: "cancelled" });
|
||||
});
|
||||
it("refuses a declared length above the caller's output budget", async () => {
|
||||
const refusal = decodeLz4Block(Buffer.from("10aa", "hex"), 9, 8);
|
||||
await expect(refusal).rejects.toBeInstanceOf(BinaryResourceFailure);
|
||||
await expect(refusal).rejects.toMatchObject({ maximum_bytes: 8 });
|
||||
});
|
||||
@@ -1,21 +1,30 @@
|
||||
import { scheduler } from "node:timers/promises";
|
||||
import { assertArtifactReadActive } from "../artifacts/ArtifactFileOperation.js";
|
||||
import { GPU_OBJECT_BYTES, rejectGpu } from "./GpuSource.js";
|
||||
import { BinaryResourceFailure } from "../native/metadata/BinaryContainer.js";
|
||||
/** Raw LZ4 blocks used by CUDA's 0x2000 mode; not an LZ4 frame decoder. */
|
||||
import { assertArtifactReadActive } from "./ArtifactFileOperation.js";
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../domain/binaryContainer.js";
|
||||
const rejectLz4 = (message: string): never => {
|
||||
throw new BinaryFormatFailure("malformed", message);
|
||||
};
|
||||
/**
|
||||
* Raw LZ4 blocks (CUDA's 0x2000 mode, UnityFS blocks); not an LZ4 frame
|
||||
* decoder. `maximumBytes` is the caller's decoded-output budget.
|
||||
*/
|
||||
export const decodeLz4Block = async (
|
||||
input: Buffer,
|
||||
expected: number,
|
||||
maximumBytes: number,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Buffer> => {
|
||||
if (
|
||||
!Number.isSafeInteger(expected) ||
|
||||
expected < 0 ||
|
||||
expected > GPU_OBJECT_BYTES
|
||||
expected > maximumBytes
|
||||
)
|
||||
throw new BinaryResourceFailure(
|
||||
"structure",
|
||||
GPU_OBJECT_BYTES,
|
||||
maximumBytes,
|
||||
"LZ4 decoded length exceeds the object budget",
|
||||
);
|
||||
const output = Buffer.alloc(expected);
|
||||
@@ -23,7 +32,7 @@ export const decodeLz4Block = async (
|
||||
write = 0,
|
||||
checkpoint = 0;
|
||||
const byte = (): number => {
|
||||
if (read >= input.length) return rejectGpu("Truncated LZ4 block");
|
||||
if (read >= input.length) return rejectLz4("Truncated LZ4 block");
|
||||
return input[read++]!;
|
||||
};
|
||||
const length = (nibble: number, remaining: number): number => {
|
||||
@@ -33,11 +42,11 @@ export const decodeLz4Block = async (
|
||||
do {
|
||||
extra = byte();
|
||||
if (extra > remaining - total)
|
||||
rejectGpu("LZ4 length exceeds its declared output");
|
||||
rejectLz4("LZ4 length exceeds its declared output");
|
||||
total += extra;
|
||||
} while (extra === 255);
|
||||
}
|
||||
if (total > remaining) rejectGpu("LZ4 length exceeds its declared output");
|
||||
if (total > remaining) rejectLz4("LZ4 length exceeds its declared output");
|
||||
return total;
|
||||
};
|
||||
while (read < input.length) {
|
||||
@@ -49,14 +58,14 @@ export const decodeLz4Block = async (
|
||||
const token = byte();
|
||||
const literals = length(token >>> 4, expected - write);
|
||||
if (literals > input.length - read)
|
||||
rejectGpu("LZ4 literals exceed their encoded input");
|
||||
rejectLz4("LZ4 literals exceed their encoded input");
|
||||
input.copy(output, write, read, read + literals);
|
||||
read += literals;
|
||||
write += literals;
|
||||
if (read === input.length) break;
|
||||
const distance = byte() | (byte() << 8);
|
||||
if (distance === 0 || distance > write)
|
||||
rejectGpu("LZ4 match has an invalid backward distance");
|
||||
rejectLz4("LZ4 match has an invalid backward distance");
|
||||
const match = length(token & 15, expected - write - 4) + 4;
|
||||
let copied = Math.min(distance, match);
|
||||
output.copy(output, write, write - distance, write - distance + copied);
|
||||
@@ -69,7 +78,7 @@ export const decodeLz4Block = async (
|
||||
write += match;
|
||||
}
|
||||
if (write !== expected)
|
||||
rejectGpu("LZ4 decoded length disagrees with its declaration");
|
||||
rejectLz4("LZ4 decoded length disagrees with its declaration");
|
||||
assertArtifactReadActive(signal);
|
||||
return output;
|
||||
};
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
nodeSeaUniversal,
|
||||
} from "./nodeSea/NodeSea.fixture.js";
|
||||
import { elfNote, elfNoteFixture } from "../native/elf/ElfNotes.fixture.js";
|
||||
import { peResourceFixture } from "../native/pe/PeResources.fixture.js";
|
||||
import { peResourceFixture } from "./pe/PeResources.fixture.js";
|
||||
import { locateNodeSea } from "./nodeSea/NodeSeaLocation.js";
|
||||
import { MAX_INSPECT_PE_FILE_BYTES } from "../domain/native/peResources.js";
|
||||
import { openRegularFile } from "../filesystem/RegularFile.js";
|
||||
|
||||
@@ -2,11 +2,11 @@ import { Budget } from "../domain/budget.js";
|
||||
import type { FileHandle } from "node:fs/promises";
|
||||
import { ArtifactReaderFailure } from "./ArtifactReader.js";
|
||||
import { readArtifactFileBytes } from "./ArtifactFileRange.js";
|
||||
import { decodeLz4Block } from "../gpu/Lz4Block.js";
|
||||
import { decodeLz4Block } from "./Lz4Block.js";
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { assertArtifactReadActive } from "./ArtifactFileOperation.js";
|
||||
import { setImmediate } from "node:timers/promises";
|
||||
import {
|
||||
@@ -229,7 +229,12 @@ export const decodeUnityFsLz4 = async (
|
||||
signal?: AbortSignal,
|
||||
): Promise<Buffer> => {
|
||||
try {
|
||||
return await decodeLz4Block(encoded, expected, signal);
|
||||
return await decodeLz4Block(
|
||||
encoded,
|
||||
expected,
|
||||
MAX_BLOCK_UNCOMPRESSED_BYTES,
|
||||
signal,
|
||||
);
|
||||
} catch (cause: unknown) {
|
||||
if (cause instanceof ArtifactReaderFailure) throw cause;
|
||||
if (cause instanceof BinaryResourceFailure)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BinaryReader } from "../native/metadata/BinaryContainer.js";
|
||||
import { BinaryReader } from "../domain/binaryContainer.js";
|
||||
import {
|
||||
apkSigningPairEnd,
|
||||
APK_SIGNING_BLOCK_MAX_PAIRS,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { elfNote, elfNoteFixture } from "../../native/elf/ElfNotes.fixture.js";
|
||||
import { peResourceFixture } from "../../native/pe/PeResources.fixture.js";
|
||||
import { peResourceFixture } from "../pe/PeResources.fixture.js";
|
||||
|
||||
// https://github.com/denoland/deno/blob/v2.9.8/cli/lib/standalone/binary.rs
|
||||
// declares this section marker.
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
MAX_INSPECT_ELF_NOTE_FILE_BYTES,
|
||||
} from "../../domain/native/elfNotes.js";
|
||||
import { MAX_INSPECT_PE_FILE_BYTES } from "../../domain/native/peResources.js";
|
||||
import { peResourceFixture } from "../../native/pe/PeResources.fixture.js";
|
||||
import { peResourceFixture } from "../pe/PeResources.fixture.js";
|
||||
import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js";
|
||||
import { scanCanonicalArtifactInventory } from "../../../tests/fixtures/artifactInventory.js";
|
||||
import { artifactFormatDescriptor } from "../artifactFormats.js";
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
} from "../apple/MachoLoadCommandReader.js";
|
||||
import { abortIfNeeded } from "../ArtifactHash.js";
|
||||
import { ArtifactReaderFailure } from "../ArtifactReader.js";
|
||||
import { locatePeResourcePayloads } from "../../native/pe/PeResourceLayout.js";
|
||||
import { locatePeResourcePayloads } from "../pe/PeResourceLayout.js";
|
||||
import { DENO_SECTION_MAGIC } from "./DenoSectionLayout.js";
|
||||
|
||||
const CPU_TYPE_ARM64 = 0x0100000c;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
devicetreeFixture,
|
||||
dtString,
|
||||
type FixtureNode,
|
||||
} from "../../firmware/devicetree/Devicetree.fixture.js";
|
||||
} from "../../domain/firmware/devicetree.fixture.js";
|
||||
|
||||
/** One /images node; `hashes` names algorithms whose values the fixture computes. */
|
||||
export interface FitFixtureImage {
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
devicetreeFixture,
|
||||
dtString,
|
||||
type FixtureNode,
|
||||
} from "../../firmware/devicetree/Devicetree.fixture.js";
|
||||
} from "../../domain/firmware/devicetree.fixture.js";
|
||||
import {
|
||||
FIT_EMBEDDED,
|
||||
FIT_KERNEL,
|
||||
|
||||
@@ -18,8 +18,8 @@ import {
|
||||
import {
|
||||
DevicetreeLimitFailure,
|
||||
parseDevicetree,
|
||||
} from "../../firmware/devicetree/DevicetreeParser.js";
|
||||
import { BinaryFormatFailure } from "../../native/metadata/BinaryContainer.js";
|
||||
} from "../../domain/firmware/devicetreeParser.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import { ArtifactReaderFailure } from "../ArtifactReader.js";
|
||||
import { strictUtf8Decoder } from "../../domain/strictUtf8.js";
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
esp8266Image,
|
||||
espImage,
|
||||
} from "../../../tests/fixtures/espImage.js";
|
||||
import { devicetreeFixture } from "../../firmware/devicetree/Devicetree.fixture.js";
|
||||
import { devicetreeFixture } from "../../domain/firmware/devicetree.fixture.js";
|
||||
import { fitFixture } from "../fit/FitImage.fixture.js";
|
||||
|
||||
it("joins only observed PE signature bytes across stream chunks", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { elfNote, elfNoteFixture } from "../../native/elf/ElfNotes.fixture.js";
|
||||
import { peResourceFixture } from "../../native/pe/PeResources.fixture.js";
|
||||
import { peResourceFixture } from "../pe/PeResources.fixture.js";
|
||||
|
||||
/** Node 24 SEA blob magic: https://github.com/nodejs/node/blob/v24.12.0/src/node_sea.h */
|
||||
export const NODE_SEA_FIXTURE_MAGIC = 0x143da20;
|
||||
|
||||
@@ -10,11 +10,11 @@ import { readElfProgramHeader } from "../../domain/elfProgramHeader.js";
|
||||
import { readElfRawTableDeclarations } from "../../domain/elfRawTableDeclarations.js";
|
||||
import { createHash } from "node:crypto";
|
||||
import { constants as bufferConstants } from "node:buffer";
|
||||
import { parsePeResources } from "../../native/pe/PeResourceParser.js";
|
||||
import { parsePeResources } from "../pe/PeResourceParser.js";
|
||||
import {
|
||||
hasPeResourceName,
|
||||
readPeResourceLayout,
|
||||
} from "../../native/pe/PeResourceLayout.js";
|
||||
} from "../pe/PeResourceLayout.js";
|
||||
import {
|
||||
MAX_INSPECT_PE_FILE_BYTES,
|
||||
MAX_INSPECT_PE_DIRECTORY_ENTRIES,
|
||||
|
||||
@@ -7,10 +7,10 @@ import {
|
||||
readPeResourceNameFacts,
|
||||
} from "./PeResourceTreeFacts.js";
|
||||
import { parseMzHeaderEvidence } from "../../domain/dosMz.js";
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import { readPeCoffHeader } from "../../domain/peCoffHeader.js";
|
||||
import { readPeSectionHeader } from "../../domain/peSectionHeader.js";
|
||||
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
||||
import { ArtifactReaderFailure } from "../ArtifactReader.js";
|
||||
import {
|
||||
readPeOptionalHeaderStructure,
|
||||
type PeOptionalHeaderFailure,
|
||||
@@ -1,5 +1,5 @@
|
||||
import { dosMz, nonPeWindowsMz } from "../../domain/binaryTarget.fixture.js";
|
||||
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
||||
import { ArtifactReaderFailure } from "../ArtifactReader.js";
|
||||
import { createHash } from "node:crypto";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
} from "./PeResourceTreeFacts.js";
|
||||
import { createHash } from "node:crypto";
|
||||
import { setImmediate } from "node:timers/promises";
|
||||
import { assertArtifactReadActive } from "../../artifacts/ArtifactFileOperation.js";
|
||||
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
||||
import { assertArtifactReadActive } from "../ArtifactFileOperation.js";
|
||||
import { ArtifactReaderFailure } from "../ArtifactReader.js";
|
||||
import type { ArtifactLimitBoundary } from "../../domain/artifactOperationError.js";
|
||||
import { jsonParts } from "../../domain/jsonSerialization.js";
|
||||
import type {
|
||||
File renamed without changes.
File renamed without changes.
@@ -2,9 +2,9 @@ import {
|
||||
resolveMappedFileOffset,
|
||||
type FileMapping,
|
||||
type ZeroFillMapping,
|
||||
} from "../../domain/virtualFileMapping.js";
|
||||
import type { PeDataDirectory } from "../../domain/peOptionalHeader.js";
|
||||
import { decodeLimit, ParseFailureError } from "../../domain/parseFailure.js";
|
||||
} from "./virtualFileMapping.js";
|
||||
import type { PeDataDirectory } from "./peOptionalHeader.js";
|
||||
import { decodeLimit, ParseFailureError } from "./parseFailure.js";
|
||||
|
||||
/** Native container facts a format failure can name. */
|
||||
interface BinaryFormatFailureFacts {
|
||||
File renamed without changes.
+3
-3
@@ -3,14 +3,14 @@ import { createHash } from "node:crypto";
|
||||
import {
|
||||
devicetreeSchema,
|
||||
inspectDevicetreeInputSchema,
|
||||
} from "../../domain/firmware/devicetree.js";
|
||||
import { DevicetreeLimitFailure, parseDevicetree } from "./DevicetreeParser.js";
|
||||
} from "./devicetree.js";
|
||||
import { DevicetreeLimitFailure, parseDevicetree } from "./devicetreeParser.js";
|
||||
import {
|
||||
cells,
|
||||
devicetreeFixture,
|
||||
emptyStringsAtReservationBoundaryFixture,
|
||||
type FixtureNode,
|
||||
} from "./Devicetree.fixture.js";
|
||||
} from "./devicetree.fixture.js";
|
||||
const parse = (b: Buffer, limits = {}) =>
|
||||
parseDevicetree(
|
||||
b,
|
||||
+2
-5
@@ -1,8 +1,5 @@
|
||||
import type {
|
||||
Devicetree,
|
||||
InspectDevicetreeInput,
|
||||
} from "../../domain/firmware/devicetree.js";
|
||||
import { BinaryFormatFailure } from "../../native/metadata/BinaryContainer.js";
|
||||
import type { Devicetree, InspectDevicetreeInput } from "./devicetree.js";
|
||||
import { BinaryFormatFailure } from "../binaryContainer.js";
|
||||
|
||||
export class DevicetreeLimitFailure extends Error {
|
||||
constructor(
|
||||
@@ -26,7 +26,10 @@ import {
|
||||
} from "../../domain/firmware/devicetree.js";
|
||||
import { err, ok } from "../../domain/result.js";
|
||||
import { DEVICETREE_PROVIDER } from "../../domain/investigationProviders.js";
|
||||
import { DevicetreeLimitFailure, parseDevicetree } from "./DevicetreeParser.js";
|
||||
import {
|
||||
DevicetreeLimitFailure,
|
||||
parseDevicetree,
|
||||
} from "../../domain/firmware/devicetreeParser.js";
|
||||
|
||||
const OPERATION = "inspect_devicetree";
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
imageFileMappings,
|
||||
isZeroFilledSpan,
|
||||
type BinaryContainer,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { readBinaryContainer } from "../native/metadata/readBinaryContainer.js";
|
||||
import {
|
||||
goAnalysisBudgets,
|
||||
|
||||
@@ -40,7 +40,7 @@ import { fixedAllowanceOptions } from "../domain/fixedAllowanceRemediation.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import { readGoBinaryImage, type GoBinaryImage } from "./GoBinaryImage.js";
|
||||
import { requireSelectedNativeImage } from "../native/metadata/MachoSliceSelection.js";
|
||||
import { BinaryResourceFailure } from "../native/metadata/BinaryContainer.js";
|
||||
import { BinaryResourceFailure } from "../domain/binaryContainer.js";
|
||||
|
||||
const OPERATION = "inspect_go_binary";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
BinaryReader,
|
||||
mappedFileOffset,
|
||||
type BinaryContainer,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { firstKeyed, keyedBy, uniqueKeyed } from "../domain/keyedCollection.js";
|
||||
|
||||
export interface GoBuildInfoSearchRange extends FileMapping {
|
||||
|
||||
@@ -5,7 +5,7 @@ import type {
|
||||
BinaryContainer,
|
||||
ImageSection,
|
||||
LoadRegion,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { createGoRodataStringFixture } from "../../tests/fixtures/go/rodataStringImage.js";
|
||||
import { readGoBinaryImage } from "./GoBinaryImage.js";
|
||||
import { recoverGoStringLiterals } from "./GoStringLiterals.js";
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
type BinaryContainer,
|
||||
type FileMappingIndex,
|
||||
type LoadRegion,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
|
||||
const MAX_REJECTED_SLICE_CACHE = 4096;
|
||||
const PE_MEM_READ = 0x40000000;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { decode } from "@msgpack/msgpack";
|
||||
import {
|
||||
BinaryResourceFailure,
|
||||
BinaryFormatFailure,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { rejectGpu } from "./GpuSource.js";
|
||||
|
||||
export const AMD_METADATA_BYTES = 8 * 1024 * 1024;
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { GpuObject } from "../domain/gpu/gpuCodeObjects.js";
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { assertArtifactReadActive } from "../artifacts/ArtifactFileOperation.js";
|
||||
import {
|
||||
gpuCount,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
BinaryReader,
|
||||
BinaryResourceFailure,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { GPU_OBJECT_BYTES, GPU_REPORT_BYTES, rejectGpu } from "./GpuSource.js";
|
||||
import { Budget } from "../domain/budget.js";
|
||||
import { jsonValueByteLength } from "../domain/jsonValueByteLength.js";
|
||||
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
artifactFileCompletion,
|
||||
} from "../artifacts/ArtifactFileOperation.js";
|
||||
import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";
|
||||
import { BinaryResourceFailure } from "../native/metadata/BinaryContainer.js";
|
||||
import { BinaryResourceFailure } from "../domain/binaryContainer.js";
|
||||
import {
|
||||
GpuFileSource,
|
||||
gpuCount,
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
BinaryReader,
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import {
|
||||
readElfSectionDirectory,
|
||||
type NativeSection,
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
isBinaryStringReadLimit,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import {
|
||||
readElfSectionDirectory,
|
||||
readPeSectionDirectory,
|
||||
|
||||
@@ -2,8 +2,8 @@ import { nodeCodecResult } from "../compression/NodeCodecResult.js";
|
||||
import { constants, inflate, zstdDecompress } from "node:zlib";
|
||||
import { promisify } from "node:util";
|
||||
import { assertArtifactReadActive } from "../artifacts/ArtifactFileOperation.js";
|
||||
import { decodeLz4Block } from "./Lz4Block.js";
|
||||
import { rejectGpu } from "./GpuSource.js";
|
||||
import { decodeLz4Block } from "../artifacts/Lz4Block.js";
|
||||
import { GPU_OBJECT_BYTES, rejectGpu } from "./GpuSource.js";
|
||||
const unzip = promisify(inflate);
|
||||
const unzstd = promisify(zstdDecompress);
|
||||
/** Completed codec bytes and their encoded extent share one completion owner. */
|
||||
@@ -47,7 +47,8 @@ export const decodeGpuPayload = async (
|
||||
signal?: AbortSignal,
|
||||
): Promise<Buffer> => {
|
||||
assertArtifactReadActive(signal);
|
||||
if (compression === "lz4") return decodeLz4Block(bytes, expected, signal);
|
||||
if (compression === "lz4")
|
||||
return decodeLz4Block(bytes, expected, GPU_OBJECT_BYTES, signal);
|
||||
const decoded = await decodeGpuPayloadStream(
|
||||
bytes,
|
||||
compression,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import type {
|
||||
NativeReadRequest,
|
||||
NativeSectionDirectory,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import type { GpuKernel } from "../domain/gpu/gpuCodeObjects.js";
|
||||
import { GPU_REPORT_BYTES, rejectGpu } from "./GpuSource.js";
|
||||
interface Token {
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
isZeroFilledSpan,
|
||||
type BinaryContainer,
|
||||
type FileMappingIndex,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { readBinaryContainer } from "../native/metadata/readBinaryContainer.js";
|
||||
import {
|
||||
requireSelectedNativeImage,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
mappedFileOffset,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { Il2cppBinaryFormatFailure } from "./Il2cppBinaryFormat.js";
|
||||
import {
|
||||
isMapped,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";
|
||||
import { appleDispatchMetadataFailure } from "./AppleDispatchMetadata.js";
|
||||
import { BinaryFormatFailure } from "./metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../domain/binaryContainer.js";
|
||||
|
||||
it.each(["malformed", "unsupported"] as const)(
|
||||
"keeps an explicit %s metadata refusal target-specific",
|
||||
|
||||
@@ -48,7 +48,7 @@ import { readBoundedFileBytes } from "../process/BoundedFileBytes.js";
|
||||
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
||||
import { pushDispatchCoverage } from "./AppleDispatchCoverage.js";
|
||||
import { parsePointerFixupsSteps } from "./AppleMachoFixups.js";
|
||||
import { BinaryFormatFailure } from "./metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../domain/binaryContainer.js";
|
||||
import { parseMachoLayout } from "./AppleMachoSelection.js";
|
||||
import {
|
||||
selectMachoSlice,
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from "../artifacts/apple/MachoImage.fixture.js";
|
||||
import { readMachoImage } from "../artifacts/apple/MachoLoadCommandReader.js";
|
||||
import { readMachoImage as readMachoMetadataImage } from "./metadata/MachoImage.js";
|
||||
import { BinaryFormatFailure } from "./metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../domain/binaryContainer.js";
|
||||
import { layoutFor, MachoSliceRefused } from "./AppleMachoSelection.fixture.js";
|
||||
import {
|
||||
selectMachoSlice,
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
createFileMappingIndex,
|
||||
} from "./metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
|
||||
import type { FixupCommands } from "./AppleMachoFixups.js";
|
||||
import { decodeMachoFixedName, decodeMachoName } from "./AppleMachoNames.js";
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Section } from "./AppleMachoSelection.js";
|
||||
import type { ObjcDispatchReaders } from "./AppleObjcDispatchFacets.js";
|
||||
import { readObjcPropertiesOf } from "./AppleObjcProperties.js";
|
||||
import { issue, type DecodeIssue } from "./AppleDispatchDecodeFacts.js";
|
||||
import { BinaryFormatFailure } from "./metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../domain/binaryContainer.js";
|
||||
import type { ObjcProtocolListResult } from "./AppleObjcProtocols.js";
|
||||
|
||||
const CLASS_SYMBOL = /^_OBJC_(?:META)?CLASS_\$_(.+)$/u;
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import type { Segment, Section } from "./AppleMachoSelection.js";
|
||||
import { boundClassName, decodeObjcCategories } from "./AppleObjcCategories.js";
|
||||
import { readObjcPropertiesOf } from "./AppleObjcProperties.js";
|
||||
import { BinaryFormatFailure } from "./metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../domain/binaryContainer.js";
|
||||
import type { DecodeIssue } from "./AppleDispatchDecodeFacts.js";
|
||||
import { createObjcProtocolReader } from "./AppleObjcProtocols.js";
|
||||
import type {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
import type { ObjcSwiftMetadata } from "../domain/native/objcSwiftMetadata.js";
|
||||
import type { PointerResolution } from "./AppleMachoFixups.js";
|
||||
import type { Segment, Section } from "./AppleMachoSelection.js";
|
||||
import { BinaryFormatFailure } from "./metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../domain/binaryContainer.js";
|
||||
import { issue, type FacetDecodeFacts } from "./AppleDispatchDecodeFacts.js";
|
||||
import {
|
||||
decodeSwiftConformanceTypeReference,
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
BinaryResourceFailure,
|
||||
isBinaryStringReadLimit,
|
||||
createFileMappingIndex,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
readElfPointerRelocationsSteps,
|
||||
ElfPointerRelocationFailure,
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
elfObjectTypeName,
|
||||
gnuNoteTypeName,
|
||||
} from "../../domain/native/elfNotes.js";
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import { decodeLimit, ParseFailureError } from "../../domain/parseFailure.js";
|
||||
import { decodeElfSectionNameTable } from "../metadata/ElfSectionNameTable.js";
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from "../../domain/native/elfUnwindRanges.js";
|
||||
import { err, ok } from "../../domain/result.js";
|
||||
import { ELF_UNWIND_RANGES_PROVIDER } from "../../domain/investigationProviders.js";
|
||||
import { BinaryResourceFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryResourceFailure } from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
ElfUnwindSymbolTextFailure,
|
||||
parseElfUnwindRanges,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
kernelModuleSchema,
|
||||
MODULE_SIGNATURE_MAGIC,
|
||||
} from "../../domain/native/kernelModule.js";
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
compressedKernelModuleContainer,
|
||||
kernelModuleFixture,
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import type {
|
||||
ImageSection,
|
||||
BinaryContainer,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { readElfImage } from "../metadata/ElfImage.js";
|
||||
import { kernelCompressionCodecAt } from "./KernelCompressionCodec.js";
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
} from "../../domain/native/kernelModule.js";
|
||||
import { err, ok } from "../../domain/result.js";
|
||||
import { KERNEL_MODULE_PROVIDER } from "../../domain/investigationProviders.js";
|
||||
import { BinaryResourceFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryResourceFailure } from "../../domain/binaryContainer.js";
|
||||
import { parseKernelModule } from "./KernelModuleParser.js";
|
||||
|
||||
const OPERATION = "inspect_kernel_module";
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
peExportImage,
|
||||
} from "../../../tests/fixtures/binaryDiagnostics/nativeExports.js";
|
||||
import * as nativeExportContracts from "../../domain/native/nativeExports.js";
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
parseNativeExports,
|
||||
parseNativeExportsSteps,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
mappedFileOffset,
|
||||
imageFileMappings,
|
||||
readMappedCString,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { architectureForElfMachine } from "../metadata/ElfImage.js";
|
||||
import { readElfStringBytes } from "../metadata/ElfStringTable.js";
|
||||
import { readElfSymbol } from "../../domain/elfSymbol.js";
|
||||
|
||||
@@ -34,7 +34,7 @@ import { NATIVE_EXPORTS_PROVIDER } from "../../domain/investigationProviders.js"
|
||||
import {
|
||||
BinaryResourceFailure,
|
||||
binaryResourceAllowance,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
NATIVE_EXPORT_LIMITS,
|
||||
type NativeExportLimit,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
PE_HARDENING_PROPERTIES,
|
||||
type BinaryHardeningRow,
|
||||
} from "../../domain/native/binaryHardening.js";
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import { readElfImage } from "../metadata/ElfImage.js";
|
||||
import { readMachoImage } from "../metadata/MachoImage.js";
|
||||
import {
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
import { ProviderAdapterError } from "../../domain/providerAdapterError.js";
|
||||
import { err, ok } from "../../domain/result.js";
|
||||
import { BINARY_HARDENING_PROVIDER } from "../../domain/investigationProviders.js";
|
||||
import { BinaryResourceFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryResourceFailure } from "../../domain/binaryContainer.js";
|
||||
import { readElfHardening } from "./ElfHardening.js";
|
||||
import { readMachoHardening } from "./MachoHardening.js";
|
||||
import { readPeHardening } from "./PeHardening.js";
|
||||
|
||||
@@ -40,7 +40,7 @@ import {
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
ELF_PT_GNU_PROPERTY,
|
||||
ELF_PT_GNU_RELRO,
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
MAX_BINARY_HARDENING_TABLE_ENTRIES,
|
||||
} from "../../domain/native/binaryHardening.js";
|
||||
import { assertArtifactReadActive } from "../../artifacts/ArtifactFileOperation.js";
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import { readMachoEncryption } from "../../artifacts/apple/MachoEncryptionReader.js";
|
||||
import {
|
||||
frameLoadCommands,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { peSubjectArchitecture } from "../../domain/peMachine.js";
|
||||
import type { PeDataDirectory } from "../../domain/peOptionalHeader.js";
|
||||
import { readPeImage } from "../metadata/PeImage.js";
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
createFileMappingIndex,
|
||||
mappedFileOffset,
|
||||
type FileMappingIndex,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { readElfDirectoryFromBuffer } from "../metadata/NativeSectionDirectory.js";
|
||||
import type { NativeSection } from "../metadata/NativeSectionDirectory.js";
|
||||
import {
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
BinaryMappingFailure,
|
||||
createFileMappingIndex,
|
||||
type ImageSection,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { readMachoImage } from "../metadata/MachoImage.js";
|
||||
import {
|
||||
finishInitializerReport,
|
||||
|
||||
@@ -7,9 +7,9 @@ const mapping = vi.hoisted(() => ({
|
||||
scans: vi.fn(),
|
||||
indexes: vi.fn(),
|
||||
}));
|
||||
vi.mock("../metadata/BinaryContainer.js", async (importOriginal) => {
|
||||
vi.mock("../../domain/binaryContainer.js", async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import("../metadata/BinaryContainer.js")>();
|
||||
await importOriginal<typeof import("../../domain/binaryContainer.js")>();
|
||||
return {
|
||||
...actual,
|
||||
mappedFileOffset: (
|
||||
@@ -48,7 +48,7 @@ import {
|
||||
} from "../../domain/native/nativeInitializers.js";
|
||||
import { buildAddressRangeIndex } from "./addressRangeIndex.js";
|
||||
import { InitializerNotes } from "./initializerNotes.js";
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
||||
|
||||
const artifact = (bytes: Buffer) => ({
|
||||
|
||||
@@ -33,7 +33,7 @@ import { NATIVE_INITIALIZERS_PROVIDER } from "../../domain/investigationProvider
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
BinaryResourceFailure,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { ElfPointerRelocationFailure } from "../metadata/ElfPointerRelocations.js";
|
||||
import { requireSelectedNativeImage } from "../metadata/MachoSliceSelection.js";
|
||||
import { readElfInitializers } from "./ElfInitializers.js";
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
mappedFileOffset,
|
||||
readMappedCString,
|
||||
type BinaryContainer,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
|
||||
it("preserves representable offsets for invalid file ranges", () => {
|
||||
const reader = new BinaryReader(Buffer.alloc(120), true, "elf");
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
type ElfDynamicSegment,
|
||||
type ImageSection,
|
||||
type LoadRegion,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { elfArchitecture } from "../../domain/elfFixedHeader.js";
|
||||
import { readElfDirectoryFromBuffer } from "./NativeSectionDirectory.js";
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
createFileMappingIndex,
|
||||
isZeroFilledSpan,
|
||||
type ElfDynamicSegment,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { ParseFailureError } from "../../domain/parseFailure.js";
|
||||
|
||||
/** The ParseFailure format of ELF loader pointer interpretation. */
|
||||
|
||||
@@ -2,7 +2,7 @@ import { expect, it } from "vitest";
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
isBinaryStringReadLimit,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { readElfStringBytes } from "./ElfStringTable.js";
|
||||
|
||||
it("preserves empty and non-UTF8 string-table bytes", () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { observeElfStringTableEntry } from "../../domain/elfStringTable.js";
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
binaryStringReadLimit,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
|
||||
/** Read exact string-table bytes; ELF does not prescribe a character encoding. */
|
||||
export const readElfStringBytes = (bytes: Buffer, offset: number): Buffer => {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
type BinaryContainer,
|
||||
type ImageSection,
|
||||
type LoadRegion,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
MachoLoadCommandCursor,
|
||||
readMachoLoadCommandDeclarations,
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
BinaryResourceFailure,
|
||||
declaredFileRange,
|
||||
type ElfDynamicSegment,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { decodeElfSectionNameTable } from "./ElfSectionNameTable.js";
|
||||
|
||||
/** A borrowed positional source. Drivers own admission, cancellation and file identity. */
|
||||
|
||||
@@ -3,7 +3,7 @@ import { readGoBinaryImage } from "../../go/GoBinaryImage.js";
|
||||
import { readPeImage } from "./PeImage.js";
|
||||
import { pe } from "../../domain/binaryTarget.fixture.js";
|
||||
import { parseMzHeaderEvidence } from "../../domain/dosMz.js";
|
||||
import { BinaryFormatFailure } from "./BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import { readBinaryContainer } from "./readBinaryContainer.js";
|
||||
import {
|
||||
createGoBinaryFixture,
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
BinaryReader,
|
||||
type BinaryContainer,
|
||||
type ImageSection,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
|
||||
const peHeaderOffset = (reader: BinaryReader): number => {
|
||||
const evidence = parseMzHeaderEvidence(reader.bytes);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
BinaryFormatFailure,
|
||||
type BinaryContainer,
|
||||
} from "./BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
classifyFatContainerIdentity,
|
||||
readFatContainerHeader,
|
||||
|
||||
@@ -23,7 +23,7 @@ import { ProviderAdapterError } from "../../domain/providerAdapterError.js";
|
||||
import {
|
||||
BinaryResourceFailure,
|
||||
binaryResourceAllowance,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
|
||||
interface PeBinaryInput {
|
||||
readonly path: string;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
PeCertificateAsn1Failure,
|
||||
readAsn1,
|
||||
} from "./PeCertificateAsn1.js";
|
||||
import { readPeHeaders } from "./PeResourceLayout.js";
|
||||
import { readPeHeaders } from "../../artifacts/pe/PeResourceLayout.js";
|
||||
|
||||
const fail = (message: string): never => {
|
||||
throw new ArtifactReaderFailure("format", message);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
projectSelectedArtifactFileFailure,
|
||||
projectOwnedArtifactIdentityFailure,
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
isBinaryFormatOrStringLimitFailure,
|
||||
createFileMappingIndex,
|
||||
imageFileMappings,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { readPeImage } from "../metadata/PeImage.js";
|
||||
import {
|
||||
MAX_INSPECT_PE_IMPORT_RETAINED_TEXT_BYTES,
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
BinaryResourceFailure,
|
||||
createFileMappingIndex,
|
||||
imageFileMappings,
|
||||
} from "../metadata/BinaryContainer.js";
|
||||
} from "../../domain/binaryContainer.js";
|
||||
import { readPeImage, type PeImage } from "../metadata/PeImage.js";
|
||||
import {
|
||||
guardFlagRecord,
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "../../domain/native/peResources.js";
|
||||
import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js";
|
||||
import { PeResourcesProvider } from "./PeResourcesProvider.js";
|
||||
import { peResourceFixture } from "./PeResources.fixture.js";
|
||||
import { peResourceFixture } from "../../artifacts/pe/PeResources.fixture.js";
|
||||
import { imageFileSizeRemediation } from "../../artifacts/StableArtifactFailure.js";
|
||||
|
||||
const inspect = async (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BinaryFormatFailure } from "../metadata/BinaryContainer.js";
|
||||
import { BinaryFormatFailure } from "../../domain/binaryContainer.js";
|
||||
import {
|
||||
imageFileSizeRemediation,
|
||||
projectSelectedArtifactFileFailure,
|
||||
@@ -36,7 +36,7 @@ import { PE_RESOURCES_PROVIDER } from "../../domain/investigationProviders.js";
|
||||
import {
|
||||
parsePeResources,
|
||||
PE_RESOURCE_METADATA_BYTES,
|
||||
} from "./PeResourceParser.js";
|
||||
} from "../../artifacts/pe/PeResourceParser.js";
|
||||
|
||||
/** Portable parser over one bounded, identity-checked regular file. */
|
||||
export class PeResourcesProvider implements PeResourcesPort {
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
} from "../domain/python/pythonPyc.js";
|
||||
import { Budget } from "../domain/budget.js";
|
||||
import { malformedInput, unsupportedInput } from "../domain/parseFailure.js";
|
||||
import { BinaryReader } from "../native/metadata/BinaryContainer.js";
|
||||
import { BinaryReader } from "../domain/binaryContainer.js";
|
||||
import {
|
||||
PYTHON_PYC_FORMAT,
|
||||
PythonPycResourceFailure,
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
BinaryResourceFailure,
|
||||
type BinaryContainer,
|
||||
type ImageSection,
|
||||
} from "../native/metadata/BinaryContainer.js";
|
||||
} from "../domain/binaryContainer.js";
|
||||
import { malformedInput, unsupportedInput } from "../domain/parseFailure.js";
|
||||
import { keyedBy, uniqueKeyed } from "../domain/keyedCollection.js";
|
||||
import { readBinaryContainer } from "../native/metadata/readBinaryContainer.js";
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
fitFixture,
|
||||
type FitFixtureImage,
|
||||
} from "../../../src/artifacts/fit/FitImage.fixture.js";
|
||||
import { dtString } from "../../../src/firmware/devicetree/Devicetree.fixture.js";
|
||||
import { dtString } from "../../../src/domain/firmware/devicetree.fixture.js";
|
||||
|
||||
type McpCall = Awaited<ReturnType<typeof connectLocalToolsMcp>>["call"];
|
||||
const image = (name: string, content: string): FitFixtureImage => ({
|
||||
|
||||
@@ -6,7 +6,7 @@ import { join } from "node:path";
|
||||
import { expect } from "vitest";
|
||||
import { toolContract } from "../../../src/contracts/toolContracts.js";
|
||||
import { peResourcesSchema } from "../../../src/domain/native/peResources.js";
|
||||
import { peResourceFixture } from "../../../src/native/pe/PeResources.fixture.js";
|
||||
import { peResourceFixture } from "../../../src/artifacts/pe/PeResources.fixture.js";
|
||||
import { connectLocalToolsMcp } from "../../fixtures/localToolsMcp.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { parseMcpToolError } from "../../fixtures/mcpToolError.js";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { fitFixture } from "../../src/artifacts/fit/FitImage.fixture.js";
|
||||
import {
|
||||
cells,
|
||||
dtString,
|
||||
} from "../../src/firmware/devicetree/Devicetree.fixture.js";
|
||||
} from "../../src/domain/firmware/devicetree.fixture.js";
|
||||
import { artifactComparisonResultSchema } from "../../src/domain/artifactComparison.js";
|
||||
import { artifactInspectionResultSchema } from "../../src/domain/artifactInspection.js";
|
||||
import { artifactInventoryResultSchema } from "../../src/domain/artifactGraph.js";
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
cells,
|
||||
devicetreeFixture,
|
||||
emptyStringsAtReservationBoundaryFixture,
|
||||
} from "../../src/firmware/devicetree/Devicetree.fixture.js";
|
||||
} from "../../src/domain/firmware/devicetree.fixture.js";
|
||||
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
||||
import { connectLocalToolsMcp } from "../fixtures/localToolsMcp.js";
|
||||
import { cliTest } from "../support/cli/cliFixture.js";
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import {
|
||||
cells,
|
||||
dtString,
|
||||
} from "../../src/firmware/devicetree/Devicetree.fixture.js";
|
||||
} from "../../src/domain/firmware/devicetree.fixture.js";
|
||||
import { parseEvidence } from "../../src/domain/evidence.js";
|
||||
import { artifactInspectionResultSchema } from "../../src/domain/artifactInspection.js";
|
||||
import {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { join } from "node:path";
|
||||
import { describe, expect } from "vitest";
|
||||
|
||||
import { toolContract } from "../../../src/contracts/toolContracts.js";
|
||||
import { peResourceFixture } from "../../../src/native/pe/PeResources.fixture.js";
|
||||
import { peResourceFixture } from "../../../src/artifacts/pe/PeResources.fixture.js";
|
||||
import { createGoBinaryFixture } from "../../fixtures/go/image.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
@@ -61,7 +61,7 @@ import {
|
||||
FIT_EMBEDDED,
|
||||
FIT_EXTERNAL,
|
||||
} from "../../../src/artifacts/fit/FitImage.fixture.js";
|
||||
import { devicetreeFixture } from "../../../src/firmware/devicetree/Devicetree.fixture.js";
|
||||
import { devicetreeFixture } from "../../../src/domain/firmware/devicetree.fixture.js";
|
||||
|
||||
it.each([
|
||||
[4000, false],
|
||||
|
||||
@@ -2,7 +2,7 @@ import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { BinaryResourceFailure } from "../../../src/native/metadata/BinaryContainer.js";
|
||||
import { BinaryResourceFailure } from "../../../src/domain/binaryContainer.js";
|
||||
import { readMachoLoadCommandTableHeader } from "../../../src/domain/apple/machoLoadCommands.js";
|
||||
import { readBinaryContainer } from "../../../src/native/metadata/readBinaryContainer.js";
|
||||
import { parseBinaryTarget } from "../../../src/application/BinaryTargetResolver.js";
|
||||
|
||||
Loaded 100 of 113 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user