Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1751865845 | |||
| 0a9a3aab3e | |||
| 43ffb318d2 |
@@ -1,6 +1,6 @@
|
|||||||
Library webhooks
|
Library webhooks
|
||||||
================
|
================
|
||||||
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v5/logo.png">
|
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v5/logo.png">
|
||||||
[](https://travis-ci.org/go-playground/webhooks)
|
[](https://travis-ci.org/go-playground/webhooks)
|
||||||
[](https://coveralls.io/github/go-playground/webhooks?branch=v5)
|
[](https://coveralls.io/github/go-playground/webhooks?branch=v5)
|
||||||
[](https://goreportcard.com/report/go-playground/webhooks)
|
[](https://goreportcard.com/report/go-playground/webhooks)
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ const (
|
|||||||
PushEvent Event = "push"
|
PushEvent Event = "push"
|
||||||
ReleaseEvent Event = "release"
|
ReleaseEvent Event = "release"
|
||||||
RepositoryEvent Event = "repository"
|
RepositoryEvent Event = "repository"
|
||||||
|
RepositoryVulnerabilityAlertEvent Event = "repository_vulnerability_alert"
|
||||||
SecurityAdvisoryEvent Event = "security_advisory"
|
SecurityAdvisoryEvent Event = "security_advisory"
|
||||||
StatusEvent Event = "status"
|
StatusEvent Event = "status"
|
||||||
TeamEvent Event = "team"
|
TeamEvent Event = "team"
|
||||||
@@ -289,6 +290,10 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
|
|||||||
var pl RepositoryPayload
|
var pl RepositoryPayload
|
||||||
err = json.Unmarshal([]byte(payload), &pl)
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
return pl, err
|
return pl, err
|
||||||
|
case RepositoryVulnerabilityAlertEvent:
|
||||||
|
var pl RepositoryVulnerabilityAlertPayload
|
||||||
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
|
return pl, err
|
||||||
case SecurityAdvisoryEvent:
|
case SecurityAdvisoryEvent:
|
||||||
var pl SecurityAdvisoryPayload
|
var pl SecurityAdvisoryPayload
|
||||||
err = json.Unmarshal([]byte(payload), &pl)
|
err = json.Unmarshal([]byte(payload), &pl)
|
||||||
|
|||||||
@@ -453,6 +453,16 @@ func TestWebhooks(t *testing.T) {
|
|||||||
"X-Hub-Signature": []string{"sha1=df442a8af41edd2d42ccdd997938d1d111b0f94e"},
|
"X-Hub-Signature": []string{"sha1=df442a8af41edd2d42ccdd997938d1d111b0f94e"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "RepositoryVulnerabilityAlertEvent",
|
||||||
|
event: RepositoryVulnerabilityAlertEvent,
|
||||||
|
typ: RepositoryVulnerabilityAlertPayload{},
|
||||||
|
filename: "../testdata/github/repository-vulnerability-alert.json",
|
||||||
|
headers: http.Header{
|
||||||
|
"X-Github-Event": []string{"repository_vulnerability_alert"},
|
||||||
|
"X-Hub-Signature": []string{"sha1=c42c0649e7e06413bcd756763edbab48dff400db"},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "SecurityAdvisoryEvent",
|
name: "SecurityAdvisoryEvent",
|
||||||
event: SecurityAdvisoryEvent,
|
event: SecurityAdvisoryEvent,
|
||||||
|
|||||||
@@ -5260,6 +5260,40 @@ type RepositoryPayload struct {
|
|||||||
} `json:"sender"`
|
} `json:"sender"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RepositoryVulnerabilityAlertEvent contains the information for GitHub's repository_vulnerability_alert hook event.
|
||||||
|
type RepositoryVulnerabilityAlertPayload struct {
|
||||||
|
Action string `json:"action"`
|
||||||
|
Alert struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Summary string `json:"summary"`
|
||||||
|
AffectedRange string `json:"affected_range"`
|
||||||
|
AffectedPackageName string `json:"affected_package_name"`
|
||||||
|
ExternalReference string `json:"external_reference"`
|
||||||
|
ExternalIdentifier string `json:"external_identifier"`
|
||||||
|
FixedIn string `json:"fixed_in"`
|
||||||
|
Dismisser struct {
|
||||||
|
Login string `json:"login"`
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
NodeID string `json:"node_id"`
|
||||||
|
AvatarURL string `json:"avatar_url"`
|
||||||
|
GravatarID string `json:"gravatar_id"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
HTMLURL string `json:"html_url"`
|
||||||
|
FollowersURL string `json:"followers_url"`
|
||||||
|
FollowingURL string `json:"following_url"`
|
||||||
|
GistsURL string `json:"gists_url"`
|
||||||
|
StarredURL string `json:"starred_url"`
|
||||||
|
SubscriptionsURL string `json:"subscriptions_url"`
|
||||||
|
OrganizationsURL string `json:"organizations_url"`
|
||||||
|
ReposURL string `json:"repos_url"`
|
||||||
|
EventsURL string `json:"events_url"`
|
||||||
|
ReceivedEventsURL string `json:"received_events_url"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
SiteAdmin bool `json:"site_admin"`
|
||||||
|
} `json:"dismisser"`
|
||||||
|
} `json:"alert"`
|
||||||
|
}
|
||||||
|
|
||||||
// SecurityAdvisoryPayload contains the information for GitHub's security_advisory hook event.
|
// SecurityAdvisoryPayload contains the information for GitHub's security_advisory hook event.
|
||||||
type SecurityAdvisoryPayload struct {
|
type SecurityAdvisoryPayload struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"action": "dismiss",
|
||||||
|
"alert": {
|
||||||
|
"id": 7649605,
|
||||||
|
"affected_range": "0.2.0",
|
||||||
|
"affected_package_name": "many_versioned_gem",
|
||||||
|
"external_reference": "https://nvd.nist.gov/vuln/detail/CVE-2018-3728",
|
||||||
|
"external_identifier": "CVE-2018-3728",
|
||||||
|
"fixed_in": "0.2.5",
|
||||||
|
"dismisser": {
|
||||||
|
"login":"octocat",
|
||||||
|
"id":1,
|
||||||
|
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
|
||||||
|
"avatar_url":"https://github.com/images/error/octocat_happy.gif",
|
||||||
|
"gravatar_id":"",
|
||||||
|
"url":"https://api.github.com/users/octocat",
|
||||||
|
"html_url":"https://github.com/octocat",
|
||||||
|
"followers_url":"https://api.github.com/users/octocat/followers",
|
||||||
|
"following_url":"https://api.github.com/users/octocat/following{/other_user}",
|
||||||
|
"gists_url":"https://api.github.com/users/octocat/gists{/gist_id}",
|
||||||
|
"starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||||
|
"subscriptions_url":"https://api.github.com/users/octocat/subscriptions",
|
||||||
|
"organizations_url":"https://api.github.com/users/octocat/orgs",
|
||||||
|
"repos_url":"https://api.github.com/users/octocat/repos",
|
||||||
|
"events_url":"https://api.github.com/users/octocat/events{/privacy}",
|
||||||
|
"received_events_url":"https://api.github.com/users/octocat/received_events",
|
||||||
|
"type":"User",
|
||||||
|
"site_admin":true
|
||||||
|
},
|
||||||
|
"dismiss_reason": "No bandwidth to fix this",
|
||||||
|
"dismissed_at": "2017-10-25T00:00:00+00:00"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user