From 1642c8d069a63a2c7b43e680db284c6c9dc9da27 Mon Sep 17 00:00:00 2001 From: Amolith Date: Fri, 31 Oct 2025 13:34:29 -0600 Subject: [PATCH] refactor(permission): check allowlist first --- internal/permission/permission.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/permission/permission.go b/internal/permission/permission.go index 829dd2ed90abf4d45b63481eacebb492cadabdfd..c51478003957756bd3ee9919505a11358a11fdd9 100644 --- a/internal/permission/permission.go +++ b/internal/permission/permission.go @@ -127,6 +127,12 @@ func (s *permissionService) Request(opts CreatePermissionRequest) bool { return true } + // Check if the tool/action combination is in the allowlist + commandKey := opts.ToolName + ":" + opts.Action + if slices.Contains(s.allowedTools, commandKey) || slices.Contains(s.allowedTools, opts.ToolName) { + return true + } + // tell the UI that a permission was requested s.notificationBroker.Publish(pubsub.CreatedEvent, PermissionNotification{ ToolCallID: opts.ToolCallID, @@ -134,12 +140,6 @@ func (s *permissionService) Request(opts CreatePermissionRequest) bool { s.requestMu.Lock() defer s.requestMu.Unlock() - // Check if the tool/action combination is in the allowlist - commandKey := opts.ToolName + ":" + opts.Action - if slices.Contains(s.allowedTools, commandKey) || slices.Contains(s.allowedTools, opts.ToolName) { - return true - } - s.autoApproveSessionsMu.RLock() autoApprove := s.autoApproveSessions[opts.SessionID] s.autoApproveSessionsMu.RUnlock()