firewallfleet

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package firewallfleet distributes immutable policy revisions to explicitly enrolled targets. Generations are per-target CAS values, not a globally atomic deployment. SQLite is fenced per StateDir; PostgreSQL coordinates replicas.

Index

Constants

View Source
const (
	MaxTargets       = 100
	MaxRevisions     = 64
	MaxJobs          = 128
	MaxAudit         = 2048
	MaxArtifactBytes = 1 << 20
	MaxRequestBytes  = 2 << 20
	MaxSnapshotBytes = 16 << 20
)
View Source
const MaxArchivedJobs = 4096
View Source
const OperationsVersion = 1

Variables

This section is empty.

Functions

func ApprovalDigest

func ApprovalDigest(operation string, r Request) string

func Run

func Run(ctx context.Context, cfg AgentConfig, target Target) error

Run owns Target.SetPolicy exclusively. SetPolicy must atomically publish the immutable compiled pointer; Policy/Evaluate may be concurrent. Polling is bounded; one joined watchdog independently expires MaxStale readiness. Run returns only on configuration, persistence initialization, or context cancellation; outages are status events. A cold agent does not trust the target's initial Policy as initialized. Cancellation is checked at application/publication decisions; cancellation after a check can race that external call. Shutdown publishes unready before joining the watchdog, including when cancellation occurs between polls.

Types

type Ack

type Ack struct {
	Revision   string `json:"revision"`
	Generation int64  `json:"generation"`
	Error      string `json:"error,omitempty"`
	Draining   bool   `json:"draining,omitempty"`
	Revoked    bool   `json:"revoked,omitempty"`
}

type AgentConfig

type AgentConfig struct {
	URL            string
	Token          string
	TargetID       string
	Scope          Scope
	StateDir       string
	PollInterval   time.Duration
	RequestTimeout time.Duration
	AllowEffects   bool
	// MaxStale=0 retains last-known policy indefinitely. A positive value makes
	// readiness false after that outage; the caller must drain on Ready=false.
	MaxStale  time.Duration
	Transport http.RoundTripper
	OnStatus  func(AgentStatus)
}

type AgentStatus

type AgentStatus struct {
	Ready       bool
	Generation  int64
	Revision    string
	LastContact time.Time
	Error       string
	Draining    bool
	Revoked     bool
}

type Audit

type Audit struct {
	ID                int64             `json:"id"`
	Time              time.Time         `json:"time"`
	Actor             string            `json:"actor"`
	Operation         string            `json:"operation"`
	Scope             Scope             `json:"scope"`
	Object            string            `json:"object"`
	Grant             string            `json:"grant,omitempty"`
	Outcome           string            `json:"outcome,omitempty"`
	Reason            string            `json:"reason,omitempty"`
	Revision          string            `json:"revision,omitempty"`
	PreviousRevision  string            `json:"previous_revision,omitempty"`
	Generation        int64             `json:"generation,omitempty"`
	Correlation       string            `json:"correlation,omitempty"`
	Targets           []string          `json:"targets,omitempty"`
	PreviousRevisions map[string]string `json:"previous_revisions,omitempty"`
}

type AuditPage

type AuditPage struct {
	Version   int     `json:"version"`
	Records   []Audit `json:"records"`
	Next      int64   `json:"next"`
	Oldest    int64   `json:"oldest"`
	More      bool    `json:"more"`
	Truncated bool    `json:"truncated"`
}

type Config

type Config struct {
	Approvals   *firewallauth.Approvals
	Auth        *firewallauth.Authority
	Environment string
	Origin      string
	// AuditRequired refuses mutations when the retained audit is full. Export
	// does not acknowledge deletion; retention remains an explicit operator choice.
	AuditRequired       bool
	AuditRetention      time.Duration
	AuditMaxRecords     int
	JobReceiptRetention time.Duration
	StateDir            string
	DatabaseURL         string
	DatabaseNamespace   string
	Token               string
	Identities          []Identity
	Targets             []Enrollment
	AllowEffects        bool
	RollbackOnFailure   bool
}

type Desired

type Desired struct {
	Version    int             `json:"version"`
	TargetID   string          `json:"target_id"`
	Scope      Scope           `json:"scope"`
	Generation int64           `json:"generation"`
	Revision   string          `json:"revision"`
	Hash       string          `json:"hash"`
	Bundle     json.RawMessage `json:"bundle,omitempty"`
	Deadline   time.Time       `json:"deadline"`
	Draining   bool            `json:"draining,omitempty"`
	Revoked    bool            `json:"revoked,omitempty"`
}

type Enrollment

type Enrollment struct {
	ID    string
	Token string
	Scope Scope
}

Enrollment is bootstrap-only. The controller binds token to ID/tenant/app; agents cannot enroll themselves or provide their own attachment scope.

type Identity

type Identity struct {
	Role  string `json:"role,omitempty"`
	ID    string
	Token string
	Scope Scope
}

type Job

