import { describe, expect, test } from "bun:test"; import { isSafeTreePath } from "./tree-path"; describe("isSafeTreePath (INT-A22)", () => { test("accepts ordinary repository paths", () => { expect(isSafeTreePath("src/index.ts")).toBe(true); expect(isSafeTreePath("README")).toBe(true); expect(isSafeTreePath(".github/workflows/ci.yml")).toBe(true); }); test("rejects traversal, git metadata, absolute paths and control characters", () => { for (const path of [ "", "/etc/passwd", "../x", "a/../b", ".git/hooks/post-checkout", "a/.GIT/config", "a\\b", "a\u0000b", "dir/", "a//b", "git~1/x", "trailing. ", ]) { expect(isSafeTreePath(path)).toBe(false); } }); });