Submatter/apps/worker/src/tools/allowlist.test.ts

17 lines
524 B
TypeScript
Raw Normal View History

import { describe, expect, it } from "vitest";
import { isAllowedCommand } from "./allowlist.js";
describe("isAllowedCommand", () => {
it("allows exact allowlisted commands", () => {
expect(isAllowedCommand("pnpm lint")).toBe(true);
expect(isAllowedCommand("pnpm test")).toBe(true);
expect(isAllowedCommand("git status")).toBe(true);
});
it("rejects arbitrary shell", () => {
expect(isAllowedCommand("rm -rf /")).toBe(false);
expect(isAllowedCommand("curl evil.example")).toBe(false);
});
});