Documentation
¶
Overview ¶
Package security implements the execution-side hardening of design doc §16 and plan P3-29..P3-32: a sandboxed subprocess environment, network egress validation, secret scrubbing, and a high-risk audit trail. Everything here is deterministic — the "adversarial model review" layers (design §14.2 Layer 2/3) are a later, model-dependent phase.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EndpointHost ¶
EndpointHost returns the lowercased host (host:port) of a URL, or "" when the URL cannot be parsed or has no host. Callers use it to pin the guard to the configured model endpoint so the allowlist is never empty in production.
func Redact ¶
Redact scrubs the two secret shapes that can appear in adapter output: a credential-named KEY=value / key: value pair, and a Bearer token. It is a heuristic safety net, not a parser — the real guarantee is that secrets are injected via env and never persisted, so this only defends against a misbehaving adapter echoing them back into a result or log.
Types ¶
type Audit ¶
type Audit struct {
// contains filtered or unexported fields
}
Audit appends high-risk operation records to the audit_log table. Callers pass a DB whose schema includes audit_log (see storage.Migrate).
type AuditRow ¶
type AuditRow struct {
ID int64
TS int64
Who string
What string
Target string
Result string
Detail string
PrevHash string
}
AuditRow is one audit_log row.
type Entry ¶
type Entry struct {
Who string // actor node id
What string // operation, e.g. "native:tier2", "circuit:open", "agent:spawn"
Target string // task id / agent / command
Result string // "authorized" / "denied" / "ok" / "failed" / "open"
Detail string // extra context, never secrets
}
Entry is one high-risk operation record (plan P3-32). High-risk means any Tier-2 execution or denial, any circuit trip, and any adapter spawn — the operations whose "who / what / result" must be reconstructable later.
type NetworkGuard ¶
type NetworkGuard struct {
// contains filtered or unexported fields
}
NetworkGuard validates the endpoints an agent subprocess is pointed at (plan P3-30). The deterministic MVP enforces two things at spawn time: the model endpoint is HTTPS (so the API key never travels cleartext) and it is in an explicit allowlist. Hard Linux-level egress control (netns/iptables restricting what the subprocess can reach) is a deploy concern layered on top; this guards the one host PANDA itself hands to the adapter.
func NewNetworkGuard ¶
func NewNetworkGuard(hosts ...string) *NetworkGuard
NewNetworkGuard builds a guard allowing the given hostnames (bare or host:port). Matching is case-insensitive and treats a host:port entry as allowing the bare host too.
func (*NetworkGuard) CheckURL ¶
func (g *NetworkGuard) CheckURL(rawurl string) error
CheckURL validates a URL against the guard: it must be https and its host must be in the allowlist. localhost/127.0.0.1 is exempt from the https requirement (plaintext is fine for a local dev model), but is still subject to the host allowlist — so a guard pinned to a remote endpoint (D7) rejects localhost too.
type Sandbox ¶
type Sandbox struct {
// contains filtered or unexported fields
}
Sandbox confines an adapter subprocess to a working directory and a minimal environment (plan P3-29). It is the deterministic MVP of "the agent only reads/writes the task directory": it removes the two most common leak vectors — an inherited home directory and a full environment full of unrelated secrets. Hard Linux-level isolation (seccomp/namespaces) is a deploy concern layered on top of this.