Documentation
¶
Overview ¶
Package policy is the workspace permission engine. It decides whether a shell command may run and whether a file may be written, using allow/deny globs from the workspace config, and it confines all file operations to an optional jail directory. The decision (Allow / Ask / Deny) is returned to the caller; the interactive "ask" prompt itself lives in the tool layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine resolves policy decisions for one workspace. Command globs are precompiled at construction. Allow globs match the whole command (anchored); deny globs match anywhere in the command, so a dangerous token is caught even when it's buried in `cd x && rm -rf /`.
func New ¶
New builds an Engine from a Config, resolving the jail root (relative to the workspace, symlink-followed) and precompiling the command globs.
func (*Engine) Resolve ¶
Resolve returns the absolute, symlink-resolved path for a (possibly relative) input and errors if it escapes the jail. Relative paths resolve against the jail root (or the workspace when no jail is set).
func (*Engine) Run ¶
Run decides whether a shell command may execute:
- the hard floor (dangerous base exe / rm -r…, plus configured deny globs) → Deny;
- else EVERY chained segment must match an allow glob → Allow (so an allowed prefix like "git *" can't smuggle a second command after && / |);
- else the default.