type Job struct {
	ID                string            `json:"id"`
	Scope             Scope             `json:"scope"`
	Revision          string            `json:"revision"`
	Targets           []string          `json:"targets"`
	Canary            []string          `json:"canary"`
	Expected          map[string]int64  `json:"expected"`
	Previous          map[string]string `json:"previous"`
	Applied           map[string]int64  `json:"applied"`
	Phase             string            `json:"phase"`
	Deadline          time.Time         `json:"deadline"`
	RollbackOnFailure bool              `json:"rollback_on_failure,omitempty"`
	Failure           string            `json:"failure,omitempty"`
}

type JobReceipt

type JobReceipt struct {
	Scope   Scope     `json:"scope"`
	Expires time.Time `json:"expires"`
}

type MaintenanceResult

type MaintenanceResult struct {
	RolledBack []string `json:"rolled_back"`
	Blocked    []string `json:"blocked"`
}

type Request

type Request struct {
	Approval          *firewallauth.ApprovalRequest `json:"approval,omitempty"`
	Receipt           string                        `json:"receipt,omitempty"`
	Revisions         []string                      `json:"revisions,omitempty"`
	Jobs              []string                      `json:"jobs,omitempty"`
	Receipts          []string                      `json:"receipts,omitempty"`
	ExpectedPlan      string                        `json:"expected_plan,omitempty"`
	After             int64                         `json:"after,omitempty"`
	Limit             int                           `json:"limit,omitempty"`
	Scope             Scope                         `json:"scope"`
	Bundle            string                        `json:"bundle,omitempty"`
	Revision          string                        `json:"revision,omitempty"`
	ID                string                        `json:"id,omitempty"`
	Targets           []string                      `json:"targets,omitempty"`
	Canary            []string                      `json:"canary,omitempty"`
	Expected          map[string]int64              `json:"expected,omitempty"`
	Deadline          time.Time                     `json:"deadline,omitempty"`
	ExpectedPhase     string                        `json:"expected_phase,omitempty"`
	RollbackOnFailure bool                          `json:"rollback_on_failure,omitempty"`
}

type RetentionReport

type RetentionReport struct {
	Version          int                  `json:"version"`
	Plan             string               `json:"plan"`
	Revisions        []string             `json:"revisions"`
	Jobs             []string             `json:"jobs"`
	Receipts         []string             `json:"receipts"`
	ReceiptInventory map[string]time.Time `json:"receipt_inventory"`
	Protected        []string             `json:"protected"`
}

RetentionReport fences all snapshot fields, including acknowledgements and enrollments, at the transaction's authoritative read.

type Scope

type Scope = firewallstate.Scope

type Service

type Service struct {
	Operations *runtimeobs.Monitor
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Service, error)

func (*Service) Acknowledge

func (s *Service) Acknowledge(ctx context.Context, token string, a Ack) error

func (*Service) Backup

func (s *Service) Backup(ctx context.Context, path string) error

func (*Service) Close

func (s *Service) Close() error

func (*Service) Desired

func (s *Service) Desired(ctx context.Context, token string) (Desired, error)

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, token, op string, r Request) (any, error)

Execute is the authenticated administrative REST/MCP boundary. Target tokens cannot invoke this API; HTTP desired/ack derive their attachment from enrollment.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler includes authenticated REST and streamable MCP. Serve with TLS for remote peers and http.Server ReadHeaderTimeout/ReadTimeout/WriteTimeout set. Desired and ack never read tenant, app, or target ID from caller input.

func (*Service) Maintain

func (s *Service) Maintain(ctx context.Context) (MaintenanceResult, error)

Maintain checks at most MaxJobs, with no owned goroutine or timer. The trusted main integration should call it periodically even when transports are idle. Scoped status, desired polling, and acknowledgments also drive maintenance.

func (*Service) WaitConverged

func (s *Service) WaitConverged(ctx context.Context, token string, scope Scope, jobID string) error

WaitConverged observes acknowledgements only; a transport ack cannot prove every in-flight request has finished under the old revision.

type Status

type Status struct {
	Targets      map[string]*TargetState `json:"targets"`
	Jobs         []*Job                  `json:"jobs"`
	Coordination string                  `json:"coordination"`
}

type Target

type Target interface {
	Policy() *policy.Compiled
	SetPolicy(*policy.Compiled)
}

type TargetState

type TargetState struct {
	ID                 string    `json:"id"`
	Scope              Scope     `json:"scope"`
	TokenHash          string    `json:"token_hash,omitempty"`
	DesiredRevision    string    `json:"desired_revision"`
	PreviousRevision   string    `json:"previous_revision"`
	Generation         int64     `json:"generation"`
	ObservedRevision   string    `json:"observed_revision"`
	ObservedGeneration int64     `json:"observed_generation"`
	LastSeen           time.Time `json:"last_seen"`
	Error              string    `json:"error,omitempty"`
	Deadline           time.Time `json:"deadline"`
	Draining           bool      `json:"draining,omitempty"`
	Revoked            bool      `json:"revoked,omitempty"`
	ObservedDraining   bool      `json:"observed_draining,omitempty"`
	ObservedRevoked    bool      `json:"observed_revoked,omitempty"`
}

Jump to

Keyboard shortcuts

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