Documentation
¶
Overview ¶
Package policy decides which tools an agent may call. It implements docs/SPEC.md section 4: allow and deny lists of tool-name patterns and the groups "readonly" and "destructive", deny by default, and deny wins.
Index ¶
Constants ¶
const ( GroupReadOnly = "readonly" GroupDestructive = "destructive" )
Group names a rule can use in place of a tool-name pattern.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision struct {
Allowed bool
// Rule is the rule that decided, as "allow <rule>" or "deny <rule>",
// e.g. "deny cancel_*" or "allow readonly". When no rule matches it is
// "default deny".
Rule string
}
Decision is the result of checking one tool. Rule is written to the audit log, so a reader can see why a call was allowed or denied.
type Policy ¶
type Policy struct {
Allow []string
Deny []string
// Digest identifies the policy in the audit log: "sha256:<hex>" of the
// file it was parsed from, or "default" for the built-in policy.
Digest string
}
Policy is a parsed writgate.yaml.
func Default ¶
func Default() *Policy
Default is the policy used when no --policy file is given: only readonly tools are allowed.
func Parse ¶
Parse parses a policy from YAML. It rejects unknown keys, empty rules, and rules with characters a tool name can't contain, so a typo fails at startup instead of silently allowing or denying.
A policy must have an "allow" list, even an empty one: without it every tool would be denied, which is more likely a mistake (a deny-only file written as if the default were allow) than the intent.