Documentation
¶
Overview ¶
Package auditanchor publishes the signed audit chain head to storage the operator controls, so a rewrite of the whole chain on this box is detectable.
Index ¶
Constants ¶
const ( EnvDir = "APP_AUDIT_ANCHOR_DIR" EnvURL = "APP_AUDIT_ANCHOR_URL" EnvInterval = "APP_AUDIT_ANCHOR_INTERVAL" EnvTimeout = "APP_AUDIT_ANCHOR_TIMEOUT" // FileName is the append-only export inside EnvDir. FileName = "audit-anchors.jsonl" )
Environment variables that turn the anchor on and tune it.
const ( EnvQueue = "APP_AUDIT_ANCHOR_QUEUE" EnvAttempts = "APP_AUDIT_ANCHOR_ATTEMPTS" EnvBackoff = "APP_AUDIT_ANCHOR_BACKOFF" EnvBackoffMax = "APP_AUDIT_ANCHOR_BACKOFF_MAX" // SignatureHeader carries "sha256=" plus the hex HMAC of the request body. SignatureHeader = "X-Levelrail-Signature" )
Tunables for the webhook exporter; the destination itself is a runtime setting.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
Config says where anchors go. Both sinks are optional; with neither set the feature is off.
func ConfigFromEnv ¶
ConfigFromEnv reads the APP_AUDIT_ANCHOR_* variables; bad durations fall back to the defaults.
type ExportConfig ¶
type ExportConfig struct {
Queue int
Attempts int
Backoff time.Duration
BackoffMax time.Duration
Timeout time.Duration
}
ExportConfig bounds the queue and the retry schedule.
func ExportConfigFromEnv ¶
func ExportConfigFromEnv(lookup func(string) (string, bool)) ExportConfig
ExportConfigFromEnv reads the APP_AUDIT_ANCHOR_* tunables; bad values fall back to defaults.
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter sends each new checkpoint to the configured webhook from a bounded queue, so a slow or dead sink never reaches the audit write path.
func NewExporter ¶
func NewExporter(cfg ExportConfig, interval time.Duration, src HeadSource, set Settings, log *slog.Logger) *Exporter
NewExporter builds an Exporter; call Run to start it.
type HeadSource ¶
type HeadSource interface {
LatestAuditAnchor(ctx context.Context) (store.AuditAnchor, bool, error)
}
HeadSource yields the signed chain head; *store.DB satisfies it.
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher pushes new heads to the configured sinks.
func New ¶
func New(cfg Config, src HeadSource, log *slog.Logger) *Publisher
New builds a Publisher; call Run to start it.
type Status ¶
type Status struct {
Enabled bool `json:"enabled"`
LastExportedSeq int64 `json:"last_exported_seq"`
LastExportedAt string `json:"last_exported_at,omitempty"`
LastError string `json:"last_error,omitempty"`
LastErrorAt string `json:"last_error_at,omitempty"`
Exported int64 `json:"exported"`
Failed int64 `json:"failed"`
Dropped int64 `json:"dropped"`
Queued int `json:"queued"`
}
Status is the operator view of the webhook export. It holds no secret and no URL.