Documentation
¶
Overview ¶
Package alerts notifies Slack, Discord, email and webhooks when a scan finds new or regressed findings at or above a severity threshold.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Alert ¶
type Alert struct {
Target string `json:"target"`
ScanID string `json:"scan_id"`
Grade string `json:"grade"`
Score float64 `json:"score"`
Threshold core.Severity `json:"threshold"`
New []core.Finding `json:"new"`
Regressed []core.Finding `json:"regressed"`
DashboardURL string `json:"dashboard_url,omitempty"`
At time.Time `json:"at"`
}
Alert is one notification: what changed in one scan.
type Discord ¶
type Discord struct {
WebhookURL string `json:"webhook_url" yaml:"webhook_url"`
}
Discord posts to a Discord webhook. Messages are capped at 2000 characters.
type Dispatcher ¶
type Dispatcher struct {
Notifiers []Notifier
MinSeverity core.Severity
DashboardURL string
Store storage.Store
Logger *slog.Logger
// Timeout bounds each notifier call.
Timeout time.Duration
}
Dispatcher turns finished scans into alerts.
func (*Dispatcher) Build ¶
Build compares a stored scan with its target's previous scan and returns the alert, or errNothingToSend. Unsaved (ephemeral) scans return storage.ErrNotFound.
type Email ¶
type Email struct {
Host string `json:"host" yaml:"host"`
Port int `json:"port" yaml:"port"`
Username string `json:"username,omitempty" yaml:"username"`
Password string `json:"-" yaml:"password"`
From string `json:"from" yaml:"from"`
To []string `json:"to" yaml:"to"`
}
Email sends alerts over SMTP. smtp.SendMail upgrades to STARTTLS when the server offers it; implicit-TLS port 465 is not supported.
type Slack ¶
type Slack struct {
WebhookURL string `json:"webhook_url" yaml:"webhook_url"`
}
Slack posts to a Slack incoming webhook.
type Webhook ¶
Webhook posts the alert as JSON, signed with HMAC-SHA256 so the receiver can verify it came from Scout:
X-Scout-Timestamp: <unix seconds> X-Scout-Signature: sha256=<hex HMAC(secret, timestamp + "." + body)>
type WebhookPayload ¶
WebhookPayload is the JSON body of a webhook alert.