test(FN-4623): add static execSync regression guard

Fusion-Task-Id: FN-4623
Fusion-Task-Lineage: 58122853-cab7-4102-9649-4ceda4c5959e
This commit is contained in:
Fusion (runfusion.ai)
2026-05-15 19:26:18 -07:00
committed by gsxdsm
parent a2245e1959
commit 81b2f4ea8f

View File

@@ -0,0 +1,17 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
describe("worktree-backend static shellout guard", () => {
it("does not use execSync and always sets timeout for exec/execFile calls", () => {
const source = readFileSync(resolve(process.cwd(), "src/worktree-backend.ts"), "utf-8");
expect(source).not.toContain("execSync(");
expect(source).not.toMatch(/\bexecSync\b/);
const callPattern = /exec(?:File)?Async\([\s\S]{0,400}?\{[\s\S]{0,400}?timeout\s*:/g;
const callMatches = source.match(/exec(?:File)?Async\(/g) ?? [];
const timeoutMatches = source.match(callPattern) ?? [];
expect(timeoutMatches.length).toBeGreaterThanOrEqual(callMatches.length);
});
});