sandbox

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReasonFSOutOfScope               = "fs_out_of_scope"
	ReasonExecNotAllowed             = "exec_not_allowed"
	ReasonNetworkNotAllowed          = "network_not_allowed"
	ReasonApprovalRequired           = "approval_required"
	ReasonApprovalChannelUnavailable = "approval_channel_unavailable"
	ReasonDeniedDependency           = "denied_dependency"
)
View Source
const (
	LeaseVersionV1 = "v1"
	LeaseScopeRun  = "run"
)
View Source
const (
	ReasonLeaseExpired          = "lease_expired"
	ReasonLeaseSignatureInvalid = "lease_signature_invalid"
	ReasonLeaseInvalid          = "lease_invalid"
)
View Source
const LeaseSchemaV1JSON = `` /* 2522-byte string literal not displayed */

Variables

This section is empty.

Functions

func CanonicalPayload

func CanonicalPayload(lease Lease) ([]byte, error)

func ParseHMACKeyring

func ParseHMACKeyring(raw string) (map[string][]byte, error)

func ValidateLease

func ValidateLease(lease Lease, now time.Time) error

func VerifySignedLease

func VerifySignedLease(lease Lease, keyring map[string][]byte, now time.Time) error

Types

type Decision

type Decision string
const (
	DecisionAllow    Decision = "allow"
	DecisionDeny     Decision = "deny"
	DecisionEscalate Decision = "escalate"
)

type DecisionInput

type DecisionInput struct {
	Lease   Lease
	Keyring map[string][]byte
	Now     time.Time
	Static  StaticPolicy
	Mode    ModeContext
	Request RuntimeRequest
}

type DecisionResult

type DecisionResult struct {
	Decision   Decision
	ReasonCode string
	Message    string
}

type ExecRule

type ExecRule struct {
	Command     string   `json:"command"`
	ArgsPattern []string `json:"args_pattern"`
}

type FileAccess

type FileAccess string
const (
	FileAccessRead  FileAccess = "read"
	FileAccessWrite FileAccess = "write"
)

type Lease

type Lease struct {
	Version          string        `json:"version"`
	LeaseID          string        `json:"lease_id"`
	RunID            string        `json:"run_id"`
	Scope            string        `json:"scope"`
	IssuedAt         time.Time     `json:"issued_at"`
	ExpiresAt        time.Time     `json:"expires_at"`
	KID              string        `json:"kid"`
	ApprovalMode     string        `json:"approval_mode"`
	AwayPolicy       string        `json:"away_policy"`
	FSRead           []string      `json:"fs_read"`
	FSWrite          []string      `json:"fs_write"`
	ExecAllowlist    []ExecRule    `json:"exec_allowlist"`
	NetworkAllowlist []NetworkRule `json:"network_allowlist"`
	Signature        string        `json:"signature,omitempty"`
}

func SignLease

func SignLease(lease Lease, key []byte) (Lease, error)

type LeaseError

type LeaseError struct {
	Code    string
	Message string
	Cause   error
}

func (*LeaseError) Error

func (e *LeaseError) Error() string

func (*LeaseError) Unwrap

func (e *LeaseError) Unwrap() error

type ModeContext

type ModeContext struct {
	ApprovalMode             string
	AwayPolicy               string
	ApprovalChannelAvailable bool
}

type NetworkRule

type NetworkRule struct {
	Host   string `json:"host"`
	Port   int    `json:"port"`
	Scheme string `json:"scheme"`
}

type PolicyBroker

type PolicyBroker interface {
	Decide(context.Context, DecisionInput) (DecisionResult, error)
}

func NewPolicyBroker

func NewPolicyBroker() PolicyBroker

type RuntimeRequest

type RuntimeRequest struct {
	ToolName         string
	FilePath         string
	FileAccess       FileAccess
	Command          string
	Args             []string
	Network          NetworkRule
	RequiresApproval bool
}

type StaticPolicy

type StaticPolicy struct {
	ApprovalPolicy string
}

Jump to

Keyboard shortcuts

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