// Package webhooks provides webhook dispatch and formatting for push and scan notifications. package webhooks // Webhook trigger bitmask constants const ( TriggerFirst = 0x01 // First-time scan (no previous scan record) TriggerAll = 0x02 // Every scan completion TriggerChanged = 0x04 // Vulnerability counts changed from previous TriggerPush = 0x08 // Image push (manifest stored) ) // WebhookPayload is the JSON body sent to webhook URLs type WebhookPayload struct { Trigger string `json:"trigger"` HoldDID string `json:"holdDid"` HoldEndpoint string `json:"holdEndpoint"` Manifest WebhookManifestInfo `json:"manifest"` Scan WebhookScanInfo `json:"scan"` Previous *WebhookVulnCounts `json:"previous"` } // WebhookManifestInfo describes the scanned manifest type WebhookManifestInfo struct { Digest string `json:"digest"` Repository string `json:"repository"` Tag string `json:"tag"` UserDID string `json:"userDid"` UserHandle string `json:"userHandle,omitempty"` } // WebhookScanInfo describes the scan results type WebhookScanInfo struct { ScannedAt string `json:"scannedAt"` ScannerVersion string `json:"scannerVersion"` Vulnerabilities WebhookVulnCounts `json:"vulnerabilities"` } // WebhookVulnCounts contains vulnerability counts by severity type WebhookVulnCounts struct { Critical int `json:"critical"` High int `json:"high"` Medium int `json:"medium"` Low int `json:"low"` Total int `json:"total"` } // PushWebhookPayload is the JSON body sent for push events (Docker Hub-inspired format) type PushWebhookPayload struct { Trigger string `json:"trigger"` PushData PushData `json:"push_data"` Repository PushRepository `json:"repository"` Hold PushHold `json:"hold"` } // PushData describes the push event type PushData struct { PushedAt string `json:"pushed_at"` Pusher string `json:"pusher"` PusherDID string `json:"pusher_did"` Tag string `json:"tag,omitempty"` Digest string `json:"digest"` } // PushRepository describes the repository that was pushed to type PushRepository struct { Name string `json:"name"` Namespace string `json:"namespace"` RepoName string `json:"repo_name"` RepoURL string `json:"repo_url"` MediaType string `json:"media_type"` StarCount int `json:"star_count"` PullCount int `json:"pull_count"` } // PushHold describes the hold service where blobs are stored type PushHold struct { DID string `json:"did"` Endpoint string `json:"endpoint"` }