Compare commits

...

6 Commits

Author SHA1 Message Date
Dean Karn 1751865845 Update README.md 2019-05-23 07:51:41 -07:00
Dean Karn 0a9a3aab3e Merge pull request #76 from v4lproik/add-repository-vulnerability-alert
Add repository vulnerability alert event
2019-05-23 07:51:04 -07:00
jrousseau 43ffb318d2 Add repository vulnerability alert event 2019-05-22 14:09:39 +02:00
Dean Karn 6edb377cee Update README.md 2019-05-20 13:34:26 -07:00
Dean Karn c205145bc6 Merge pull request #75 from maguro/v5
Update PipelineEventPayload with Job
2019-05-20 13:33:52 -07:00
Alan D. Cabrera a8ef7768a6 Update Pipeline even with jobs 2019-05-20 06:53:40 -07:00
7 changed files with 152 additions and 48 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Library webhooks
================
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v5/logo.png">![Project status](https://img.shields.io/badge/version-5.10.0-green.svg)
<img align="right" src="https://raw.githubusercontent.com/go-playground/webhooks/v5/logo.png">![Project status](https://img.shields.io/badge/version-5.11.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/webhooks.svg?branch=v5)](https://travis-ci.org/go-playground/webhooks)
[![Coverage Status](https://coveralls.io/repos/go-playground/webhooks/badge.svg?branch=v5&service=github)](https://coveralls.io/github/go-playground/webhooks?branch=v5)
[![Go Report Card](https://goreportcard.com/badge/go-playground/webhooks)](https://goreportcard.com/report/go-playground/webhooks)
+5
View File
@@ -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)
+10
View File
@@ -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,
+34
View File
@@ -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
View File
@@ -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"`
+33
View File
@@ -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"
}
}
+27 -5
View File
@@ -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