mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
a891bb80ae
Return the validated descriptor and its original metadata from regular-file admission. Propagate that contract through owned reads, hashes, snapshots, artifact inventory and provider file workflows instead of replacing initial facts with another stat. Keep arbitrary output-handle operations separate. Preserve final descriptor/path identity proofs, borrowed-source verification, BigInt precision, cancellation provenance and failed-close ownership. Remove the obsolete source and owned-ZIP baseline stages and update their consumers and regressions. Tie read completion faults to actual reads instead of the retired duplicate stat; instrument real handles without fake handle wrappers. Validation: fresh runtime/catalog build; focused source, lifecycle, filesystem, CLI/MCP and authored provider-fixture tests; full static checks; docs checks; test discovery; duplication check. Platform-specific cases remain skipped on macOS. No installed provider or device behavior was verified.
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { readFile, symlink } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { expect, it, vi } from "vitest";
|
|
|
|
vi.mock("node:fs", async (importOriginal) => {
|
|
const original = await importOriginal<typeof import("node:fs")>();
|
|
return {
|
|
...original,
|
|
constants: { ...original.constants, O_NOFOLLOW: 0 },
|
|
};
|
|
});
|
|
|
|
import { openRegularFile } from "../../src/filesystem/RegularFile.js";
|
|
import { ZipArtifactReader } from "../../src/artifacts/ZipArtifactReader.js";
|
|
import { writeOrderedZip } from "../fixtures/artifactEntryOrder.js";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
|
|
it("rejects a symlink when O_NOFOLLOW is unavailable and still follows when requested", async () => {
|
|
const root = await createTestTempDirectory("rea-no-nofollow-");
|
|
const target = join(root, "target.zip");
|
|
const link = join(root, "selected.zip");
|
|
await writeOrderedZip(target, ["member.bin"]);
|
|
await symlink(target, link);
|
|
|
|
const reader = new ZipArtifactReader(target, "zip");
|
|
try {
|
|
const entries = [];
|
|
for await (const entry of reader.entries()) entries.push(entry);
|
|
expect(entries.map(({ path }) => path)).toEqual(["member.bin"]);
|
|
} finally {
|
|
await reader.close();
|
|
}
|
|
|
|
const linkedReader = new ZipArtifactReader(link, "zip");
|
|
try {
|
|
await expect(async () => {
|
|
for await (const _entry of linkedReader.entries()) {
|
|
// Consume through the public reader boundary.
|
|
}
|
|
}).rejects.toMatchObject({
|
|
name: "ArtifactReaderFailure",
|
|
reason: "format",
|
|
});
|
|
} finally {
|
|
await linkedReader.close();
|
|
}
|
|
|
|
const { handle: followed } = await openRegularFile(link, {
|
|
symlinks: "follow",
|
|
});
|
|
try {
|
|
await expect(readFile(followed)).resolves.toEqual(await readFile(target));
|
|
} finally {
|
|
await followed.close();
|
|
}
|
|
});
|