From e3ae2c41d3497660a46459e12bd92369a7ecd824 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Wed, 19 Feb 2025 09:37:29 -0500 Subject: [PATCH] Allow setting a wildcard for auto-approve commands --- .changeset/wet-games-pay.md | 5 +++++ webview-ui/src/components/settings/SettingsView.tsx | 2 +- .../src/utils/__tests__/command-validation.test.ts | 11 +++++++++++ webview-ui/src/utils/command-validation.ts | 3 +++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/wet-games-pay.md diff --git a/.changeset/wet-games-pay.md b/.changeset/wet-games-pay.md new file mode 100644 index 0000000000..50fdd17b90 --- /dev/null +++ b/.changeset/wet-games-pay.md @@ -0,0 +1,5 @@ +--- +"roo-cline": patch +--- + +Allow setting a wildcard for auto-approve commands diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index bef57d1f5a..1e14e27a42 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -401,7 +401,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => { color: "var(--vscode-descriptionForeground)", }}> Command prefixes that can be auto-executed when "Always approve execute operations" - is enabled. + is enabled. Add * to allow all commands (use with caution).

diff --git a/webview-ui/src/utils/__tests__/command-validation.test.ts b/webview-ui/src/utils/__tests__/command-validation.test.ts index bea07cfc29..c1c73548b9 100644 --- a/webview-ui/src/utils/__tests__/command-validation.test.ts +++ b/webview-ui/src/utils/__tests__/command-validation.test.ts @@ -106,5 +106,16 @@ describe("Command Validation", () => { expect(validateCommand("", allowedCommands)).toBe(true) expect(validateCommand(" ", allowedCommands)).toBe(true) }) + + it("allows all commands when wildcard is present", () => { + const wildcardAllowedCommands = ["*"] + // Should allow any command, including dangerous ones + expect(validateCommand("rm -rf /", wildcardAllowedCommands)).toBe(true) + expect(validateCommand("dangerous-command", wildcardAllowedCommands)).toBe(true) + expect(validateCommand("npm test && rm -rf /", wildcardAllowedCommands)).toBe(true) + // Should even allow subshell commands that are normally blocked + expect(validateCommand("npm test $(echo dangerous)", wildcardAllowedCommands)).toBe(true) + expect(validateCommand("npm test `rm -rf /`", wildcardAllowedCommands)).toBe(true) + }) }) }) diff --git a/webview-ui/src/utils/command-validation.ts b/webview-ui/src/utils/command-validation.ts index 54072494ee..3f8fd593b1 100644 --- a/webview-ui/src/utils/command-validation.ts +++ b/webview-ui/src/utils/command-validation.ts @@ -104,6 +104,9 @@ export function isAllowedSingleCommand(command: string, allowedCommands: string[ export function validateCommand(command: string, allowedCommands: string[]): boolean { if (!command?.trim()) return true + // If '*' is in allowed commands, everything is allowed + if (allowedCommands?.includes("*")) return true + // Block subshell execution attempts if (command.includes("$(") || command.includes("`")) { return false