mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
refactor(resources): move the ASAR header reader into src/resources and its node schema into domain (#11526)
This commit is contained in:
1 parent
1e663371a0
commit
e4f140417e
20 files changed
+48
-38
No files matched your search
@@ -16,7 +16,7 @@
|
||||
"apktool -> artifacts": 2,
|
||||
"artifacts -> dotnet": 3,
|
||||
"artifacts -> native": 1,
|
||||
"browser -> artifacts": 4,
|
||||
"browser -> artifacts": 2,
|
||||
"captures -> pcap": 2,
|
||||
"desktop -> browser": 1,
|
||||
"desktop -> electron": 1,
|
||||
|
||||
@@ -554,6 +554,8 @@ const PARSER_FOLDERS = [
|
||||
"src/model/",
|
||||
"src/native/",
|
||||
"src/python/",
|
||||
// Shared artifact readers (ZIP, directory, ASAR header) live in resources.
|
||||
"src/resources/",
|
||||
"src/rust/",
|
||||
"src/v8/",
|
||||
"src/wasm/",
|
||||
@@ -572,11 +574,13 @@ const PARSER_FOLDERS = [
|
||||
"managed",
|
||||
"model",
|
||||
"native",
|
||||
"pcap",
|
||||
"python",
|
||||
"rust",
|
||||
"v8",
|
||||
"wasm",
|
||||
"windows",
|
||||
"zip",
|
||||
].map((folder) => `src/domain/${folder}/`),
|
||||
];
|
||||
const parserFiles = files.filter((file) =>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"src/artifacts/AsarHeader.ts": 1,
|
||||
"src/kuna/KunaJsonStream.ts": 1,
|
||||
"src/process/BoundedOutputExcerpt.ts": 1,
|
||||
"src/process/ProviderProcess.ts": 1
|
||||
"src/process/ProviderProcess.ts": 1,
|
||||
"src/resources/AsarHeader.ts": 1
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"src/android/JadxProtocol.ts": 2,
|
||||
"src/android/JadxWorkspaceRoot.ts": 1,
|
||||
"src/artifacts/AsarHeader.ts": 1,
|
||||
"src/artifacts/ReleaseExposureReader.ts": 1,
|
||||
"src/artifacts/apple/AppleAssetCatalogAnalysis.ts": 1,
|
||||
"src/artifacts/deno/DenoSectionLayout.ts": 1,
|
||||
@@ -13,5 +12,6 @@
|
||||
"src/native/LldbRetainedObservations.ts": 1,
|
||||
"src/native/apple/losslessJson.ts": 1,
|
||||
"src/native/parsers/plist.ts": 1,
|
||||
"src/resources/AsarHeader.ts": 1,
|
||||
"src/rust/RustAuditableReader.ts": 1
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
"src/application/BinaryTargetResolver.ts": 1,
|
||||
"src/application/MipsElfMetadata.ts": 10,
|
||||
"src/application/MipsGnuAttributes.ts": 2,
|
||||
"src/artifacts/AsarHeader.ts": 4,
|
||||
"src/artifacts/DesktopFileInspection.ts": 4,
|
||||
"src/artifacts/FitArtifactReader.ts": 1,
|
||||
"src/artifacts/GodotPckArtifactReader.ts": 6,
|
||||
@@ -131,5 +130,6 @@
|
||||
"src/native/pwntools/RecordedCrashSourceBindings.ts": 6,
|
||||
"src/native/windows/WindowsShortcutParser.ts": 49,
|
||||
"src/pcap/PcapDnsWire.ts": 5,
|
||||
"src/resources/AsarHeader.ts": 4,
|
||||
"src/v8/V8CodeCacheParser.ts": 1
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
import type { AsarHeaderAdmission } from "../config/asarHeaderAdmission.js";
|
||||
import {
|
||||
createAsarHeaderSignatureProbe,
|
||||
type FinalAsarHeaderProbeObservation,
|
||||
} from "./AsarHeader.js";
|
||||
import {
|
||||
createXmlPlistSignatureProbe,
|
||||
MAX_XML_PLIST_PROBE_BYTES,
|
||||
@@ -20,6 +16,10 @@ import {
|
||||
type MzWindowsHeaderSignatureEvidence,
|
||||
} from "../domain/dosMz.js";
|
||||
import { DFUSE_SUFFIX_BYTES } from "../domain/firmware/dfuse.js";
|
||||
import {
|
||||
createAsarHeaderSignatureProbe,
|
||||
type FinalAsarHeaderProbeObservation,
|
||||
} from "../resources/index.js";
|
||||
|
||||
/** Initial bytes required by the other bounded format classifiers. */
|
||||
export const ARTIFACT_CLASSIFICATION_PREFIX_BYTES = 8_192;
|
||||
|
||||
@@ -26,13 +26,11 @@ import {
|
||||
type ArtifactReader,
|
||||
type ArtifactTraversalOptions,
|
||||
readArtifactFileChunks,
|
||||
} from "../resources/index.js";
|
||||
import { closeAsarHandle, readValidatedAsarEntry } from "./AsarEntryStream.js";
|
||||
import {
|
||||
admitAsarHeader,
|
||||
readAsarHeader,
|
||||
type AsarHeaderExtents,
|
||||
} from "./AsarHeader.js";
|
||||
} from "../resources/index.js";
|
||||
import { closeAsarHandle, readValidatedAsarEntry } from "./AsarEntryStream.js";
|
||||
import { OwnedFileHandle } from "../filesystem/OwnedFileHandle.js";
|
||||
import type { FileHandleChunkStream } from "../filesystem/readFileHandleChunks.js";
|
||||
import {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { HOST_PLATFORM } from "../platform/HostPlatform.js";
|
||||
import { setImmediate } from "node:timers/promises";
|
||||
import { z } from "zod";
|
||||
|
||||
import { asarDeclaredSizeSchema, asarNodeSchema } from "./AsarNode.js";
|
||||
import { asarDeclaredSizeSchema, asarNodeSchema } from "../domain/asarNode.js";
|
||||
import {
|
||||
ArtifactReaderFailure,
|
||||
type ArtifactEntry,
|
||||
|
||||
@@ -35,6 +35,8 @@ import {
|
||||
hashStableRootArtifactHandle,
|
||||
openRootArtifact,
|
||||
releaseRootArtifact,
|
||||
asarHeaderAdmissionRecovery,
|
||||
createAsarHeaderSignatureProbe,
|
||||
} from "../resources/index.js";
|
||||
import { decodeBinaryPlistText } from "../domain/apple/binaryPlistMaterializer.js";
|
||||
import {
|
||||
@@ -42,10 +44,6 @@ import {
|
||||
invariantViolation,
|
||||
} from "../domain/internalInvariant.js";
|
||||
import { ArtifactEmbeddedFormatProbes } from "./ArtifactEmbeddedFormatProbes.js";
|
||||
import {
|
||||
asarHeaderAdmissionRecovery,
|
||||
createAsarHeaderSignatureProbe,
|
||||
} from "./AsarHeader.js";
|
||||
import {
|
||||
DEFAULT_ASAR_HEADER_ADMISSION,
|
||||
type AsarHeaderAdmission,
|
||||
|
||||
@@ -24,13 +24,13 @@ import {
|
||||
SafeOutputTree,
|
||||
SafeOutputTreeCreationFailure,
|
||||
assertArtifactFileSelectedSource,
|
||||
resolveAsarHeaderAdmission,
|
||||
} from "../../resources/index.js";
|
||||
import { absoluteCallerPath } from "../../filesystem/callerPath.js";
|
||||
import type { AsarHeaderAdmission } from "../../config/asarHeaderAdmission.js";
|
||||
import type { EspFlashSelection } from "../../domain/firmware/espFlashLocation.js";
|
||||
import { artifactFormatDescriptor } from "../artifactFormats.js";
|
||||
import { createArtifactReader } from "../createArtifactReader.js";
|
||||
import { resolveAsarHeaderAdmission } from "../AsarHeader.js";
|
||||
import {
|
||||
ArtifactEmbeddedFormatProbes,
|
||||
type ArtifactEmbeddedFormatProbeFacts,
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
resolveOccurrenceParents,
|
||||
} from "./ArtifactGraphConstruction.js";
|
||||
import { createArtifactClassificationProbe } from "../ArtifactClassificationProbe.js";
|
||||
import { createAsarHeaderSignatureProbe } from "../AsarHeader.js";
|
||||
import { ArtifactReaderFailure } from "../../resources/ArtifactReader.js";
|
||||
import { translateArtifactFailure } from "../ArtifactOperationFailure.js";
|
||||
import { projectAnalysisError } from "../../domain/analysisErrorProjection.js";
|
||||
@@ -43,6 +42,7 @@ import {
|
||||
} from "../../../tests/fixtures/espImage.js";
|
||||
import { devicetreeFixture } from "../../domain/firmware/devicetree.fixture.js";
|
||||
import { fitFixture } from "../fit/FitImage.fixture.js";
|
||||
import { createAsarHeaderSignatureProbe } from "../../resources/index.js";
|
||||
|
||||
it("joins only observed PE signature bytes across stream chunks", () => {
|
||||
const bytes = pe(0x8664, 8190);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { artifactFormatDescriptor } from "../artifactFormats.js";
|
||||
import { recognizeArtifactFormat } from "../../domain/artifactFormatRecognition.js";
|
||||
import type { ArtifactClassificationEvidence } from "../ArtifactClassificationProbe.js";
|
||||
import { asarHeaderAdmissionFailure } from "../AsarHeader.js";
|
||||
import { hasDestinationPath } from "../../resources/index.js";
|
||||
import {
|
||||
hasDestinationPath,
|
||||
asarHeaderAdmissionFailure,
|
||||
} from "../../resources/index.js";
|
||||
import { compareUnicodeCodePoints } from "../../domain/unicodeCodePointOrder.js";
|
||||
import { isJavaScriptSourcePath } from "../../domain/javascript/javascriptArtifactFiles.js";
|
||||
import { digestCanonicalValue } from "../../domain/canonicalDigest.js";
|
||||
|
||||
@@ -15,18 +15,16 @@ import {
|
||||
withArtifactFileHandle,
|
||||
ArtifactReaderFailure,
|
||||
ArtifactResourceScope,
|
||||
admitAsarHeader,
|
||||
asarHeaderAdmissionFailure,
|
||||
} from "../resources/index.js";
|
||||
import { asarNodeSchema } from "../artifacts/AsarNode.js";
|
||||
import { asarNodeSchema } from "../domain/asarNode.js";
|
||||
import {
|
||||
regularFileState,
|
||||
sameRegularFileState,
|
||||
type RegularFileState,
|
||||
} from "../filesystem/RegularFile.js";
|
||||
|
||||
import {
|
||||
admitAsarHeader,
|
||||
asarHeaderAdmissionFailure,
|
||||
} from "../artifacts/AsarHeader.js";
|
||||
import {
|
||||
DEFAULT_ASAR_HEADER_ADMISSION,
|
||||
type AsarHeaderAdmission,
|
||||
|
||||
File renamed without changes.
@@ -2,12 +2,12 @@ import type { FileHandle } from "node:fs/promises";
|
||||
import type { Stats } from "node:fs";
|
||||
import { expect, it, vi } from "vitest";
|
||||
|
||||
import { asarHeaderBytes } from "../../tests/fixtures/asarHeader.js";
|
||||
import {
|
||||
admitAsarHeader,
|
||||
readAsarHeader,
|
||||
createAsarHeaderSignatureProbe,
|
||||
} from "./AsarHeader.js";
|
||||
import { asarHeaderBytes } from "../../tests/fixtures/asarHeader.js";
|
||||
|
||||
const makeArchive = (): Buffer => asarHeaderBytes(' \t\r\n{"files":{}} ');
|
||||
|
||||
@@ -3,10 +3,8 @@ import type { FileHandle } from "node:fs/promises";
|
||||
import { readFileHandleRange } from "../filesystem/readFileHandleRange.js";
|
||||
import { findDuplicateJsonMember } from "../domain/jsonDuplicateMember.js";
|
||||
|
||||
import {
|
||||
assertArtifactReadActive,
|
||||
ArtifactReaderFailure,
|
||||
} from "../resources/index.js";
|
||||
import { assertArtifactReadActive } from "./ArtifactFileOperation.js";
|
||||
import { ArtifactReaderFailure } from "./ArtifactReader.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import {
|
||||
ASAR_HEADER_ADMISSION_SETTING,
|
||||
@@ -4,6 +4,18 @@
|
||||
* counts any other import as an import past the entry file. Export a name
|
||||
* here when a new outside use needs it.
|
||||
*/
|
||||
export {
|
||||
admitAsarHeader,
|
||||
asarHeaderAdmissionFailure,
|
||||
asarHeaderAdmissionRecovery,
|
||||
createAsarHeaderSignatureProbe,
|
||||
readAsarHeader,
|
||||
resolveAsarHeaderAdmission,
|
||||
} from "./AsarHeader.js";
|
||||
export type {
|
||||
AsarHeaderExtents,
|
||||
FinalAsarHeaderProbeObservation,
|
||||
} from "./AsarHeader.js";
|
||||
export {
|
||||
AnalysisCleanupLease,
|
||||
AnalysisCleanupLeaseGroup,
|
||||
|
||||
@@ -6,10 +6,6 @@ import { afterEach, expect, it, vi } from "vitest";
|
||||
|
||||
import { translateArtifactFailure } from "../../../src/artifacts/ArtifactOperationFailure.js";
|
||||
import { ArtifactReaderFailure } from "../../../src/resources/ArtifactReader.js";
|
||||
import {
|
||||
admitAsarHeader,
|
||||
asarHeaderAdmissionRecovery,
|
||||
} from "../../../src/artifacts/AsarHeader.js";
|
||||
import { parseEnvironment } from "../../../src/config/environment.js";
|
||||
import { createDirectAnalysis } from "../../../src/composition/directAnalysis.js";
|
||||
import {
|
||||
@@ -26,6 +22,10 @@ import { projectAnalysisError } from "../../../src/domain/analysisErrorProjectio
|
||||
import { inventoryArtifact } from "../../fixtures/artifactInventory.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { analyzeJavaScriptApplication } from "../../support/javascriptApplicationScope.js";
|
||||
import {
|
||||
admitAsarHeader,
|
||||
asarHeaderAdmissionRecovery,
|
||||
} from "../../../src/resources/index.js";
|
||||
|
||||
const createFixture = async () => {
|
||||
const root = await createTestTempDirectory("rea-asar-header-admission-");
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
BLOCK_INTEGRITY_LIMITATION,
|
||||
readAsarListing,
|
||||
} from "../../../src/artifacts/AsarListing.js";
|
||||
import { resolveAsarHeaderAdmission } from "../../../src/artifacts/AsarHeader.js";
|
||||
import {
|
||||
asarHeaderBytes,
|
||||
nestedAsarHeader,
|
||||
@@ -19,6 +18,7 @@ import { inventoryArtifact } from "../../fixtures/artifactInventory.js";
|
||||
import { ArtifactResourceScope } from "../../../src/resources/ArtifactResourceScope.js";
|
||||
import { extractArtifact } from "../../../src/artifacts/extraction/ArtifactExtraction.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { resolveAsarHeaderAdmission } from "../../../src/resources/index.js";
|
||||
|
||||
const archiveWith = async (bytes: Buffer) => {
|
||||
const root = await createTestTempDirectory("rea-asar-listing-");
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { createAsarHeaderSignatureProbe } from "../../src/artifacts/AsarHeader.js";
|
||||
import { classifyArtifactContent } from "../../src/artifacts/inventory/ArtifactGraphConstruction.js";
|
||||
import { createAsarHeaderSignatureProbe } from "../../src/resources/index.js";
|
||||
|
||||
/** Observe a supplied byte prefix before assigning an inventory path role. */
|
||||
export const classifyArtifactBytesAtPath = (
|
||||
|
||||
Reference in new issue
Block a user