config

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SessionIDHeaderName is the fixed HTTP header name boundary injects to
	// carry its session ID. Coder AI Gateway expects exactly this header name.
	SessionIDHeaderName = "X-Coder-Agent-Firewall-Session-Id"

	// SequenceNumberHeaderName is the fixed HTTP header name boundary injects
	// to carry its per-session sequence number. Coder AI Gateway expects
	// exactly this header name.
	SequenceNumberHeaderName = "X-Coder-Agent-Firewall-Sequence-Number"

	// DefaultAIGatewayPath is the current AI Gateway route prefix glob used
	// when auto-deriving an inject target from CODER_AGENT_URL.
	DefaultAIGatewayPath = "/api/v2/ai-gateway/*"

	// DefaultAIBridgePath is the backward-compatible aibridge alias route
	// prefix glob used when auto-deriving an inject target from
	// CODER_AGENT_URL. It is transitional: once all Coder deployments serve
	// the gateway exclusively at DefaultAIGatewayPath, this alias and the
	// extra inject target derived from it in DefaultInjectTargetsFromEnv
	// should be removed.
	DefaultAIBridgePath = "/api/v2/aibridge/*"

	// CoderAgentURLEnv is the environment variable set by the Coder workspace
	// agent that points to the control plane. Boundary uses it to derive a
	// default inject target when none is explicitly configured.
	CoderAgentURLEnv = "CODER_AGENT_URL"
)

Header names and paths for session correlation.

View Source
const (
	CAKeyName  = "ca-key.pem"
	CACertName = "ca-cert.pem"
)

Variables

This section is empty.

Functions

func DefaultInjectTargetsFromEnv added in v0.10.0

func DefaultInjectTargetsFromEnv(environ []string) []string

DefaultInjectTargetsFromEnv derives inject target rule strings from the CODER_AGENT_URL variable in the provided environment slice. It returns nil if the variable is absent, empty, or not a valid URL with a host. The derived targets cover both the current AI Gateway route prefix (DefaultAIGatewayPath) and its backward-compatible aibridge alias (DefaultAIBridgePath) so that clients hitting either path on the control-plane host get correlation headers injected.

The environ parameter is accepted rather than reading os.Environ directly so that callers (and tests) can supply an arbitrary environment.

func ValidateSessionCorrelation added in v0.10.0

func ValidateSessionCorrelation(cfg SessionCorrelationConfig) error

ValidateSessionCorrelation checks that the session correlation config is internally consistent. When enabled it verifies that at least one inject target is configured and that every target string is a valid rulesengine rule. It returns an error describing the first problem found, or nil if the config is valid.

Types

type AllowStringsArray

type AllowStringsArray []string

AllowStringsArray is a custom type that implements pflag.Value to support repeatable --allow flags without splitting on commas. This allows comma-separated paths within a single allow rule (e.g., "path=/todos/1,/todos/2").

func (*AllowStringsArray) Set

func (a *AllowStringsArray) Set(value string) error

Set implements pflag.Value. It appends the value to the slice without splitting on commas.

func (AllowStringsArray) String

func (a AllowStringsArray) String() string

String implements pflag.Value.

func (AllowStringsArray) Type

func (a AllowStringsArray) Type() string

Type implements pflag.Value.

func (AllowStringsArray) Value

func (a AllowStringsArray) Value() []string

Value returns the underlying slice of strings.

type AppConfig

type AppConfig struct {
	AllowRules         []string
	LogLevel           string
	LogDir             string
	ProxyPort          int64
	PprofEnabled       bool
	PprofPort          int64
	JailType           JailType
	UseRealDNS         bool
	NoUserNamespace    bool
	TargetCMD          []string
	UserInfo           *UserInfo
	DisableAuditLogs   bool
	LogProxySocketPath string

	// SessionCorrelation controls header injection for AI Bridge
	// correlation. See SessionCorrelationConfig for details.
	SessionCorrelation SessionCorrelationConfig

	// SessionID is a UUIDv4 generated at process startup. It groups
	// all audit events produced by this boundary invocation into a
	// single session. Set by Run, not by configuration.
	SessionID uuid.UUID

	// ConfinedProcessName is the base name of the process boundary is
	// confining (e.g. "claude", "codex"), derived from TargetCMD. It is
	// reported alongside audit logs so that sessions can be attributed to
	// the process that generated them.
	ConfinedProcessName string
}

func NewAppConfigFromCliConfig

func NewAppConfigFromCliConfig(cfg CliConfig, targetCMD []string, environ []string) (AppConfig, error)

type CliConfig

type CliConfig struct {
	Config             serpent.YAMLConfigPath `yaml:"-"`
	AllowListStrings   serpent.StringArray    `yaml:"allowlist"` // From config file
	AllowStrings       AllowStringsArray      `yaml:"-"`         // From CLI flags only
	LogLevel           serpent.String         `yaml:"log_level"`
	LogDir             serpent.String         `yaml:"log_dir"`
	ProxyPort          serpent.Int64          `yaml:"proxy_port"`
	PprofEnabled       serpent.Bool           `yaml:"pprof_enabled"`
	PprofPort          serpent.Int64          `yaml:"pprof_port"`
	JailType           serpent.String         `yaml:"jail_type"`
	UseRealDNS         serpent.Bool           `yaml:"use_real_dns"`
	NoUserNamespace    serpent.Bool           `yaml:"no_user_namespace"`
	DisableAuditLogs   serpent.Bool           `yaml:"disable_audit_logs"`
	LogProxySocketPath serpent.String         `yaml:"log_proxy_socket_path"`

	// Session correlation header injection.
	SessionCorrelationEnabled serpent.Bool        `yaml:"session_correlation_enabled"`
	InjectSessionIDTarget     AllowStringsArray   `yaml:"-"`                         // From CLI flags only
	InjectSessionIDTargets    serpent.StringArray `yaml:"session_id_inject_targets"` // From config file
}

type JailType

type JailType string

JailType represents the type of jail to use for network isolation

const (
	NSJailType   JailType = "nsjail"
	LandjailType JailType = "landjail"
)

func NewJailTypeFromString

func NewJailTypeFromString(str string) (JailType, error)

type SessionCorrelationConfig added in v0.10.0

type SessionCorrelationConfig struct {
	// Enabled controls whether session correlation headers are injected.
	// Deployments without AI Bridge in front should set this to false.
	Enabled bool

	// InjectTargets is the list of raw rule specs (same syntax as --allow)
	// that should receive session correlation headers. Each string uses the
	// rulesengine "domain=... path=..." format so that inject target
	// matching is identical to allow-rule matching.
	InjectTargets []string
}

SessionCorrelationConfig holds configuration for session correlation header injection. When enabled, boundary injects its session ID and sequence number as custom headers on matching outbound requests so that an upstream AI Bridge can correlate the request back to the boundary audit event stream.

type UserInfo

type UserInfo struct {
	SudoUser  string
	Uid       int
	Gid       int
	HomeDir   string
	ConfigDir string
}

func GetUserInfo

func GetUserInfo() *UserInfo

GetUserInfo returns information about the current user, handling sudo scenarios

func (*UserInfo) CACertPath

func (u *UserInfo) CACertPath() string

func (*UserInfo) CAKeyPath

func (u *UserInfo) CAKeyPath() string

Jump to

Keyboard shortcuts

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