Documentation
¶
Overview ¶
Package webhook fires a single HTTP POST when a scan reaches a terminal state (completed or failed). Unlike the per-finding notify backends, this is a one-shot scan-completion hook: project-scoped, retried up to 5 times on 5xx/network errors, fire-and-forget so it never blocks the scan.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FireAgenticScan ¶
func FireAgenticScan(settings *config.Settings, repo *database.Repository, agenticScanUUID string)
FireAgenticScan loads the agentic scan row, computes severity counts from associated findings, and posts a completion payload. No-op when settings/repo are nil or the webhook is not enabled.
func FireNativeScan ¶
func FireNativeScan(settings *config.Settings, repo *database.Repository, scanUUID string)
FireNativeScan loads the native scan row and posts a completion payload. No-op when settings/repo are nil or the webhook is not enabled.
Types ¶
type FindingCounts ¶
type FindingCounts struct {
Total int `json:"total"`
BySeverity map[string]int `json:"by_severity"`
}
FindingCounts is the severity breakdown of findings produced by a scan.
type ScanCompletedPayload ¶
type ScanCompletedPayload struct {
Event string `json:"event"`
ProjectUUID string `json:"project_uuid"`
ScanUUID string `json:"scan_uuid"`
ScanType string `json:"scan_type"`
Target string `json:"target"`
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
Findings FindingCounts `json:"findings"`
ResultURL string `json:"result_url"`
}
ScanCompletedPayload is the JSON body POSTed to the webhook URL.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender posts ScanCompletedPayload to a configured URL with retry on 5xx.
func NewSender ¶
func NewSender(cfg config.WebhookConfig) *Sender
NewSender returns a Sender or nil when the webhook URL is empty. Provider/master-switch gating is the caller's responsibility — this helper only validates the per-channel config.
func (*Sender) Post ¶
func (s *Sender) Post(ctx context.Context, payload ScanCompletedPayload) error
Post sends the payload with retries (5 attempts, exponential backoff on 5xx and network errors). 4xx responses are not retried. Returns the last error encountered when all attempts fail.
func (*Sender) PostAsync ¶
func (s *Sender) PostAsync(payload ScanCompletedPayload)
PostAsync fires the POST in a goroutine and logs failures. Use this from scan-completion paths so the scan does not block on webhook delivery.