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
- func ApprovalDigest(operation string, r Request) string
- func Run(ctx context.Context, cfg AgentConfig, target Target) error
- type Ack
- type AgentConfig
- type AgentStatus
- type Audit
- type AuditPage
- type Config
- type Desired
- type Enrollment
- type Identity
- type Job
- type JobReceipt
- type MaintenanceResult
- type Request
- type RetentionReport
- type Scope
- type Service
- func (s *Service) Acknowledge(ctx context.Context, token string, a Ack) error
- func (s *Service) Backup(ctx context.Context, path string) error
- func (s *Service) Close() error
- func (s *Service) Desired(ctx context.Context, token string) (Desired, error)
- func (s *Service) Execute(ctx context.Context, token, op string, r Request) (any, error)
- func (s *Service) Handler() http.Handler
- func (s *Service) Maintain(ctx context.Context) (MaintenanceResult, error)
- func (s *Service) WaitConverged(ctx context.Context, token string, scope Scope, jobID string) error
- type Status
- type Target
- type TargetState
Constants ¶
const ( MaxTargets = 100 MaxRevisions = 64 MaxJobs = 128 MaxAudit = 2048 MaxArtifactBytes = 1 << 20 MaxRequestBytes = 2 << 20 MaxSnapshotBytes = 16 << 20 )
const MaxArchivedJobs = 4096
const OperationsVersion = 1
Variables ¶
This section is empty.
Functions ¶
func ApprovalDigest ¶
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 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 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 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 ¶
Enrollment is bootstrap-only. The controller binds token to ID/tenant/app; agents cannot enroll themselves or provide their own attachment 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 MaintenanceResult ¶
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 (*Service) Acknowledge ¶
func (*Service) Execute ¶
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 ¶
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.
type Status ¶
type Status struct {
Targets map[string]*TargetState `json:"targets"`
Jobs []*Job `json:"jobs"`
Coordination string `json:"coordination"`
}
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"`
}