import { describe, expect, test } from "vitest"; import { isSafeSystemPath } from "#src/safe-system-paths"; describe("isSafeSystemPath", () => { test("returns true for the whitelisted device paths", () => { for (const p of ["/dev/null", "/dev/stdin", "/dev/stdout", "/dev/stderr"]) { expect(isSafeSystemPath(p)).toBe(true); } }); test("returns false for an arbitrary absolute path", () => { expect(isSafeSystemPath("/etc/passwd")).toBe(false); }); test("returns false for a path prefixed with a safe system path", () => { expect(isSafeSystemPath("/dev/null/subdir")).toBe(false); }); test("returns false for an empty string", () => { expect(isSafeSystemPath("")).toBe(false); }); test("returns false for a relative path", () => { expect(isSafeSystemPath("dev/null")).toBe(false); }); });