enforce

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 33 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"
)
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 StartRegisteringBroker added in v0.4.11

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

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 ConnectDecider added in v0.4.11

type ConnectDecider func(dest netip.AddrPort) bool

type ConnectRegistrar added in v0.4.11

type ConnectRegistrar func(local netip.AddrPort) error

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, Reason string
}

type Resolution

type Resolution struct {
	Capability          Capability
	Reason              string
	Legs                []Leg
	SelfTestPassed      bool
	SliceSelfTestPassed 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