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
+1 -1
View File
@@ -308,7 +308,7 @@ const objectValue = (value: unknown): Record<string, unknown> => {
return parsed.success ? parsed.data : {};
};
const parseObject = (text: string): Record<string, unknown> =>
objectValue(JSON.parse(text));
objectSchema.parse(JSON.parse(text));
const isMissing = (cause: unknown): boolean =>
cause instanceof Error && "code" in cause && cause.code === "ENOENT";
const restoreConfig = async (
+3 -1
View File
@@ -1,5 +1,5 @@
import { constants } from "node:fs";
import { access, open, realpath } from "node:fs/promises";
import { access, open, realpath, stat } from "node:fs/promises";
import { isAbsolute, resolve } from "node:path";
import { BinaryTargetError } from "./errors.js";
@@ -36,6 +36,8 @@ export const parseBinaryTarget = async (
try {
await access(candidate, constants.R_OK);
const path = await realpath(candidate);
if (!(await stat(path)).isFile())
return err(new BinaryTargetError(path, "target is not a regular file"));
if (
targetKind === "database" ||
(targetKind === undefined && path.toLowerCase().endsWith(".hop"))