A container registry that uses the AT Protocol for manifest storage and S3 for blob storage.
1// Package webhooks provides webhook dispatch and formatting for push and scan notifications.
2package webhooks
3
4// Webhook trigger bitmask constants
5const (
6 TriggerFirst = 0x01 // First-time scan (no previous scan record)
7 TriggerAll = 0x02 // Every scan completion
8 TriggerChanged = 0x04 // Vulnerability counts changed from previous
9 TriggerPush = 0x08 // Image push (manifest stored)
10)
11
12// WebhookPayload is the JSON body sent to webhook URLs
13type WebhookPayload struct {
14 Trigger string `json:"trigger"`
15 HoldDID string `json:"holdDid"`
16 HoldEndpoint string `json:"holdEndpoint"`
17 Manifest WebhookManifestInfo `json:"manifest"`
18 Scan WebhookScanInfo `json:"scan"`
19 Previous *WebhookVulnCounts `json:"previous"`
20}
21
22// WebhookManifestInfo describes the scanned manifest
23type WebhookManifestInfo struct {
24 Digest string `json:"digest"`
25 Repository string `json:"repository"`
26 Tag string `json:"tag"`
27 UserDID string `json:"userDid"`
28 UserHandle string `json:"userHandle,omitempty"`
29}
30
31// WebhookScanInfo describes the scan results
32type WebhookScanInfo struct {
33 ScannedAt string `json:"scannedAt"`
34 ScannerVersion string `json:"scannerVersion"`
35 Vulnerabilities WebhookVulnCounts `json:"vulnerabilities"`
36}
37
38// WebhookVulnCounts contains vulnerability counts by severity
39type WebhookVulnCounts struct {
40 Critical int `json:"critical"`
41 High int `json:"high"`
42 Medium int `json:"medium"`
43 Low int `json:"low"`
44 Total int `json:"total"`
45}
46
47// PushWebhookPayload is the JSON body sent for push events (Docker Hub-inspired format)
48type PushWebhookPayload struct {
49 Trigger string `json:"trigger"`
50 PushData PushData `json:"push_data"`
51 Repository PushRepository `json:"repository"`
52 Hold PushHold `json:"hold"`
53}
54
55// PushData describes the push event
56type PushData struct {
57 PushedAt string `json:"pushed_at"`
58 Pusher string `json:"pusher"`
59 PusherDID string `json:"pusher_did"`
60 Tag string `json:"tag,omitempty"`
61 Digest string `json:"digest"`
62}
63
64// PushRepository describes the repository that was pushed to
65type PushRepository struct {
66 Name string `json:"name"`
67 Namespace string `json:"namespace"`
68 RepoName string `json:"repo_name"`
69 RepoURL string `json:"repo_url"`
70 MediaType string `json:"media_type"`
71 StarCount int `json:"star_count"`
72 PullCount int `json:"pull_count"`
73}
74
75// PushHold describes the hold service where blobs are stored
76type PushHold struct {
77 DID string `json:"did"`
78 Endpoint string `json:"endpoint"`
79}