diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-04 15:41:25 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-04 15:41:25 +0200 |
| commit | 64199736677a8ed303291c763975d484ac8f7e99 (patch) | |
| tree | d5b59ff3f541187f5310c8dddd0fbe76df1c3071 /internal/llm/tools/bash_test.go | |
| parent | 8f8b403bbcb171fae525e7239f2f7b9d46c78b77 (diff) | |
| download | opencode-64199736677a8ed303291c763975d484ac8f7e99.tar.gz opencode-64199736677a8ed303291c763975d484ac8f7e99.zip | |
Enhance bash tool security and improve permission dialog UI
- Expand safe command list with common dev tools (git, go, node, python, etc.)
- Improve multi-word command detection for better security checks
- Add scrollable viewport to permission dialog for better diff viewing
- Fix command batching in TUI update to properly handle multiple commands
🤖 Generated with termai
Co-Authored-By: termai <[email protected]>
Diffstat (limited to 'internal/llm/tools/bash_test.go')
| -rw-r--r-- | internal/llm/tools/bash_test.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/internal/llm/tools/bash_test.go b/internal/llm/tools/bash_test.go index b7b5c5ee5..9eadc227c 100644 --- a/internal/llm/tools/bash_test.go +++ b/internal/llm/tools/bash_test.go @@ -119,27 +119,38 @@ func TestBashTool_Run(t *testing.T) { } }) - t.Run("handles safe read-only commands without permission check", func(t *testing.T) { + t.Run("handles multi-word safe commands without permission check", func(t *testing.T) { permission.Default = newMockPermissionService(false) tool := NewBashTool() - // Test with a safe read-only command - params := BashParams{ - Command: "echo 'test'", + // Test with multi-word safe commands + multiWordCommands := []string{ + "git status", + "git log -n 5", + "docker ps", + "go test ./...", + "kubectl get pods", } - paramsJSON, err := json.Marshal(params) - require.NoError(t, err) + for _, cmd := range multiWordCommands { + params := BashParams{ + Command: cmd, + } - call := ToolCall{ - Name: BashToolName, - Input: string(paramsJSON), - } + paramsJSON, err := json.Marshal(params) + require.NoError(t, err) - response, err := tool.Run(context.Background(), call) - require.NoError(t, err) - assert.Equal(t, "test\n", response.Content) + call := ToolCall{ + Name: BashToolName, + Input: string(paramsJSON), + } + + response, err := tool.Run(context.Background(), call) + require.NoError(t, err) + assert.NotContains(t, response.Content, "permission denied", + "Command %s should be allowed without permission", cmd) + } }) t.Run("handles permission denied", func(t *testing.T) { |
