Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

refactor(artifacts): remove unused root classifier

morluto5291bca108af
diff --git a/src/artifacts/inventory/classify.ts b/src/artifacts/inventory/classify.ts
index a8baf7a12..18c675921 100644
--- a/src/artifacts/inventory/classify.ts
+++ b/src/artifacts/inventory/classify.ts
@@ -28,21 +28,6 @@ const classifyContainerExtension = (
return undefined;
};
-export const classifyRoot = async (
- path: string,
- directory: boolean,
-): Promise<ArtifactOccurrence["artifact_format"]> => {
- if (directory) return "directory";
- const extensionFormat = classifyContainerExtension(path);
- if (extensionFormat !== undefined) return extensionFormat;
- const handle = await openRootFile(path);
- try {
- return await classifyOpenedRoot(path, handle);
- } finally {
- await handle.close();
- }
-};
-
/** Classify and hash one file root through the same stable open descriptor. */
export const classifyAndHashRoot = async (
path: string,
diff --git a/src/filesystem/RegularFile.ts b/src/filesystem/RegularFile.ts
index e5afac401..13982a896 100644
--- a/src/filesystem/RegularFile.ts
+++ b/src/filesystem/RegularFile.ts
@@ -2,6 +2,7 @@ import { constants } from "node:fs";
import type { BigIntStats, Stats } from "node:fs";
import { open, type FileHandle } from "node:fs/promises";
+/** Identifies a selected path that cannot be read as one regular file. */
export class NonRegularFileReadError extends Error {
readonly code: "EISDIR" | "ENOTFILE";
diff --git a/tests/boundary/filesystem/zipDetection.test.ts b/tests/boundary/filesystem/zipDetection.test.ts
index 8ab81112a..3e1878db4 100644
--- a/tests/boundary/filesystem/zipDetection.test.ts
+++ b/tests/boundary/filesystem/zipDetection.test.ts
@@ -1,9 +1,9 @@
-import { writeFile } from "node:fs/promises";
+import { lstat, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
-import { classifyRoot } from "../../../src/artifacts/inventory/classify.js";
+import { classifyAndHashRoot } from "../../../src/artifacts/inventory/classify.js";
import { parseBinaryTarget } from "../../../src/application/BinaryTargetResolver.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
@@ -19,7 +19,9 @@ describe("ZIP signature detection", () => {
const root = await createTestTempDirectory("rea-zip-signature-");
const path = join(root, "input");
await writeFile(path, Buffer.from(signature));
- expect(await classifyRoot(path, false)).toBe(archive ? "zip" : "file");
+ expect(
+ (await classifyAndHashRoot(path, false, await lstat(path))).format,
+ ).toBe(archive ? "zip" : "file");
const target = await parseBinaryTarget(path);
if (archive)
expect(target).toMatchObject({ ok: true, value: { format: "zip" } });
@@ -37,7 +39,9 @@ describe("ZIP signature detection", () => {
const root = await createTestTempDirectory("rea-zip-short-");
const path = join(root, "input");
await writeFile(path, Buffer.from(bytes));
- expect(await classifyRoot(path, false)).toBe("file");
+ expect(
+ (await classifyAndHashRoot(path, false, await lstat(path))).format,
+ ).toBe("file");
expect((await parseBinaryTarget(path)).ok).toBe(false);
},
);