Compare commits

..

9 Commits

Author SHA1 Message Date
Dean Karn d228b48c40 Update README.md 2019-04-30 07:55:25 -07:00
Dean Karn 869ac76ba8 Merge pull request #69 from hatstand/add-security-advisory
Add github security advisory event
2019-04-30 07:55:04 -07:00
John Maguire ebe6b8d143 Add test for security_advisory 2019-04-17 16:09:34 +01:00
John Maguire c271d4f1c6 Parse SecurityAdvisory events 2019-04-17 15:59:55 +01:00
John Maguire 067e3f1d7a Add SecurityAdvisoryPayload struct 2019-04-17 15:57:20 +01:00
Dean Karn 0f4713c1d1 Update README.md 2019-04-14 09:36:48 -07:00
Dean Karn f053ac6ee1 Merge pull request #67 from hatstand/add-requested-teams
Add requested_team to PullRequestPayload
2019-04-14 09:36:21 -07:00
John Maguire 65f5d60701 Add requested_team to PullRequestPayload 2019-04-04 17:20:26 +01:00
Dean Karn 295aa6531f Update README.md 2019-03-31 05:24:05 -07:00
5 changed files with 151 additions and 41 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Library webhooks 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.6.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.9.0-green.svg)
[![Build Status](https://travis-ci.org/go-playground/webhooks.svg?branch=v5)](https://travis-ci.org/go-playground/webhooks) [![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) [![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) [![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" PushEvent Event = "push"
ReleaseEvent Event = "release" ReleaseEvent Event = "release"
RepositoryEvent Event = "repository" RepositoryEvent Event = "repository"
SecurityAdvisoryEvent Event = "security_advisory"
StatusEvent Event = "status" StatusEvent Event = "status"
TeamEvent Event = "team" TeamEvent Event = "team"
TeamAddEvent Event = "team_add" TeamAddEvent Event = "team_add"
@@ -288,6 +289,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 SecurityAdvisoryEvent:
var pl SecurityAdvisoryPayload
err = json.Unmarshal([]byte(payload), &pl)
return pl, err
case StatusEvent: case StatusEvent:
var pl StatusPayload var pl StatusPayload
err = json.Unmarshal([]byte(payload), &pl) err = json.Unmarshal([]byte(payload), &pl)
+10
View File
@@ -453,6 +453,16 @@ func TestWebhooks(t *testing.T) {
"X-Hub-Signature": []string{"sha1=df442a8af41edd2d42ccdd997938d1d111b0f94e"}, "X-Hub-Signature": []string{"sha1=df442a8af41edd2d42ccdd997938d1d111b0f94e"},
}, },
}, },
{
name: "SecurityAdvisoryEvent",
event: SecurityAdvisoryEvent,
typ: SecurityAdvisoryPayload{},
filename: "../testdata/github/security-advisory.json",
headers: http.Header{
"X-Github-Event": []string{"security_advisory"},
"X-Hub-Signature": []string{"sha1=6a71f24fa69f55469843a91dc3a5c3e29714a565"},
},
},
{ {
name: "StatusEvent", name: "StatusEvent",
event: StatusEvent, event: StatusEvent,
+44
View File
@@ -3728,6 +3728,18 @@ type PullRequestPayload struct {
} `json:"sender"` } `json:"sender"`
Assignee *Assignee `json:"assignee"` Assignee *Assignee `json:"assignee"`
RequestedReviewer *Assignee `json:"requested_reviewer"` RequestedReviewer *Assignee `json:"requested_reviewer"`
RequestedTeam struct {
Name string `json:"name"`
ID int64 `json:"id"`
Slug string `json:"slug"`
Description string `json:"description"`
Privacy string `json:"privacy"`
URL string `json:"url"`
HTMLURL string `json:"html_url"`
MembersURL string `json:"members_url"`
RepositoriesURL string `json:"repositories_url"`
Permission string `json:"permission"`
} `json:"requested_team"`
Installation struct { Installation struct {
ID int64 `json:"id"` ID int64 `json:"id"`
} `json:"installation"` } `json:"installation"`
@@ -5065,6 +5077,38 @@ type RepositoryPayload struct {
} `json:"sender"` } `json:"sender"`
} }
// SecurityAdvisoryPayload contains the information for GitHub's security_advisory hook event.
type SecurityAdvisoryPayload struct {
Action string `json:"action"`
SecurityAdvisory struct {
GHSAID string `json:"ghsa_id"`
Summary string `json:"summary"`
Description string `json:"description"`
Severity string `json:"string"`
Identifiers []struct {
Value string `json:"value"`
Type string `json:"type"`
} `json:"identifiers"`
References []struct {
URL string `json:"url"`
} `json:"references"`
PublishedAt time.Time `json:"published_at"`
UpdatedAt time.Time `json:"updated_at"`
WithdrawnAt *time.Time `json:"withdrawn_at"`
Vulnerabilities []struct {
Package struct {
Ecosystem string `json:"ecosystem"`
Name string `json:"name"`
}
Severity string `json:"severity"`
VulnerableVersionRange string `json:"vulnerable_version_range"`
FirstPatchedVersion *struct {
Identifier string `json:"identifier"`
} `json:"first_patched_version"`
} `json:"vulnerabilities"`
} `json:"security_advisory"`
}
// StatusPayload contains the information for GitHub's status hook event // StatusPayload contains the information for GitHub's status hook event
type StatusPayload struct { type StatusPayload struct {
ID int64 `json:"id"` ID int64 `json:"id"`
+51
View File
@@ -0,0 +1,51 @@
{
"action": "published",
"security_advisory": {
"ghsa_id": "GHSA-rf4j-j272-fj86",
"summary": "Moderate severity vulnerability that affects django",
"description": "django.contrib.auth.forms.AuthenticationForm in Django 2.0 before 2.0.2, and 1.11.8 and 1.11.9, allows remote attackers to obtain potentially sensitive information by leveraging data exposure from the confirm_login_allowed() method, as demonstrated by discovering whether a user account is inactive.",
"severity": "moderate",
"identifiers": [
{
"value": "GHSA-rf4j-j272-fj86",
"type": "GHSA"
},
{
"value": "CVE-2018-6188",
"type": "CVE"
}
],
"references": [
{
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-6188"
}
],
"published_at": "2018-10-03T21:13:54Z",
"updated_at": "2018-10-03T21:13:54Z",
"withdrawn_at": null,
"vulnerabilities": [
{
"package": {
"ecosystem": "pip",
"name": "django"
},
"severity": "moderate",
"vulnerable_version_range": ">= 2.0.0, < 2.0.2",
"first_patched_version": {
"identifier": "2.0.2"
}
},
{
"package": {
"ecosystem": "pip",
"name": "django"
},
"severity": "moderate",
"vulnerable_version_range": ">= 1.11.8, < 1.11.10",
"first_patched_version": {
"identifier": "1.11.10"
}
}
]
}
}