Help us shape the future of Go! Take the 2026 Go Developer Survey

securitystate

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Classification of the run's protected settings files and blocked paths, and the typed refusal a covered structured-tool call produces before it is authorized.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Label

type Label string
const (
	LabelAdded      Label = "added"
	LabelRemoved    Label = "removed"
	LabelChanged    Label = "changed"
	LabelMalformed  Label = "malformed"
	LabelUnreadable Label = "unreadable"
	LabelMissing    Label = "missing"
)

type LayerKind

type LayerKind string
const (
	LayerGlobal  LayerKind = "global"
	LayerProject LayerKind = "project"
	LayerLocal   LayerKind = "local"
)

type LayerSnapshot

type LayerSnapshot struct {
	Kind    LayerKind
	Path    string
	Ignored bool
	Present bool
	Raw     map[string]any
}

LayerSnapshot is one settings layer as bootstrap admitted it, handed to a monitor so the baseline is the content the launch actually loaded rather than a later re-read. Ignored carries a configured project path the trust gate refused: it is retained so the launch can state what it is not watching, and the monitor never opens or locks it.

type Monitor

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

Monitor holds a runtime-local baseline of the protected settings the launch admitted and compares later checkpoint reads against it. It never touches the live authorization or configuration cache: a checkpoint reports what changed on disk and changes nothing.

func NewMonitor

func NewMonitor(layers []LayerSnapshot) *Monitor

func (*Monitor) AdvanceBaseline

func (m *Monitor) AdvanceBaseline(path string, prior, next Projection) bool

AdvanceBaseline replaces the baseline for path when prior still matches the retained one, so a confirmed publication only advances the state it was computed against. A caller whose prior no longer matches has raced another writer and its change stays visible as drift.

func (*Monitor) Checkpoint

func (m *Monitor) Checkpoint() []Result

Checkpoint compares every admitted layer against its baseline and returns one result per affected layer, in the order the layers were admitted (global first). A layer that matches its baseline — including an admitted path that was absent and still is — yields no result.

type Policy

type Policy struct {
	// Entries must be absolute: a relative entry matches no endpoint and protects nothing.
	SettingsPaths []string
	Blocked       *permissions.BlockedPaths
}

func (Policy) Guards

func (p Policy) Guards() bool

func (Policy) ProtectedIn

func (p Policy) ProtectedIn(root string) ([]string, error)

ProtectedIn returns every protected identity inside root, hardlink aliases included. A protected file that does not exist cannot be aliased and is skipped; any other stat or directory-read failure is returned, so a caller that cannot enumerate the whole set refuses rather than acting on a partial one.

func (Policy) RefuseBlockedVCS

func (p Policy) RefuseBlockedVCS(tool, cwd string, risky func(protectedIn func(root string) ([]string, error)) bool) *Refusal

func (Policy) RefuseNominal

func (p Policy) RefuseNominal(tool string, args map[string]any, home, baseDir string) *Refusal

RefuseNominal classifies a covered call's raw endpoint arguments, so a target an operation-specific resolver would reject is still refused as protected state.

func (Policy) RefuseResolved

func (p Policy) RefuseResolved(tool string, endpoints ...string) *Refusal

func (Policy) RefuseShell

func (p Policy) RefuseShell(subjectKind, subject, folder string, candidates []string) *Refusal

func (Policy) RefuseVCS

func (p Policy) RefuseVCS(tool, cwd string, risky bool) *Refusal

type Projection

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

Projection is the protected view of one settings layer. It holds credentials in memory and is only ever compared against another projection — never rendered, logged, hashed, or persisted.

func Project

func Project(raw map[string]any) Projection

Project builds the protected view of an already-validated settings layer.

type Refusal

type Refusal struct {
	SubjectKind          string
	Subject              string
	PathScope            string
	Envelope             string
	Source               string
	Entry                string
	EntrySource          string
	ArgumentHash         string
	DirectRequestSubject string
}

func (*Refusal) Error

func (r *Refusal) Error() string

type Result

type Result struct {
	Kind        LayerKind
	Path        string
	Unavailable bool
	Reason      locks.LockReason
	Sections    []Section
	Labels      []Label
}

Result is one layer's checkpoint outcome. It is metadata only: no settings content, permission argument, credential, token, account identifier, or provider name reaches it. Unavailable means the layer could not be inspected under its lock and carries no labels, which is distinct from inspecting it and finding it unreadable.

type Section

type Section string

Section names a protected area of a settings layer. The vocabulary is closed and never carries a configured provider name, which is unbounded user text.

const (
	SectionPermissions           Section = "permissions"
	SectionAuth                  Section = "auth"
	SectionProviderDestination   Section = "provider_destination"
	SectionProviderCredential    Section = "provider_credential"
	SectionProviderAuthHeader    Section = "provider_auth_header"
	SectionWebResearchCredential Section = "web_research_credential"
	SectionDeclaredCommands      Section = "declared_commands"
	SectionBlockedPaths          Section = "blocked_paths"
	SectionWritableFolders       Section = "writable_folders"
)

Jump to

Keyboard shortcuts

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