Skip to content

Commit ebfe57b

Browse files
authored
Merge pull request #1069 from RooVetGit/auto_approve_wildcard
Allow setting a wildcard for auto-approve commands
2 parents c5aa775 + e3ae2c4 commit ebfe57b

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

.changeset/wet-games-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Allow setting a wildcard for auto-approve commands

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {
401401
color: "var(--vscode-descriptionForeground)",
402402
}}>
403403
Command prefixes that can be auto-executed when "Always approve execute operations"
404-
is enabled.
404+
is enabled. Add * to allow all commands (use with caution).
405405
</p>
406406

407407
<div style={{ display: "flex", gap: "5px", marginTop: "10px" }}>

webview-ui/src/utils/__tests__/command-validation.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,16 @@ describe("Command Validation", () => {
106106
expect(validateCommand("", allowedCommands)).toBe(true)
107107
expect(validateCommand(" ", allowedCommands)).toBe(true)
108108
})
109+
110+
it("allows all commands when wildcard is present", () => {
111+
const wildcardAllowedCommands = ["*"]
112+
// Should allow any command, including dangerous ones
113+
expect(validateCommand("rm -rf /", wildcardAllowedCommands)).toBe(true)
114+
expect(validateCommand("dangerous-command", wildcardAllowedCommands)).toBe(true)
115+
expect(validateCommand("npm test && rm -rf /", wildcardAllowedCommands)).toBe(true)
116+
// Should even allow subshell commands that are normally blocked
117+
expect(validateCommand("npm test $(echo dangerous)", wildcardAllowedCommands)).toBe(true)
118+
expect(validateCommand("npm test `rm -rf /`", wildcardAllowedCommands)).toBe(true)
119+
})
109120
})
110121
})

webview-ui/src/utils/command-validation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export function isAllowedSingleCommand(command: string, allowedCommands: string[
104104
export function validateCommand(command: string, allowedCommands: string[]): boolean {
105105
if (!command?.trim()) return true
106106

107+
// If '*' is in allowed commands, everything is allowed
108+
if (allowedCommands?.includes("*")) return true
109+
107110
// Block subshell execution attempts
108111
if (command.includes("$(") || command.includes("`")) {
109112
return false

0 commit comments

Comments
 (0)