Documentation
¶
Overview ¶
Package guard defines the foundational action classification, safety level, and protected workspace directory primitives shared across shellguard and tools.
Index ¶
- Variables
- func EvaluatePath(targetPath, workspaceDir, homeDir string, action api.ActionType, ...) (string, api.SafetyLevel)
- func EvaluatePathWithConfig(targetPath string, action api.ActionType, cfg PathConfig) (string, api.SafetyLevel)
- func HostCredentialPaths(workDir string) []string
- func IsProtectedPath(targetPath, workspaceDir string, protectedDirs ...string) bool
- func IsProtectedTarget(targetPath, workDir, homeDir string) bool
- func IsSecretEnvFile(name string) bool
- func IsSensitivePath(targetPath, homeDir string) bool
- func IsSensitiveWritePath(targetPath, homeDir string) bool
- func ProtectedWorkspaceWritePaths(workDir string) []string
- func TasksmithConfigPaths() []string
- func TasksmithSecretPaths() []string
- type PathConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultProtectedDirs = []string{".git", ".bare", ".agents"}
DefaultProtectedDirs is the default list of protected workspace directories where write, delete, or exec operations are classified as SafetyUnsafe.
var DefaultSensitiveHomeDirs = []string{
".ssh",
".aws",
".gnupg",
".kube",
".docker",
".netrc",
}
DefaultSensitiveHomeDirs is the list of credential/key directory and file names that are always classified as SafetyUnsafe even for read-only operations.
var DefaultSensitivePaths = []string{
"/etc",
"/private/etc",
"/System",
"/proc",
"/sys",
"/dev",
"/boot",
"/root",
"/var/root",
}
DefaultSensitivePaths is the list of system directory prefixes that are always classified as SafetyUnsafe even for read-only operations.
var ProtectedWorkspaceWriteFiles = []string{".bashrc", ".zshrc", ".profile", ".gitconfig"}
ProtectedWorkspaceWriteFiles lists workspace-root shell and Git startup files whose modification lets a child process inject code into every later execution, so they must stay read-only at the kernel level.
Functions ¶
func EvaluatePath ¶
func EvaluatePath(targetPath, workspaceDir, homeDir string, action api.ActionType, protectedDirs ...string) (string, api.SafetyLevel)
EvaluatePath resolves targetPath against workspaceDir (and expands ~ with homeDir) and classifies its SafetyLevel for the given ActionType.
func EvaluatePathWithConfig ¶
func EvaluatePathWithConfig(targetPath string, action api.ActionType, cfg PathConfig) (string, api.SafetyLevel)
EvaluatePathWithConfig resolves targetPath against cfg.WorkspaceDir (and expands ~ with cfg.HomeDir) and classifies its SafetyLevel for the given ActionType:
- Sensitive system or credential paths always return SafetyUnsafe.
- Paths inside cfg.WriteDirs (with symlink confinement) return SafetySafe for ActionRead, ActionWrite, ActionDelete, and SafetyUnsafe for other actions.
- TaskSmith's own sandbox.json and workspace config store return SafetyUnsafe for any non-read action (reads stay permitted).
- Paths inside cfg.WorkspaceDir return SafetyUnsafe if targeting a protected directory with a non-read action, or SafetySafe otherwise.
- Paths inside cfg.ReadDirs return SafetySafe for ActionRead, and SafetyUnsafe for other actions.
- Otherwise (outside cfg.WorkspaceDir, cfg.WriteDirs, cfg.ReadDirs): returns SafetyOutside for ActionRead, or SafetyUnsafe for non-read actions.
func HostCredentialPaths ¶
HostCredentialPaths returns canonical absolute host paths holding user or TaskSmith secrets that native OS sandbox profiles must block child processes from reading: every entry in DefaultSensitiveHomeDirs under the user's home directory plus TaskSmith's XDG secret stores.
Candidates are returned even when they do not exist yet so secrets created mid-session (e.g. an OAuth login or /setup writing the credential store) land behind an already-active kernel rule. Each candidate is canonicalized via fsutils.ResolveDeepestExisting before overlap detection so a dotfiles workspace whose ~/.ssh symlinks into workDir stays readable while unrelated workspaces mask the resolved target.
func IsProtectedPath ¶
IsProtectedPath reports whether targetPath (either workspace-relative or absolute within workspaceDir) resides inside any of the specified protected directories. If protectedDirs is empty, DefaultProtectedDirs is used.
func IsProtectedTarget ¶
IsProtectedTarget reports whether targetPath (or its symlink-resolved target) points to a secret/credential file, TaskSmith XDG config/data store, home startup dotfile, or workspace control-plane path (.git, .bare, .agents, WORKSPACE.md, workspace startup dotfiles).
func IsSecretEnvFile ¶
IsSecretEnvFile reports whether name (a file's base name) is a dotenv secret file (such as ".env" or ".env.local") while allowing safe template suffixes (".example", ".sample", ".template").
func IsSensitivePath ¶
IsSensitivePath reports whether targetPath points to a sensitive system path (e.g. /etc, /proc, /dev), user credential path (e.g. ~/.ssh, ~/.aws), or TaskSmith's own global XDG secret stores.
func IsSensitiveWritePath ¶
IsSensitiveWritePath reports whether targetPath must be treated as sensitive for modification or deletion (as opposed to reading): every path IsSensitivePath covers, plus TaskSmith's own sandbox.json and workspace configuration store, which a tool or sandboxed process must never rewrite.
func ProtectedWorkspaceWritePaths ¶
ProtectedWorkspaceWritePaths returns canonical absolute host paths that native OS sandbox profiles must keep read-only for child processes even when they sit inside the sandbox work directory: the workspace's agent resource directory and manifest (.agents, WORKSPACE.md), Git tampering surfaces (.git/hooks, .git/config), workspace-root shell/Git startup dotfiles, and TaskSmith's own XDG config and data stores (which hold sandbox.json and permissions.json, so a sandboxed process must never be able to escalate its own next invocation).
Candidates are returned even when they do not exist yet so a file created mid-session lands behind an already-active kernel rule. Workspace entries anchor on both the logical and symlink-resolved root without dereferencing the leaf, so a planted symlink at a protected location cannot be unlinked and replaced from inside the sandbox.
func TasksmithConfigPaths ¶
func TasksmithConfigPaths() []string
TasksmithConfigPaths returns the host locations holding TaskSmith's own runtime configuration: $XDG_CONFIG_HOME/tasksmith/sandbox.json and the per-project workspace store under $XDG_DATA_HOME/tasksmith/workspaces/. Reads stay permitted (the daemon and /sandbox view must read them), but tools and sandboxed processes must never modify them, since they define the isolation and approval posture of the next invocation.
func TasksmithSecretPaths ¶
func TasksmithSecretPaths() []string
TasksmithSecretPaths returns TaskSmith's own global secret locations under XDG config and data directories ($XDG_CONFIG_HOME/tasksmith/.env, $XDG_DATA_HOME/tasksmith/credentials, and $XDG_DATA_HOME/tasksmith/mcp).