mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 21:23:45 +00:00
fix(parsers): respect container facts and real decoding boundaries
Use zip.js's parsed symlink fact for inventory and open refusal. Treat an unmatched Godot trailer as an unconfirmed candidate while preserving failures for confirmed malformed packs. Report entropy path-resolution failures at the selected-input boundary. Separate Go header discovery from inline string extents in ELF and Mach-O, and apply the aggregate content allowance after validating real source ranges. Normalize binary plist UID widths through the existing scalar-copy owner, budget exact clone growth, preserve source identity, and refuse inexact UIDs. Validation: 389 distinct tests passed, one Linux /proc test skipped on Darwin; build, typecheck/lint, docs, single-thread formatting, and discovery (2142 files) passed. CLI/MCP Go fixtures and public ZIP/Godot/keyed-archive workflows ran. Real producer prevalence and external provider execution were not established. Repeated ordinary keyed-archive CLI inventory facts and estimated reply tokens were equal before/after. Warm median elapsed was 0.5166s / 0.5177s; no speed claim. Fixes #6751 Fixes #6763 Fixes #6754 Fixes #6767 Fixes #6762 Fixes #6779
This commit is contained in:
1 parent
bd4f5e9c19
commit
6ba6aea5eb
27 files changed
+991
-111
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { open, stat, rename, writeFile } from "node:fs/promises";
|
||||
import { open, stat, rename, symlink, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { expect, it, vi } from "vitest";
|
||||
import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js";
|
||||
@@ -69,6 +69,67 @@ it("rejects missing files, non-files and windows beyond EOF, but accepts empty w
|
||||
).toContainEqual(expect.stringContaining("reports a size of 0"));
|
||||
});
|
||||
|
||||
it.skipIf(process.platform !== "linux" && process.platform !== "darwin")(
|
||||
"projects real path-resolution failures as actionable input errors",
|
||||
async () => {
|
||||
const root = await createTestTempDirectory("rea-entropy-path-resolution-");
|
||||
const loop = join(root, "loop");
|
||||
await symlink("loop", loop);
|
||||
const overlong = join(root, "x".repeat(256));
|
||||
const cases = [
|
||||
[loop, "ELOOP"],
|
||||
[overlong, "ENAMETOOLONG"],
|
||||
] as const;
|
||||
const service = new ByteEntropyService();
|
||||
try {
|
||||
for (const [path, code] of cases) {
|
||||
let observedCode: unknown;
|
||||
try {
|
||||
await stat(path);
|
||||
} catch (cause: unknown) {
|
||||
observedCode =
|
||||
cause instanceof Error && "code" in cause ? cause.code : undefined;
|
||||
}
|
||||
expect(observedCode).toBe(code);
|
||||
|
||||
const result = await service.inspect({ path });
|
||||
if (result.ok) throw new Error(`Expected ${code} path failure`);
|
||||
expect(result.error).toMatchObject({
|
||||
_tag: "AnalysisInputError",
|
||||
cause: { code },
|
||||
issues: [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_value",
|
||||
},
|
||||
],
|
||||
});
|
||||
const projected = projectAnalysisError(result.error);
|
||||
expect(projected).toMatchObject({
|
||||
code: "invalid_request",
|
||||
recovery: {
|
||||
kind: "inspect_input_contract",
|
||||
operation: "inspect_byte_entropy",
|
||||
},
|
||||
details: {
|
||||
operation: "inspect_byte_entropy",
|
||||
issues: [
|
||||
{
|
||||
path: ["path"],
|
||||
reason: "invalid_value",
|
||||
message: expect.stringContaining(code),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(projected.details)).toContain(path);
|
||||
}
|
||||
} finally {
|
||||
await service.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
[{ offset: 2048 }, "offset"],
|
||||
[{ offset: 2048, length: 0 }, "offset"],
|
||||
|
||||
Reference in new issue
Block a user