GetSuggestedPattern returns a suggested policy pattern for the given tool invocation. For exec commands, it returns empty string to prevent "Allow Always" from being offered -- exec should always require per-command approval since any shell command could be destructive.
(toolName, args string)
| 432 | // "Allow Always" from being offered -- exec should always require per-command |
| 433 | // approval since any shell command could be destructive. |
| 434 | func GetSuggestedPattern(toolName, args string) string { |
| 435 | sub, _ := NormalizeCoderArgs(args) |
| 436 | if sub == "" { |
| 437 | return toolName |
| 438 | } |
| 439 | // exec commands must NEVER get a blanket "Allow Always" pattern |
| 440 | if strings.EqualFold(sub, "exec") { |
| 441 | return "" |
| 442 | } |
| 443 | return fmt.Sprintf("%s %s", toolName, sub) |
| 444 | } |
| 445 | |
| 446 | func (pm *PolicyManager) ActivePolicyPath() string { |
| 447 | pm.mu.RLock() |