Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1751865845 | |||
| 0a9a3aab3e | |||
| 43ffb318d2 | |||
| 6edb377cee | |||
| c205145bc6 | |||
| a8ef7768a6 |
@@ -1,6 +1,6 @@
|
||||
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://coveralls.io/github/go-playground/webhooks?branch=v5)
|
||||
[](https://goreportcard.com/report/go-playground/webhooks)
|
||||
|
||||
@@ -60,6 +60,7 @@ const (
|
||||
PushEvent Event = "push"
|
||||
ReleaseEvent Event = "release"
|
||||
RepositoryEvent Event = "repository"
|
||||
RepositoryVulnerabilityAlertEvent Event = "repository_vulnerability_alert"
|
||||
SecurityAdvisoryEvent Event = "security_advisory"
|
||||
StatusEvent Event = "status"
|
||||
TeamEvent Event = "team"
|
||||
@@ -289,6 +290,10 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
|
||||
var pl RepositoryPayload
|
||||
err = json.Unmarshal([]byte(payload), &pl)
|
||||
return pl, err
|
||||
case RepositoryVulnerabilityAlertEvent:
|
||||
var pl RepositoryVulnerabilityAlertPayload
|
||||
err = json.Unmarshal([]byte(payload), &pl)
|
||||
return pl, err
|
||||
case SecurityAdvisoryEvent:
|
||||
var pl SecurityAdvisoryPayload
|
||||
err = json.Unmarshal([]byte(payload), &pl)
|
||||
|
||||
@@ -453,6 +453,16 @@ func TestWebhooks(t *testing.T) {
|
||||
"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",
|
||||
event: SecurityAdvisoryEvent,
|
||||
|
||||
@@ -5260,6 +5260,40 @@ type RepositoryPayload struct {
|
||||
} `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.
|
||||
type SecurityAdvisoryPayload struct {
|
||||
Action string `json:"action"`
|
||||
|
||||
+3
-3
@@ -109,7 +109,7 @@ type PipelineEventPayload struct {
|
||||
Project Project `json:"project"`
|
||||
Commit Commit `json:"commit"`
|
||||
ObjectAttributes ObjectAttributes `json:"object_attributes"`
|
||||
Builds []Build `json:"builds"`
|
||||
Jobs []Job `json:"jobs"`
|
||||
}
|
||||
|
||||
// CommentEventPayload contains the information for GitLab's comment event
|
||||
@@ -193,8 +193,8 @@ type Issue struct {
|
||||
IID int64 `json:"iid"`
|
||||
}
|
||||
|
||||
// Build contains all of the GitLab build information
|
||||
type Build struct {
|
||||
// Job contains all of the GitLab job information
|
||||
type Job struct {
|
||||
ID int64 `json:"id"`
|
||||
Stage string `json:"stage"`
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
Vendored
+27
-5
@@ -14,7 +14,13 @@
|
||||
],
|
||||
"created_at": "2016-08-12 15:23:28 UTC",
|
||||
"finished_at": "2016-08-12 15:26:29 UTC",
|
||||
"duration": 63
|
||||
"duration": 63,
|
||||
"variables": [
|
||||
{
|
||||
"key": "NESTOR_PROD_ENVIRONMENT",
|
||||
"value": "us-west-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"user":{
|
||||
"name": "Administrator",
|
||||
@@ -22,6 +28,7 @@
|
||||
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
|
||||
},
|
||||
"project":{
|
||||
"id": 1,
|
||||
"name": "Gitlab Test",
|
||||
"description": "Atque in sunt eos similique dolores voluptatem.",
|
||||
"web_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
|
||||
@@ -43,7 +50,7 @@
|
||||
"email": "user@gitlab.com"
|
||||
}
|
||||
},
|
||||
"builds":[
|
||||
"jobs":[
|
||||
{
|
||||
"id": 380,
|
||||
"stage": "deploy",
|
||||
@@ -80,7 +87,12 @@
|
||||
"username": "root",
|
||||
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
|
||||
},
|
||||
"runner": null,
|
||||
"runner": {
|
||||
"id":380987,
|
||||
"description":"shared-runners-manager-6.gitlab.com",
|
||||
"active":true,
|
||||
"is_shared":true
|
||||
},
|
||||
"artifacts_file":{
|
||||
"filename": null,
|
||||
"size": null
|
||||
@@ -101,7 +113,12 @@
|
||||
"username": "root",
|
||||
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
|
||||
},
|
||||
"runner": null,
|
||||
"runner": {
|
||||
"id":380987,
|
||||
"description":"shared-runners-manager-6.gitlab.com",
|
||||
"active":true,
|
||||
"is_shared":true
|
||||
},
|
||||
"artifacts_file":{
|
||||
"filename": null,
|
||||
"size": null
|
||||
@@ -122,7 +139,12 @@
|
||||
"username": "root",
|
||||
"avatar_url": "http://www.gravatar.com/avatar/e32bd13e2add097461cb96824b7a829c?s=80\u0026d=identicon"
|
||||
},
|
||||
"runner": null,
|
||||
"runner": {
|
||||
"id":380987,
|
||||
"description":"shared-runners-manager-6.gitlab.com",
|
||||
"active":true,
|
||||
"is_shared":true
|
||||
},
|
||||
"artifacts_file":{
|
||||
"filename": null,
|
||||
"size": null
|
||||
|
||||
Reference in New Issue
Block a user