{"modulePath":"github.com/OpenSIN-Code/SIN-Code-Bundle","version":"v0.1.2","isLatest":false,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package sandbox\n\nSPDX-License-Identifier: MIT Purpose: OS-level isolation for shell command execution. On Linux it uses Landlock (kernel \u003e= 5.13) to restrict filesystem and network access. On other platforms it falls back to a no-op with an explicit warning so callers can surface degraded isolation to the user.\n\n## Functions\n\n```go\nfunc ApplyAndExec() error\n```\nApplyAndExec is called from main() when os.Args\\[1] == \"\\_\\_sandbox\\_exec\". It applies the sandbox to the current process then execs the target. On platforms without Landlock support (kernel \\\u003c 5.13) it degrades gracefully: the command still runs but with a warning.\n\n## Types\n\n```go\ntype Policy struct {\n\t// ReadOnlyPaths are directories the command may read but not modify.\n\tReadOnlyPaths []string\n\t// ReadWritePaths are directories the command may read and modify.\n\t// Typically the project workdir and a scratch temp dir — nothing else.\n\tReadWritePaths []string\n\t// AllowNetwork controls outbound network access. Default false.\n\tAllowNetwork bool\n\t// Timeout is the hard wall-clock limit for the command.\n\tTimeout time.Duration\n}\n```\nPolicy describes what a sandboxed command may access.\n\n```go\nfunc DefaultPolicy(workdir, tmpDir string) Policy\n```\nDefaultPolicy returns the recommended policy for agent bash execution: read/write only inside workdir and tmpDir, read-only system paths, no network.\n\n```go\ntype Result struct {\n\t// Enforced is true when OS-level sandboxing was active.\n\tEnforced bool\n\t// Mechanism names the isolation backend (\"landlock\", \"none\").\n\tMechanism string\n\t// Warning is non-empty when isolation is degraded.\n\tWarning string\n}\n```\nResult reports how the command was isolated.\n\n```go\nfunc Command(ctx context.Context, policy Policy, name string, args ...string) (*exec.Cmd, Result, error)\n```\nCommand builds an \\*exec.Cmd whose process is confined by the given policy where the platform supports it. The returned Result tells the caller whether enforcement is active so it can warn the user.\n\n","path":"github.com/OpenSIN-Code/SIN-Code-Bundle/cmd/sin-code/internal/sandbox","name":"sandbox","synopsis":"SPDX-License-Identifier: MIT Purpose: OS-level isolation for shell command execution.","isRedistributable":true}
