guard

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package guard defines the foundational action classification, safety level, and protected workspace directory primitives shared across shellguard and tools.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

View Source
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.

View Source
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

func HostCredentialPaths(workDir string) []string

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

func IsProtectedPath(targetPath, workspaceDir string, protectedDirs ...string) bool

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

func IsProtectedTarget(targetPath, workDir, homeDir string) bool

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

func IsSecretEnvFile(name string) bool

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

func IsSensitivePath(targetPath, homeDir string) bool

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

func IsSensitiveWritePath(targetPath, homeDir string) bool

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

func ProtectedWorkspaceWritePaths(workDir string) []string

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).

Types

type PathConfig

type PathConfig struct {
	WorkspaceDir  string
	HomeDir       string
	ProtectedDirs []string
	ReadDirs      []string
	WriteDirs     []string
}

PathConfig encapsulates the path configuration used by EvaluatePathWithConfig.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL