enforce

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package enforce reports the session-level execution capability.

Index

Constants

View Source
const (
	HelperCommand          = "__codemeld_confine"
	ProbeArg               = "--probe"
	ControlArg             = "--control"
	SetupFailureExitCode   = 125
	ModePlan               = "plan"
	ModeAutoEdits          = "auto_edits"
	NetworkAccessAuthority = "network access"
	MaxPolicyFrameBytes    = 64 * 1024
	BrokerNone             = ""
	BrokerSlice            = "slice"
	BrokerFull             = "full"
	BrokerConnect          = "connect"
)
View Source
const HelperChannelFD = 3

Variables

View Source
var ErrBrokerUnsupported = errors.New("enforce: broker mode is not supported on this platform")

Functions

func ReceiveListener added in v0.4.11

func ReceiveListener(channel *os.File, timeout time.Duration) (*os.File, error)

func ReleaseHelper added in v0.4.11

func ReleaseHelper(channel *os.File) error

func RunHelper

func RunHelper(args []string) int

func WritePolicyFrame

func WritePolicyFrame(w io.Writer, p Policy) error

Types

type Broker added in v0.4.11

type Broker struct {
	// contains filtered or unexported fields
}

func StartBroker added in v0.4.11

func StartBroker(listener *os.File, decide ConnectDecider) (*Broker, error)

func StartConnectBroker added in v0.4.12

func StartConnectBroker(listener *os.File, rules ConnectRules, register ConnectRegistrar) (*Broker, error)

func StartRegisteringBroker added in v0.4.11

func StartRegisteringBroker(listener *os.File, decide ConnectDecider, register ConnectRegistrar) (*Broker, error)

func (*Broker) Decisions added in v0.4.12

func (b *Broker) Decisions() []ConnectDecision

func (*Broker) Refusals added in v0.4.11

func (b *Broker) Refusals() []Refusal

func (*Broker) Stop added in v0.4.11

func (b *Broker) Stop()

type Capability

type Capability string
const (
	Constrained Capability = "constrained"
	Refused     Capability = "refused"
)

type ConnectAsker added in v0.4.12

type ConnectAsker func(ctx context.Context, live func() bool, tcp netip.AddrPort, unixFD int) (step, reason string)

type ConnectDecider added in v0.4.11

type ConnectDecider func(dest netip.AddrPort) bool

type ConnectDecision added in v0.4.12

type ConnectDecision struct {
	Destination string
	Allowed     bool
	Step        string
	Reason      string
	Count       int64
}

type ConnectRegistrar added in v0.4.11

type ConnectRegistrar func(local netip.AddrPort) error

type ConnectRules added in v0.4.12

type ConnectRules struct {
	Grants     []string
	Deny       *DenyList
	Proxy      ConnectDecider
	WriteRoots []string
	TmpDir     string
	Ask        ConnectAsker
	Policy     Policy
}

type DenyList added in v0.4.12

type DenyList struct {
	// contains filtered or unexported fields
}

func NewDenyList added in v0.4.12

func NewDenyList() *DenyList

func (*DenyList) Close added in v0.4.12

func (d *DenyList) Close()

type Leg

type Leg struct {
	Name       string
	Observed   string
	Diagnostic string
}

type Policy

type Policy struct {
	Mode                 string   `json:"mode"`
	ExceptionalAuthority string   `json:"exceptional_authority"`
	BlockedPaths         []string `json:"blocked_paths"`
	WriteRoots           []string `json:"write_roots"`
	NoWritePaths         []string `json:"no_write_paths"`
	ReadRoots            []string `json:"read_roots"`
	TmpDir               string   `json:"tmp_dir"`
	TmpDirDev            uint64   `json:"tmp_dir_dev"`
	TmpDirIno            uint64   `json:"tmp_dir_ino"`
	Broker               string   `json:"broker"`
}

func ReadPolicyFrame

func ReadPolicyFrame(r io.Reader) (Policy, error)

type Refusal added in v0.4.11

type Refusal struct {
	Host, Port, Path, Reason string
}

type Resolution

type Resolution struct {
	Capability            Capability
	Reason                string
	Legs                  []Leg
	SelfTestPassed        bool
	SliceSelfTestPassed   bool
	ConnectSelfTestPassed bool
	FullSelfTestPassed    bool
}

func Resolve

func Resolve(in ResolveInput) Resolution

func (Resolution) SandboxLabel

func (r Resolution) SandboxLabel(modeKey string) string

func (Resolution) SandboxState

func (r Resolution) SandboxState(modeKey string) string

type ResolveInput

type ResolveInput struct {
	Home             string
	HelperExecutable string
}

Jump to

Keyboard shortcuts

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