Documentation
¶
Index ¶
- Variables
- type FSScope
- type HTTPScope
- type Permission
- type PermissionError
- type Policy
- func (p *Policy) AllowDir(dir string)
- func (p *Policy) Check(perm Permission) error
- func (p *Policy) CheckFSRead(path string) error
- func (p *Policy) CheckFSWrite(path string) error
- func (p *Policy) CheckHTTP(rawURL string) error
- func (p *Policy) CheckPath(path string) error
- func (p *Policy) CheckProcess(cmd string, args []string) error
- func (p *Policy) HasPermission(perm Permission) bool
- func (p *Policy) SetFSScope(scope FSScope)
- func (p *Policy) SetHTTPScope(scope HTTPScope)
- func (p *Policy) SetProcessScope(scope ProcessScope)
- type ProcessRule
- type ProcessScope
Constants ¶
This section is empty.
Variables ¶
var AllPermissions = []Permission{ PermFS, PermDialog, PermClipboard, PermShell, PermNotification, PermTray, PermMenu, PermHTTP, PermProcess, PermStore, PermShortcuts, PermUpdater, }
AllPermissions is the set of all declarable permissions.
Functions ¶
This section is empty.
Types ¶
type HTTPScope ¶
type HTTPScope struct {
Allow []string `json:"allow"` // allowed domain patterns (e.g., "*.github.com", "api.example.com")
Deny []string `json:"deny"` // denied domain patterns (checked first)
}
HTTPScope holds scoped HTTP permission patterns.
type Permission ¶
type Permission string
Permission represents an API permission that an app can request.
const ( PermFS Permission = "fs" PermDialog Permission = "dialog" PermClipboard Permission = "clipboard" PermShell Permission = "shell" PermNotification Permission = "notification" PermTray Permission = "tray" PermMenu Permission = "menu" PermHTTP Permission = "http" PermProcess Permission = "process" PermStore Permission = "store" PermShortcuts Permission = "shortcuts" PermUpdater Permission = "updater" )
type PermissionError ¶
type PermissionError struct {
Namespace string
Method string
Attempted string
Allowed []string
ConfigKey string
}
PermissionError is a structured permission denial error with AI-debuggable output.
func (*PermissionError) Error ¶
func (e *PermissionError) Error() string
Error returns the AI-friendly formatted error message.
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy holds the security policy for a running app.
func DevPolicy ¶
func DevPolicy() *Policy
DevPolicy creates a permissive policy for development mode.
func (*Policy) AllowDir ¶
AllowDir adds an additional allowed directory (e.g., user-selected via dialog).
func (*Policy) Check ¶
func (p *Policy) Check(perm Permission) error
Check returns an error if the given permission is not granted.
func (*Policy) CheckFSRead ¶
CheckFSRead verifies that the path is allowed for reading.
func (*Policy) CheckFSWrite ¶
CheckFSWrite verifies that the path is allowed for writing.
func (*Policy) CheckPath ¶
CheckPath verifies that a file path is within the allowed directories. It resolves symlinks to prevent traversal attacks.
func (*Policy) CheckProcess ¶
CheckProcess verifies that a command execution is allowed.
func (*Policy) HasPermission ¶
func (p *Policy) HasPermission(perm Permission) bool
HasPermission checks if a permission is granted without returning an error.
func (*Policy) SetFSScope ¶
SetFSScope configures scoped filesystem permissions with glob patterns.
func (*Policy) SetHTTPScope ¶
SetHTTPScope configures scoped HTTP permissions with domain patterns.
func (*Policy) SetProcessScope ¶
func (p *Policy) SetProcessScope(scope ProcessScope)
SetProcessScope configures scoped process execution permissions.
type ProcessRule ¶
type ProcessRule struct {
Cmd string `json:"cmd"`
Args []string `json:"args"` // if empty or contains "*", any args allowed
}
ProcessRule defines an allowed command and its permitted arguments.
type ProcessScope ¶
type ProcessScope struct {
Exec []ProcessRule `json:"exec"`
}
ProcessScope holds scoped process execution permissions.