egresspolicy

package
v0.0.0-...-70d2dba Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package egresspolicy holds what the VM has been told about the egress policy its session runs under.

The policy itself lives outside the VM: a session's allowlist is enforced by Kernel's egress proxy, which is the only component that knows which destinations are allowed. The VM is told one thing — that an allowlist exists — because some of what it can be asked to do would route traffic around that proxy, and it cannot refuse those requests without knowing the session is filtered at all.

Index

Constants

View Source
const DefaultStatePath = "/run/kernel/egress-policy.json"

DefaultStatePath is where the policy is kept so it survives a restart of the API process, which supervisord does automatically. Alongside the fork identity, since both are per-boot state the control plane hands the VM.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State is the session's egress policy as the control plane last reported it.

It is held on disk as well as in memory. The API process is restarted automatically if it dies, and a restart that came back unfiltered would drop the refusal silently while the session's allowlist was still being enforced at the proxy — the gap would be invisible from outside the VM.

func Load

func Load(path string, logger *slog.Logger) *State

Load reads the policy left by a previous run of the process. A session that has never been told anything is unfiltered, which is how every session behaved before the policy existed.

A file that exists but cannot be read is treated as filtered. It should not happen — the file is written atomically — but the alternative is to resolve an unreadable security control in the direction that switches it off.

func (*State) Filtered

func (s *State) Filtered() bool

Filtered reports whether the session's egress is restricted to an allowlist. It is read on the CDP proxy's forwarding path, ahead of the message it is deciding about, so it is a lock-free load.

func (*State) SetFiltered

func (s *State) SetFiltered(filtered bool) error

SetFiltered records the policy the control plane applied, and does not take effect unless it was persisted: a caller that is told the policy is applied must be able to rely on it surviving a restart.

It is called when the session is set up and again whenever an allowlist is added to or removed from a running session, so it is safe to call repeatedly with the same value.

Jump to

Keyboard shortcuts

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