Documentation
¶
Overview ¶
Package policy enforces path resolution, symlink guards, sensitive file protection, and Antigravity CLI settings.json permission rules.
Index ¶
- func IsApprovalRequired(err error) bool
- type Decision
- type Engine
- func (e *Engine) CheckCommand(cmdLine string) error
- func (e *Engine) CheckMCP(server, tool string) error
- func (e *Engine) LoadSettingsJSON(raw []byte)
- func (e *Engine) NativeEscalationHint() bool
- func (e *Engine) ResolveAndCheckRead(baseDir, targetPath string) (string, error)
- func (e *Engine) ResolveAndCheckWrite(baseDir, targetPath string) (string, error)
- func (e *Engine) TrustWorkspaceMCP() bool
- type Options
- type PolicyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsApprovalRequired ¶
IsApprovalRequired reports whether err indicates an interactive approval gate.
Types ¶
type Decision ¶
type Decision string
Decision represents the outcome of evaluating a capability operation.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func NewEngine ¶
NewEngine creates a policy engine rooted at workspaceDir and aligned with ~/.gemini/antigravity-cli/settings.json.
func NewEngineWithOptions ¶
NewEngineWithOptions creates a policy engine with explicit host profile options.
func (*Engine) CheckCommand ¶
CheckCommand validates a shell command against CLI permission rules and the built-in guard. Order: user deny rules > built-in guard (APPROVAL_REQUIRED) > user ask rules > user allow rules. The built-in guard is a best-effort guardrail, not a security boundary (see guards.go).
func (*Engine) CheckMCP ¶
CheckMCP validates external MCP bridge invocations against mcp(server/tool) rules.
func (*Engine) LoadSettingsJSON ¶
LoadSettingsJSON loads CLI or desktop policy JSON directly (useful for testing and custom configs). Subsequent calls override AllowNonWorkspaceAccess if set and append permission rules.
func (*Engine) NativeEscalationHint ¶
NativeEscalationHint reports whether interactive-approval errors should mention native host tools.
func (*Engine) ResolveAndCheckRead ¶
ResolveAndCheckRead resolves path against baseDir and checks read permissions.
func (*Engine) ResolveAndCheckWrite ¶
ResolveAndCheckWrite resolves path against baseDir and enforces workspace & .git confinement.
func (*Engine) TrustWorkspaceMCP ¶
TrustWorkspaceMCP reports whether MCP servers declared in `<workspace>/.agents/mcp_config.json` may be spawned. Off by default: a cloned repository must not be able to make the sandbox launch arbitrary processes. Enable with `AGY_PTC_TRUST_WORKSPACE_MCP=1` or `"agyPtcTrustWorkspaceMcp": true` in an agy-ptc policy.json.
type Options ¶
type Options struct {
ExtraRoots []string
StrictWorkspace bool // force allowNonWorkspaceAccess = false (confine to workspaceRoots)
TrustWorkspaceMCP bool // allow <workspace>/.agents/mcp_config.json
PolicyFiles []string // explicit JSON policy files to load in order
ProtectedFiles []string // additional config files (e.g. --mcp-config) protected against sandbox writes
LoadAntigravityConfig bool // load ~/.gemini/antigravity-cli/settings.json & ~/.gemini/config/agy-ptc/policy.json & PLUGIN_DATA/policy.json
NativeEscalationHint bool // include "; run it via native run_command" in DecisionAsk messages
}
Engine enforces workspace confinement, sensitive file guards, and Antigravity CLI settings.json rules. Options configures a policy Engine for either standalone MCPlex or Antigravity plugin mode.
type PolicyError ¶
type PolicyError struct {
Decision Decision
Action string
Target string
Reason string
NoNativeHint bool
}
PolicyError is returned when an operation is blocked or requires host interactive approval.
func (*PolicyError) Detail ¶
func (e *PolicyError) Detail() string
Detail is the one-line message without the kind word: `<target> — <reason>[; <how to proceed>]`.
func (*PolicyError) Error ¶
func (e *PolicyError) Error() string
func (*PolicyError) Kind ¶
func (e *PolicyError) Kind() string
Kind implements sandbox.KindedError: guest code sees `e.name` "NeedsApproval" or "Denied".