fix(boundaries): reject unsafe local inputs

This commit is contained in:
morluto
2026-07-12 08:59:18 +08:00
parent aee9cb8e4e
commit 15e8cf3234
4 changed files with 26 additions and 3 deletions
+6 -1
View File
@@ -67,7 +67,7 @@ describe("executable header parsing", () => {
describe("binary target I/O", () => {
it("resolves relative Hopper databases and rejects unknown or unreadable paths", async () => {
directory = await mkdtemp(join(tmpdir(), "bb-target-"));
directory = await mkdtemp(join(tmpdir(), "rea-target-"));
await writeFile(join(directory, "sample.hop"), "database");
await writeFile(join(directory, "text"), "hello");
expect((await parseBinaryTarget("sample.hop", directory)).ok).toBe(true);
@@ -75,6 +75,11 @@ describe("binary target I/O", () => {
expect((await parseBinaryTarget("missing", directory)).ok).toBe(false);
});
it("rejects non-regular targets before reading them", async () => {
directory = await mkdtemp(join(tmpdir(), "rea-target-"));
expect((await parseBinaryTarget(directory)).ok).toBe(false);
});
it("honors an explicit database kind without relying on the file suffix", async () => {
directory = await mkdtemp(join(tmpdir(), "rea-target-"));
await writeFile(join(directory, "saved-analysis"), "database");