Documentation
¶
Overview ¶
Package kernelalerts raises the kernel's operational alerts: leaf certificates (Agent, forward link, module) that were not renewed in time, CAs close to their end, and phased processes (the node credential split, the identity cutover) left in a non-final phase. A Monitor scans the certificate stores and the phase tables read-only, keeps one row per alert in v4_kernel_alert, and sends the administrators one digest of the alerts that are new, worse or due again. GET /api/v4/kernel/alerts lists the rows. Nothing here changes a certificate or a phase.
Index ¶
Constants ¶
const ( // KindAgentCertificate: a node's latest Agent client certificate is // close to its end (or past it) and was not renewed. KindAgentCertificate = "agent_certificate_expiring" // KindLinkCertificate: the same for a forward node's link certificate // (H28). KindLinkCertificate = "link_certificate_expiring" // KindModuleCertificate: the same for a module's certificate. KindModuleCertificate = "module_certificate_expiring" // KindCAExpiring: the current module (Agent, kernel) CA or forward link // CA is within ca_expiry_days of its end. KindCAExpiring = "ca_expiring" // KindNodeSecretsSplitStalled: a node credential split table sits in // dual_write or dual_read and was not touched for phase_stuck_after. KindNodeSecretsSplitStalled = "node_secrets_split_stalled" // #nosec G101 -- names an alert kind, not a credential. // KindNodeSecretsFinalizeInterrupted: a table's finalize started and // did not complete. KindNodeSecretsFinalizeInterrupted = "node_secrets_finalize_interrupted" // #nosec G101 -- names an alert kind, not a credential. // KindIdentityImportStalled: the identity authority sits in importing // without progress for phase_stuck_after. KindIdentityImportStalled = "identity_import_stalled" // KindIdentityCutoverPending: identity owns logins since the latest // cutover, but legacy credentials were not finalized for // phase_stuck_after. KindIdentityCutoverPending = "identity_cutover_not_finalized" )
Alert kinds.
const ( SubjectNode = "node" SubjectCA = "ca" SubjectModule = "module" SubjectNodeSecrets = "node_secrets" // #nosec G101 -- names a subject kind, not a credential. SubjectIdentity = "identity" )
Subject kinds.
const ( StatusActive = "active" StatusResolved = "resolved" StatusAll = "all" )
Statuses a listing filters by.
const ( DefaultLimit = 100 MaxLimit = 500 )
Listing limits.
Variables ¶
var ErrInvalidQuery = errors.New("invalid alert query")
ErrInvalidQuery wraps every reason a listing query is refused.
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert struct {
ID uint `json:"id"`
Key string `json:"key"`
Kind string `json:"kind"`
Severity string `json:"severity"`
Status string `json:"status"`
SubjectKind string `json:"subject_kind"`
Subject string `json:"subject"`
Message string `json:"message"`
Detail map[string]any `json:"detail"`
ExpiresAt *time.Time `json:"expires_at"`
FirstSeenAt time.Time `json:"first_seen_at"`
LastSeenAt time.Time `json:"last_seen_at"`
LastNotifiedAt *time.Time `json:"last_notified_at"`
NotifyCount int `json:"notify_count"`
ResolvedAt *time.Time `json:"resolved_at"`
}
Alert is an alert as the admin API answers it.
type Finding ¶
type Finding struct {
Kind string
Severity string
SubjectKind string
Subject string
Message string
// Detail holds the facts behind the alert; no secret, ever.
Detail map[string]any
ExpiresAt *time.Time
}
Finding is one alert condition a scan found.
type Monitor ¶
type Monitor struct {
DB *gorm.DB
Settings config.AlertSettings
// Notifier may be nil: alerts are then only recorded and listed.
Notifier Notifier
// Now defaults to time.Now.
Now func() time.Time
}
Monitor keeps v4_kernel_alert in step with what the Scanner finds and notifies the administrators of what needs their attention. Run it in one process at a time (the singleton workers' lease).
type Notification ¶
type Notification struct {
Title string
Content string
Alerts []model.KernelAlert
}
Notification is one digest for the administrators: every alert that is new, worse or due again in a scan, in one message.
type Notifier ¶
type Notifier interface {
Notify(ctx context.Context, notification Notification) error
}
Notifier delivers a digest to the administrators. An error means nothing was delivered: the alerts stay due and the next scan tries again.
type Query ¶
type Query struct {
Status string
// Kind and Severity filter when set.
Kind string
Severity string
Limit int
}
Query selects alerts: Status is active (the default), resolved or all.
func ParseQuery ¶
ParseQuery validates raw query values.
type ScanResult ¶
type ScanResult struct {
Findings []Finding
// Unevaluated lists the kinds whose check failed. The alerts of those
// kinds are left as they are: a failed scan proves nothing is resolved.
Unevaluated map[string]bool
}
ScanResult is what one scan found.
type ScanSummary ¶
ScanSummary is what one scan did.