Documentation
¶
Overview ¶
Package permissions provides tool permission checking based on configurable Allow/Ask/Deny patterns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker evaluates tool permissions based on configured patterns
func NewChecker ¶
func NewChecker(cfg *latest.PermissionsConfig) *Checker
NewChecker creates a new permission checker from config
func (*Checker) AllowPatterns ¶ added in v1.20.0
AllowPatterns returns the list of allow patterns.
func (*Checker) AskPatterns ¶ added in v1.23.4
AskPatterns returns the list of ask patterns.
func (*Checker) Check ¶
Check evaluates the permission for a given tool name without arguments. This is a convenience method that calls CheckWithArgs with nil arguments. Evaluation order: Deny (checked first), then Allow, then Ask (default)
func (*Checker) CheckWithArgs ¶
CheckWithArgs evaluates the permission for a given tool name and its arguments. Evaluation order: Deny (checked first), then Allow, then Ask (explicit), then Ask (default).
The toolName can be a simple name like "shell" or a qualified name like "mcp:github:create_issue".
Patterns support: - Simple tool names: "shell", "read_*" - Argument matching: "shell:cmd=ls*" matches shell tool with cmd argument starting with "ls" - Multiple arguments: "shell:cmd=ls*:cwd=/home/*" matches both conditions - Glob patterns in both tool names and argument values
Returns ForceAsk when an explicit ask pattern matches. ForceAsk means the tool must always be confirmed, even when it would normally be auto-approved (e.g. read-only tools or --yolo mode).
func (*Checker) DenyPatterns ¶ added in v1.20.0
DenyPatterns returns the list of deny patterns.
type Decision ¶
type Decision int
Decision represents the permission decision for a tool call
const ( // Ask means the tool requires user approval (default behavior) Ask Decision = iota // Allow means the tool is auto-approved without user confirmation Allow // Deny means the tool is rejected and should not be executed Deny // ForceAsk means an explicit ask pattern matched; the tool must be // confirmed even if it would normally be auto-approved (e.g. read-only). ForceAsk )