Files
pmg/errcodes/codes.go
T
5131c3f641 feat(sandbox): ExecutionContext plumbing and fail-closed lockdown contract (#371)
* feat(sandbox): ExecutionContext plumbing and fail-closed lockdown contract

Network lockdown needs the PMG proxy's address, which is only known at
spawn time. Thread an ExecutionContext from the proxy flow through the
runner and executor into every sandbox driver, and enforce the
network_via_proxy_only fail-closed contract: lockdown without a running
loopback proxy, or on a driver that cannot enforce it, is a hard error —
never a silent fallback to unrestricted network.

- sandbox.ExecutionContext{ProxyAddr} + 4-arg Sandbox.Execute
- sandbox.ValidateLockdown validates the proxy address (loopback only)
  with usefulerror code SandboxRequiresProxy
- Seatbelt validates lockdown before translation (translation itself
  lands next); bubblewrap and landlock reject lockdown as unsupported
  until Linux enforcement is implemented
- executor.WithExecutionContext, runner.ExecuteOptions.SandboxProxyAddr,
  proxy flow passes the live proxy address
- ApplySandbox also validates centrally before invoking the driver

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqMU5GNBbQvQct9nxek1VS

* fix(sandbox): require numeric in-range proxy port in ValidateLockdown

The validated port string is embedded into generated sandbox profiles,
so service names, zero, and out-of-range ports are refused.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqMU5GNBbQvQct9nxek1VS

* fix(sandbox): fail closed on Seatbelt lockdown until translation lands

A lockdown policy that passed proxy validation would silently receive
the pre-lockdown network rules from the translator. Reject it until the
lockdown profile translation is implemented, keeping the window between
plumbing and enforcement fail-closed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqMU5GNBbQvQct9nxek1VS

* chore: review feedback — drop redundant comment, simplify stub help text

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PqMU5GNBbQvQct9nxek1VS

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-10 20:12:33 +05:30

43 lines
1.7 KiB
Go

package errcodes
const (
InvalidArgument = "InvalidArgument"
PermissionDenied = "PermissionDenied"
NotFound = "NotFound"
Timeout = "Timeout"
Canceled = "Canceled"
UnexpectedEOF = "UnexpectedEOF"
Lifecycle = "Lifecycle"
Network = "Network"
PackageManagerExecutionFailed = "PackageManagerExecutionFailed"
PackageManagerNotFound = "PackageManagerNotFound"
BubblewrapNotFound = "BubblewrapNotFound"
// Package manager error codes.
DependencyResolutionFailed = "DependencyResolutionFailed"
PackageParseFailed = "PackageParseFailed"
PackageAuthorNotFound = "PackageAuthorNotFound"
GitHubRateLimitExceeded = "GitHubRateLimitExceeded"
// Certificate trust store error codes.
CertGeneration = "CertGeneration"
CertPersistence = "CertPersistence"
CertTrustStore = "CertTrustStore"
UnsupportedPlatform = "UnsupportedPlatform"
// Sandbox error codes. SandboxRequiresProxy is returned when a sandbox
// policy enables network_via_proxy_only but no PMG proxy is running to
// confine traffic to.
SandboxRequiresProxy = "SandboxRequiresProxy"
// Proxy error codes. ProxyPolicyViolation is returned when the proxy blocked
// one or more packages by policy (malware, dependency cooldown, or a denied
// suspicious package) and the run was gated with --fail-on-violation.
ProxyPolicyViolation = "ProxyPolicyViolation"
// Unknown mirrors the default code that dry/usefulerror returns for errors
// created without an explicit code, so unset and explicitly-unknown errors
// classify identically (e.g. the bug-report hint in ui.ErrorExit).
Unknown = "unknown"
)