Skip to content

Commit 160691f

Browse files
fixed release, repository-vulnerability-alert repository
security-advisory payloads
1 parent e9d3dcd commit 160691f

File tree

2 files changed

+54
-237
lines changed

2 files changed

+54
-237
lines changed

github/payload.go

Lines changed: 34 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,95 +2422,8 @@ type ReleasePayload struct {
24222422
ZipballURL string `json:"zipball_url"`
24232423
Body *string `json:"body"`
24242424
} `json:"release"`
2425-
Repository struct {
2426-
ID int64 `json:"id"`
2427-
Name string `json:"name"`
2428-
FullName string `json:"full_name"`
2429-
Owner struct {
2430-
Login string `json:"login"`
2431-
ID int64 `json:"id"`
2432-
NodeID string `json:"node_id"`
2433-
AvatarURL string `json:"avatar_url"`
2434-
GravatarID string `json:"gravatar_id"`
2435-
URL string `json:"url"`
2436-
HTMLURL string `json:"html_url"`
2437-
FollowersURL string `json:"followers_url"`
2438-
FollowingURL string `json:"following_url"`
2439-
GistsURL string `json:"gists_url"`
2440-
StarredURL string `json:"starred_url"`
2441-
SubscriptionsURL string `json:"subscriptions_url"`
2442-
OrganizationsURL string `json:"organizations_url"`
2443-
ReposURL string `json:"repos_url"`
2444-
EventsURL string `json:"events_url"`
2445-
ReceivedEventsURL string `json:"received_events_url"`
2446-
Type string `json:"type"`
2447-
SiteAdmin bool `json:"site_admin"`
2448-
} `json:"owner"`
2449-
Private bool `json:"private"`
2450-
HTMLURL string `json:"html_url"`
2451-
Description string `json:"description"`
2452-
Fork bool `json:"fork"`
2453-
URL string `json:"url"`
2454-
ForksURL string `json:"forks_url"`
2455-
KeysURL string `json:"keys_url"`
2456-
CollaboratorsURL string `json:"collaborators_url"`
2457-
TeamsURL string `json:"teams_url"`
2458-
HooksURL string `json:"hooks_url"`
2459-
IssueEventsURL string `json:"issue_events_url"`
2460-
EventsURL string `json:"events_url"`
2461-
AssigneesURL string `json:"assignees_url"`
2462-
BranchesURL string `json:"branches_url"`
2463-
TagsURL string `json:"tags_url"`
2464-
BlobsURL string `json:"blobs_url"`
2465-
GitTagsURL string `json:"git_tags_url"`
2466-
GitRefsURL string `json:"git_refs_url"`
2467-
TreesURL string `json:"trees_url"`
2468-
StatusesURL string `json:"statuses_url"`
2469-
LanguagesURL string `json:"languages_url"`
2470-
StargazersURL string `json:"stargazers_url"`
2471-
ContributorsURL string `json:"contributors_url"`
2472-
SubscribersURL string `json:"subscribers_url"`
2473-
SubscriptionURL string `json:"subscription_url"`
2474-
CommitsURL string `json:"commits_url"`
2475-
GitCommitsURL string `json:"git_commits_url"`
2476-
CommentsURL string `json:"comments_url"`
2477-
IssueCommentURL string `json:"issue_comment_url"`
2478-
ContentsURL string `json:"contents_url"`
2479-
CompareURL string `json:"compare_url"`
2480-
MergesURL string `json:"merges_url"`
2481-
ArchiveURL string `json:"archive_url"`
2482-
DownloadsURL string `json:"downloads_url"`
2483-
IssuesURL string `json:"issues_url"`
2484-
PullsURL string `json:"pulls_url"`
2485-
MilestonesURL string `json:"milestones_url"`
2486-
NotificationsURL string `json:"notifications_url"`
2487-
LabelsURL string `json:"labels_url"`
2488-
ReleasesURL string `json:"releases_url"`
2489-
CreatedAt time.Time `json:"created_at"`
2490-
UpdatedAt time.Time `json:"updated_at"`
2491-
PushedAt time.Time `json:"pushed_at"`
2492-
GitURL string `json:"git_url"`
2493-
SSHURL string `json:"ssh_url"`
2494-
CloneURL string `json:"clone_url"`
2495-
SvnURL string `json:"svn_url"`
2496-
Homepage *string `json:"homepage"`
2497-
Size int64 `json:"size"`
2498-
StargazersCount int64 `json:"stargazers_count"`
2499-
WatchersCount int64 `json:"watchers_count"`
2500-
Language *string `json:"language"`
2501-
HasIssues bool `json:"has_issues"`
2502-
HasDownloads bool `json:"has_downloads"`
2503-
HasWiki bool `json:"has_wiki"`
2504-
HasPages bool `json:"has_pages"`
2505-
ForksCount int64 `json:"forks_count"`
2506-
MirrorURL *string `json:"mirror_url"`
2507-
OpenIssuesCount int64 `json:"open_issues_count"`
2508-
Forks int64 `json:"forks"`
2509-
OpenIssues int64 `json:"open_issues"`
2510-
Watchers int64 `json:"watchers"`
2511-
DefaultBranch string `json:"default_branch"`
2512-
} `json:"repository"`
2513-
Sender struct {
2425+
Repository Repository `json:"repository"`
2426+
Sender struct {
25142427
Login string `json:"login"`
25152428
ID int64 `json:"id"`
25162429
NodeID string `json:"node_id"`
@@ -2530,115 +2443,14 @@ type ReleasePayload struct {
25302443
Type string `json:"type"`
25312444
SiteAdmin bool `json:"site_admin"`
25322445
} `json:"sender"`
2533-
Installation struct {
2534-
ID int `json:"id"`
2535-
} `json:"installation"`
2446+
Installation Installation `json:"installation"`
25362447
}
25372448

25382449
// RepositoryPayload contains the information for GitHub's repository hook event
25392450
type RepositoryPayload struct {
2540-
Action string `json:"action"`
2541-
Repository struct {
2542-
ID int64 `json:"id"`
2543-
NodeID string `json:"node_id"`
2544-
Name string `json:"name"`
2545-
FullName string `json:"full_name"`
2546-
Owner struct {
2547-
Login string `json:"login"`
2548-
ID int64 `json:"id"`
2549-
NodeID string `json:"node_id"`
2550-
AvatarURL string `json:"avatar_url"`
2551-
GravatarID string `json:"gravatar_id"`
2552-
URL string `json:"url"`
2553-
HTMLURL string `json:"html_url"`
2554-
FollowersURL string `json:"followers_url"`
2555-
FollowingURL string `json:"following_url"`
2556-
GistsURL string `json:"gists_url"`
2557-
StarredURL string `json:"starred_url"`
2558-
SubscriptionsURL string `json:"subscriptions_url"`
2559-
OrganizationsURL string `json:"organizations_url"`
2560-
ReposURL string `json:"repos_url"`
2561-
EventsURL string `json:"events_url"`
2562-
ReceivedEventsURL string `json:"received_events_url"`
2563-
Type string `json:"type"`
2564-
SiteAdmin bool `json:"site_admin"`
2565-
} `json:"owner"`
2566-
Private bool `json:"private"`
2567-
HTMLURL string `json:"html_url"`
2568-
Description string `json:"description"`
2569-
Fork bool `json:"fork"`
2570-
URL string `json:"url"`
2571-
ForksURL string `json:"forks_url"`
2572-
KeysURL string `json:"keys_url"`
2573-
CollaboratorsURL string `json:"collaborators_url"`
2574-
TeamsURL string `json:"teams_url"`
2575-
HooksURL string `json:"hooks_url"`
2576-
IssueEventsURL string `json:"issue_events_url"`
2577-
EventsURL string `json:"events_url"`
2578-
AssigneesURL string `json:"assignees_url"`
2579-
BranchesURL string `json:"branches_url"`
2580-
TagsURL string `json:"tags_url"`
2581-
BlobsURL string `json:"blobs_url"`
2582-
GitTagsURL string `json:"git_tags_url"`
2583-
GitRefsURL string `json:"git_refs_url"`
2584-
TreesURL string `json:"trees_url"`
2585-
StatusesURL string `json:"statuses_url"`
2586-
LanguagesURL string `json:"languages_url"`
2587-
StargazersURL string `json:"stargazers_url"`
2588-
ContributorsURL string `json:"contributors_url"`
2589-
SubscribersURL string `json:"subscribers_url"`
2590-
SubscriptionURL string `json:"subscription_url"`
2591-
CommitsURL string `json:"commits_url"`
2592-
GitCommitsURL string `json:"git_commits_url"`
2593-
CommentsURL string `json:"comments_url"`
2594-
IssueCommentURL string `json:"issue_comment_url"`
2595-
ContentsURL string `json:"contents_url"`
2596-
CompareURL string `json:"compare_url"`
2597-
MergesURL string `json:"merges_url"`
2598-
ArchiveURL string `json:"archive_url"`
2599-
DownloadsURL string `json:"downloads_url"`
2600-
IssuesURL string `json:"issues_url"`
2601-
PullsURL string `json:"pulls_url"`
2602-
MilestonesURL string `json:"milestones_url"`
2603-
NotificationsURL string `json:"notifications_url"`
2604-
LabelsURL string `json:"labels_url"`
2605-
ReleasesURL string `json:"releases_url"`
2606-
CreatedAt time.Time `json:"created_at"`
2607-
UpdatedAt time.Time `json:"updated_at"`
2608-
PushedAt time.Time `json:"pushed_at"`
2609-
GitURL string `json:"git_url"`
2610-
SSHURL string `json:"ssh_url"`
2611-
CloneURL string `json:"clone_url"`
2612-
SvnURL string `json:"svn_url"`
2613-
Homepage *string `json:"homepage"`
2614-
Size int64 `json:"size"`
2615-
StargazersCount int64 `json:"stargazers_count"`
2616-
WatchersCount int64 `json:"watchers_count"`
2617-
Language *string `json:"language"`
2618-
HasIssues bool `json:"has_issues"`
2619-
HasDownloads bool `json:"has_downloads"`
2620-
HasWiki bool `json:"has_wiki"`
2621-
HasPages bool `json:"has_pages"`
2622-
ForksCount int64 `json:"forks_count"`
2623-
MirrorURL *string `json:"mirror_url"`
2624-
OpenIssuesCount int64 `json:"open_issues_count"`
2625-
Forks int64 `json:"forks"`
2626-
OpenIssues int64 `json:"open_issues"`
2627-
Watchers int64 `json:"watchers"`
2628-
DefaultBranch string `json:"default_branch"`
2629-
} `json:"repository"`
2630-
Organization struct {
2631-
Login string `json:"login"`
2632-
ID int64 `json:"id"`
2633-
NodeID string `json:"node_id"`
2634-
URL string `json:"url"`
2635-
ReposURL string `json:"repos_url"`
2636-
EventsURL string `json:"events_url"`
2637-
MembersURL string `json:"members_url"`
2638-
PublicMembersURL string `json:"public_members_url"`
2639-
AvatarURL string `json:"avatar_url"`
2640-
} `json:"organization"`
2641-
Sender struct {
2451+
Action string `json:"action"`
2452+
Repository Repository `json:"repository"`
2453+
Sender struct {
26422454
Login string `json:"login"`
26432455
ID int64 `json:"id"`
26442456
NodeID string `json:"node_id"`
@@ -2658,40 +2470,44 @@ type RepositoryPayload struct {
26582470
Type string `json:"type"`
26592471
SiteAdmin bool `json:"site_admin"`
26602472
} `json:"sender"`
2473+
Installation Installation `json:"installation"`
26612474
}
26622475

26632476
// RepositoryVulnerabilityAlertEvent contains the information for GitHub's repository_vulnerability_alert hook event.
26642477
type RepositoryVulnerabilityAlertPayload struct {
26652478
Action string `json:"action"`
26662479
Alert struct {
2667-
ID int64 `json:"id"`
2668-
Summary string `json:"summary"`
2480+
ID int64 `json:"id"`
2481+
// TODO: is it really gone?
2482+
// Summary string `json:"summary"`
26692483
AffectedRange string `json:"affected_range"`
26702484
AffectedPackageName string `json:"affected_package_name"`
26712485
ExternalReference string `json:"external_reference"`
26722486
ExternalIdentifier string `json:"external_identifier"`
26732487
FixedIn string `json:"fixed_in"`
2674-
Dismisser struct {
2675-
Login string `json:"login"`
2676-
ID int64 `json:"id"`
2677-
NodeID string `json:"node_id"`
2678-
AvatarURL string `json:"avatar_url"`
2679-
GravatarID string `json:"gravatar_id"`
2680-
URL string `json:"url"`
2681-
HTMLURL string `json:"html_url"`
2682-
FollowersURL string `json:"followers_url"`
2683-
FollowingURL string `json:"following_url"`
2684-
GistsURL string `json:"gists_url"`
2685-
StarredURL string `json:"starred_url"`
2686-
SubscriptionsURL string `json:"subscriptions_url"`
2687-
OrganizationsURL string `json:"organizations_url"`
2688-
ReposURL string `json:"repos_url"`
2689-
EventsURL string `json:"events_url"`
2690-
ReceivedEventsURL string `json:"received_events_url"`
2691-
Type string `json:"type"`
2692-
SiteAdmin bool `json:"site_admin"`
2693-
} `json:"dismisser"`
26942488
} `json:"alert"`
2489+
Repository Repository `json:"repository"`
2490+
Sender struct {
2491+
Login string `json:"login"`
2492+
ID int64 `json:"id"`
2493+
NodeID string `json:"node_id"`
2494+
AvatarURL string `json:"avatar_url"`
2495+
GravatarID string `json:"gravatar_id"`
2496+
URL string `json:"url"`
2497+
HTMLURL string `json:"html_url"`
2498+
FollowersURL string `json:"followers_url"`
2499+
FollowingURL string `json:"following_url"`
2500+
GistsURL string `json:"gists_url"`
2501+
StarredURL string `json:"starred_url"`
2502+
SubscriptionsURL string `json:"subscriptions_url"`
2503+
OrganizationsURL string `json:"organizations_url"`
2504+
ReposURL string `json:"repos_url"`
2505+
EventsURL string `json:"events_url"`
2506+
ReceivedEventsURL string `json:"received_events_url"`
2507+
Type string `json:"type"`
2508+
SiteAdmin bool `json:"site_admin"`
2509+
} `json:"sender"`
2510+
Installation Installation `json:"installation"`
26952511
}
26962512

26972513
// SecurityAdvisoryPayload contains the information for GitHub's security_advisory hook event.
@@ -2701,7 +2517,7 @@ type SecurityAdvisoryPayload struct {
27012517
GHSAID string `json:"ghsa_id"`
27022518
Summary string `json:"summary"`
27032519
Description string `json:"description"`
2704-
Severity string `json:"string"`
2520+
Severity string `json:"severity"`
27052521
Identifiers []struct {
27062522
Value string `json:"value"`
27072523
Type string `json:"type"`
@@ -2724,6 +2540,7 @@ type SecurityAdvisoryPayload struct {
27242540
} `json:"first_patched_version"`
27252541
} `json:"vulnerabilities"`
27262542
} `json:"security_advisory"`
2543+
Installation Installation `json:"installation"`
27272544
}
27282545

27292546
// StatusPayload contains the information for GitHub's status hook event

github/payload_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,26 +179,26 @@ func TestPayloads(t *testing.T) {
179179
filename: "release.json",
180180
typ: &ReleasePayload{},
181181
},
182-
// {
183-
// name: "RepositoryVulnerabilityAlertPayload",
184-
// filename: "repository-vulnerability-alert.json",
185-
// typ: &RepositoryVulnerabilityAlertPayload{},
186-
// },
187-
// {
188-
// name: "RepositoryPayload",
189-
// filename: "repository.json",
190-
// typ: &RepositoryPayload{},
191-
// },
192-
// {
193-
// name: "SecurityAdvisoryPayload",
194-
// filename: "security-advisory.json",
195-
// typ: &SecurityAdvisoryPayload{},
196-
// },
197-
// {
198-
// name: "StatusPayload",
199-
// filename: "status.json",
200-
// typ: &StatusPayload{},
201-
// },
182+
{
183+
name: "RepositoryVulnerabilityAlertPayload",
184+
filename: "repository-vulnerability-alert.json",
185+
typ: &RepositoryVulnerabilityAlertPayload{},
186+
},
187+
{
188+
name: "RepositoryPayload",
189+
filename: "repository.json",
190+
typ: &RepositoryPayload{},
191+
},
192+
{
193+
name: "SecurityAdvisoryPayload",
194+
filename: "security-advisory.json",
195+
typ: &SecurityAdvisoryPayload{},
196+
},
197+
{
198+
name: "StatusPayload",
199+
filename: "status.json",
200+
typ: &StatusPayload{},
201+
},
202202
// {
203203
// name: "TeamAddPayload",
204204
// filename: "team-add.json",

0 commit comments

Comments
 (0)