17 lines
524 B
TypeScript
17 lines
524 B
TypeScript
|
|
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);
|
||
|
|
});
|
||
|
|
});
|