repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

fix(git-safe): validate Windows clone paths

108f0d9155d7a031f7e08763267c1d10c2169187

Oliver Krylow <o.krylow@isp-insoft.de> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (3)

CHANGELOG.md

Modified
46 46 - Fix Pulse TAB completion
47 47 - Fix Notes so `/tree` restores notes from the selected branch and `/new` asks whether to carry pending notes into the new session
48 48 - Fix the uv extension on Windows by skipping incompatible shell shims while retaining command blocking
49 +- Fix git-safe cloning on Windows so valid deep destination paths are accepted
49 50 - Fix Overkill's Aftermath skill picker so large skill lists scroll within the terminal
50 51 - Fix Overkill Aftermath completion when mining finds insufficient tasks so it offers report-only actions and shows consistent artifact paths
51 52 - Show persistent below-editor progress during long Overkill phases, including mining and aggregation calls

extensions/git-safe/__tests__/path.test.ts

Added
new file mode 100644
1 +import { join, parse } from "node:path";
2 +import { describe, expect, it } from "vitest";
3 +import { isDangerousPath } from "../clone";
5 +describe("git-safe clone path validation", () => {
6 + it("accepts a deep native path", () => {
7 + const target = join(
8 + process.cwd(),
9 + "output",
10 + "tmp",
11 + "research",
12 + "repos",
13 + "owner",
14 + "repo",
15 + );
17 + expect(isDangerousPath(target)).toBeNull();
18 + });
20 + it("rejects native root and shallow paths", () => {
21 + const root = parse(process.cwd()).root;
23 + expect(isDangerousPath(root)).toBe("path is root directory");
24 + expect(isDangerousPath(join(root, "repo"))).toMatch(/path is too shallow/);
25 + });
26 +});

extensions/git-safe/clone.ts

Modified
15 15 writeFile,
16 16 } from "node:fs/promises";
17 17 import { homedir, tmpdir } from "node:os";
18 -import { dirname, isAbsolute, join, normalize, resolve } from "node:path";
18 +import {
19 + dirname,
20 + isAbsolute,
21 + join,
22 + normalize,
23 + parse,
24 + relative,
25 + resolve,
26 + sep,
27 +} from "node:path";
19 28 import {
20 29 SpawnExitError,
21 30 SpawnTimeoutError,
56 65 // ── Path safety ────────────────────────────────────────────────────────────
58 67 /** Reject obviously dangerous paths */
59 -function isDangerousPath(p: string): string | null {
68 +export function isDangerousPath(p: string): string | null {
60 69 const resolved = resolve(p);
61 70 const home = homedir();
62 - const parts = resolved.split("/").filter(Boolean);
71 + const root = parse(resolved).root;
72 + const parts = relative(root, resolved).split(sep).filter(Boolean);
64 74 // Root
65 - if (resolved === "/") return "path is root directory";
75 + if (resolved === root) return "path is root directory";
66 76 // Home dir itself
67 77 if (resolved === home) return "path is home directory";
68 78 // Too shallow (depth < 2)