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

auditstream

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package auditstream pushes the audit log to audit sinks as it is written (R-382, R-383, design 12 §5).

It runs on the leader alone (R-256): one delivering replica, so a destination never receives two interleaved copies of the stream. Sinks are built from their rows on every pass, as core/imageregistry builds registries, so a rotated token is what the next pass sends with on whichever replica leads, with no restart.

An adapter is handed encoded events and nothing else. This package reads the log through audit.Reader, which cannot write it (R-027), and records where each sink has got to in audit_sink_state.

Index

Constants

View Source
const DefaultBatch = 500

DefaultBatch is a batch's size when an adapter does not say.

View Source
const DefaultInterval = 2 * time.Second

DefaultInterval is how often a quiet pass runs. While any sink is behind, passes run back to back.

Variables

This section is empty.

Functions

func Describe

func Describe(st Status) string

Describe is the one-line disclosure the console shows beside the audit log for an enabled sink (R-385).

Types

type ConfigStore

type ConfigStore interface {
	List(ctx context.Context) ([]state.AdapterConfig, error)
}

ConfigStore lists stored adapters (state.Adapters).

type CredentialStore

type CredentialStore interface {
	Resolve(ctx context.Context, adapterID string) (map[string]secret.Value, error)
}

CredentialStore opens an adapter's sealed credentials (state.AdapterCredentials).

type Declared

type Declared struct {
	ID      string
	Adapter api.AuditSinkAdapter
}

Declared is an audit sink the startup configuration declares, already configured.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, n api.Notification) error
}

Notifier sends Pando's own notifications.

type Service

type Service struct {
	Configs     ConfigStore
	Credentials CredentialStore
	Declared    []Declared

	// New returns an unconfigured adapter of a kind, or nil.
	New func(kind string) api.AuditSinkAdapter

	States *state.AuditSinks
	Reader *audit.Reader

	// Encoders turn native lines into a sink's format. A format with no
	// encoder — native — is sent as read.
	Encoders map[string]audit.Encoder

	// Audit writes the sink's own events: its first failure, its recovery,
	// and Pando turning it off (R-383).
	Audit func(ctx context.Context, e audit.Event)

	Holders  VerbHolders
	Notifier Notifier

	Clock    clock.Clock
	Logger   *zap.Logger
	Interval time.Duration
	// contains filtered or unexported fields
}

Service delivers the audit log to every enabled audit sink.

func (*Service) Holding

func (s *Service) Holding(ctx context.Context, lo, hi time.Time) ([]string, error)

Holding names the enabled sinks that have not been sent every event in [lo, hi): the archiver keeps such a month in the live log (R-386). A sink Pando turned off does not hold.

func (*Service) Pass

func (s *Service) Pass(ctx context.Context) (bool, error)

Pass sends one batch to every sink that is due. It reports whether any sink is still behind.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run delivers until ctx ends: a pass every Interval while every sink is caught up, and back to back while any is behind.

func (*Service) Statuses

func (s *Service) Statuses(ctx context.Context) ([]Status, error)

Statuses lists every audit sink, enabled or not, with where it has got to.

func (*Service) Validate

func (s *Service) Validate(ctx context.Context, id, kind string, config json.RawMessage, given map[string]secret.Value) error

Validate configures a sink as it would be saved — config and the credentials given, beside the ones already stored for id that are not replaced — and returns the adapter's refusal, so a sink Pando could not send with is refused when it is saved rather than at its first send. A credential sent empty removes the stored one, as saving does.

type Status

type Status struct {
	ID       string `json:"id"`
	Kind     string `json:"kind"`
	Name     string `json:"name"`
	Enabled  bool   `json:"enabled"`
	Declared bool   `json:"declared,omitempty"`

	Transport string   `json:"transport,omitempty"`
	Endpoint  string   `json:"endpoint,omitempty"`
	Format    string   `json:"format,omitempty"`
	Actions   []string `json:"actions,omitempty"`
	Exclude   []string `json:"exclude,omitempty"`

	// Backlog is how many events are past the cursor, at most BacklogCap;
	// BacklogCapped says there are at least that many.
	Backlog       int  `json:"backlog"`
	BacklogCapped bool `json:"backlog_capped,omitempty"`

	// Unusable is why the sink cannot be built from its settings.
	Unusable string `json:"unusable,omitempty"`

	state.AuditSinkState
}

Status is one sink as the console, API, CLI and MCP show it (R-383, R-385).

type VerbHolders

type VerbHolders interface {
	InstallVerbHolders(ctx context.Context, verb authz.Verb) ([]string, error)
}

VerbHolders lists the people holding an install verb (state.AuthzStore).

Jump to

Keyboard shortcuts

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