Reverts https://github.com/openai/codex/pull/386 because: * The parsing logic for shell commands was unsafe (`split(/\s+/)` instead of something like `shell-quote`) * We have a different plan for supporting auto-approved commands.
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
import type { SafetyAssessment } from "../src/approvals";
|
||||
|
||||
import { canAutoApprove } from "../src/approvals";
|
||||
import { describe, test, expect, vi } from "vitest";
|
||||
|
||||
vi.mock("../src/utils/config", () => ({
|
||||
loadConfig: () => ({
|
||||
safeCommands: ["npm test", "sl"],
|
||||
}),
|
||||
}));
|
||||
import { describe, test, expect } from "vitest";
|
||||
|
||||
describe("canAutoApprove()", () => {
|
||||
const env = {
|
||||
@@ -95,27 +89,4 @@ describe("canAutoApprove()", () => {
|
||||
|
||||
expect(check(["cargo", "build"])).toEqual({ type: "ask-user" });
|
||||
});
|
||||
|
||||
test("commands in safeCommands config should be safe", async () => {
|
||||
expect(check(["npm", "test"])).toEqual({
|
||||
type: "auto-approve",
|
||||
reason: "User-defined safe command",
|
||||
group: "User config",
|
||||
runInSandbox: false,
|
||||
});
|
||||
|
||||
expect(check(["sl"])).toEqual({
|
||||
type: "auto-approve",
|
||||
reason: "User-defined safe command",
|
||||
group: "User config",
|
||||
runInSandbox: false,
|
||||
});
|
||||
|
||||
expect(check(["npm", "test", "--watch"])).toEqual({
|
||||
type: "auto-approve",
|
||||
reason: "User-defined safe command",
|
||||
group: "User config",
|
||||
runInSandbox: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user