From 64199736677a8ed303291c763975d484ac8f7e99 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Fri, 4 Apr 2025 15:41:25 +0200 Subject: Enhance bash tool security and improve permission dialog UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- internal/llm/tools/bash_test.go | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'internal/llm/tools/bash_test.go') 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) { -- cgit v1.2.3