Skip to content

Commit

Permalink
Adds test case for code_scanning_alert event
Browse files Browse the repository at this point in the history
  • Loading branch information
ffeldmann committed Dec 17, 2023
1 parent 1c740f1 commit 26d02e6
Show file tree
Hide file tree
Showing 2 changed files with 217 additions and 0 deletions.
9 changes: 9 additions & 0 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,15 @@ func TestWebhooks(t *testing.T) {
"X-Github-Event": []string{"github_app_authorization"},
},
},
{
name: "CodeScanningAlertEvent",
event: CodeScanningAlertEvent,
typ: CodeScanningAlertPayload{},
filename: "../testdata/github/code_scanning_alert.json",
headers: http.Header{
"X-Github-Event": []string{"code_scanning_alert"},
},
},
}

for _, tt := range tests {
Expand Down
208 changes: 208 additions & 0 deletions testdata/github/code_scanning_alert.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"action": "reopened_by_user",
"alert": {
"number": 2996,
"created_at": "2023-12-12T09:04:37Z",
"updated_at": "2023-12-17T13:40:01Z",
"url": "https://github.com/api/v3/repos/dummyrepo/non-existing/code-scanning/alerts/2996",
"html_url": "https://github.com/dummyrepo/non-existing/security/code-scanning/2996",
"state": "open",
"fixed_at": null,
"dismissed_by": null,
"dismissed_at": null,
"dismissed_reason": null,
"dismissed_comment": null,
"rule": {
"id": "CVE-2023-123456",
"severity": "note",
"description": "curl: cookie injection with none file",
"name": "OsPackageVulnerability",
"tags": [
"LOW",
"security",
"vulnerability"
],
"full_description": "This flaw allows an attacker to insert cookies at will into a running program.",
"help": "**Vulnerability CVE-2023-123456**\n",
"help_uri": "https://avd.aquasec.com/nvd/cve-2023-123456",
"security_severity_level": "low"
},
"tool": {
"name": "Trivy",
"guid": null,
"version": "0.47.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/image.yml",
"environment": "{}",
"category": ".github/workflows/image.yml",
"state": "open",
"commit_sha": "285b53e372a84db195d9cdaecea544601045c9e0",
"message": {
"text": "Package: libcurl3-gnutls\nInstalled Version: 7.74.0-1.3+deb11u1\nVulnerability CVE-2023-123456\nSeverity: LOW\nFixed Version: 7.74.0-1.3+deb11u10\nLink: [CVE-2023-123456](https://avd.aquasec.com/nvd/cve-2023-123456)"
},
"location": {
"path": "some-path",
"start_line": 1,
"end_line": 1,
"start_column": 1,
"end_column": 1
},
"classifications": [

]
},
"instances_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/code-scanning/alerts/2996/instances"
},
"ref": "",
"commit_oid": "",
"repository": {
"id": 89033,
"node_id": "MDEwOlJlcG9zaXRvcnk4OTAzMw==",
"name": "somerepo",
"full_name": "someorg/somerepo",
"private": false,
"owner": {
"login": "someorg",
"id": 33886,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMzODg2",
"avatar_url": "https://avatars.github.com/u/33886?",
"gravatar_id": "",
"url": "https://github.com/api/v3/users/someorg",
"html_url": "https://github.com/someorg",
"followers_url": "https://github.com/api/v3/users/someorg/followers",
"following_url": "https://github.com/api/v3/users/someorg/following{/other_user}",
"gists_url": "https://github.com/api/v3/users/someorg/gists{/gist_id}",
"starred_url": "https://github.com/api/v3/users/someorg/starred{/owner}{/repo}",
"subscriptions_url": "https://github.com/api/v3/users/someorg/subscriptions",
"organizations_url": "https://github.com/api/v3/users/someorg/orgs",
"repos_url": "https://github.com/api/v3/users/someorg/repos",
"events_url": "https://github.com/api/v3/users/someorg/events{/privacy}",
"received_events_url": "https://github.com/api/v3/users/someorg/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/someorg/somerepo",
"description": "Some description",
"fork": false,
"url": "https://github.com/api/v3/repos/someorg/somerepo",
"forks_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/forks",
"keys_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/keys{/key_id}",
"collaborators_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/collaborators{/collaborator}",
"teams_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/teams",
"hooks_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/hooks",
"issue_events_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/issues/events{/number}",
"events_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/events",
"assignees_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/assignees{/user}",
"branches_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/branches{/branch}",
"tags_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/tags",
"blobs_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/git/blobs{/sha}",
"git_tags_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/git/tags{/sha}",
"git_refs_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/git/refs{/sha}",
"trees_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/git/trees{/sha}",
"statuses_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/statuses/{sha}",
"languages_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/languages",
"stargazers_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/stargazers",
"contributors_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/contributors",
"subscribers_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/subscribers",
"subscription_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/subscription",
"commits_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/commits{/sha}",
"git_commits_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/git/commits{/sha}",
"comments_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/comments{/number}",
"issue_comment_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/issues/comments{/number}",
"contents_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/contents/{+path}",
"compare_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/compare/{base}...{head}",
"merges_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/merges",
"archive_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/{archive_format}{/ref}",
"downloads_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/downloads",
"issues_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/issues{/number}",
"pulls_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/pulls{/number}",
"milestones_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/milestones{/number}",
"notifications_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/notifications{?since,all,participating}",
"labels_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/labels{/name}",
"releases_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/releases{/id}",
"deployments_url": "https://github.com/api/v3/repos/dummyrepo/non-existing/deployments",
"created_at": "2022-01-24T06:53:38Z",
"updated_at": "2023-06-15T13:56:45Z",
"pushed_at": "2023-12-15T09:52:10Z",
"git_url": "git://github.com/somerepo/someorg.git",
"ssh_url": "git@github.com:somerepo/someorg.git",
"clone_url": "https://github.com/somerepo/someorg.git",
"svn_url": "https://github.com/somerepo/someorg",
"homepage": "",
"size": 28828,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Shell",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"has_discussions": false,
"forks_count": 1,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 10,
"license": null,
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [
"sometopic"
],
"visibility": "public",
"forks": 1,
"open_issues": 10,
"watchers": 0,
"default_branch": "main"
},
"organization": {
"login": "someorg",
"id": 33886,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjMzODg2",
"url": "https://github.com/api/v3/orgs/someorg",
"repos_url": "https://github.com/api/v3/orgs/someorg/repos",
"events_url": "https://github.com/api/v3/orgs/someorg/events",
"hooks_url": "https://github.com/api/v3/orgs/someorg/hooks",
"issues_url": "https://github.com/api/v3/orgs/someorg/issues",
"members_url": "https://github.com/api/v3/orgs/someorg/members{/member}",
"public_members_url": "https://github.com/api/v3/orgs/someorg/public_members{/member}",
"avatar_url": "https://avatars.github.com/u/33886?",
"description": "Some description."
},
"enterprise": {
"id": 1,
"slug": "some-company",
"name": "Some Company",
"node_id": "MDEwOkVudGVabcJpc2Ux",
"avatar_url": "https://avatars.github.com/b/1?",
"description": "",
"website_url": "https://github.com/",
"html_url": "https://github.com/enterprises/some-company",
"created_at": "2018-11-29T17:39:39Z",
"updated_at": "2023-06-20T14:11:12Z"
},
"sender": {
"login": "some-user",
"id": 9773,
"node_id": "MDQ6VXabcdk3NzM=",
"avatar_url": "https://avatars.github.com/u/9773?",
"gravatar_id": "",
"url": "https://github.com/api/v3/users/some-user",
"html_url": "https://github.com/some-user",
"followers_url": "https://github.com/api/v3/users/some-user/followers",
"following_url": "https://github.com/api/v3/users/some-user/following{/other_user}",
"gists_url": "https://github.com/api/v3/users/some-user/gists{/gist_id}",
"starred_url": "https://github.com/api/v3/users/some-user/starred{/owner}{/repo}",
"subscriptions_url": "https://github.com/api/v3/users/some-user/subscriptions",
"organizations_url": "https://github.com/api/v3/users/some-user/orgs",
"repos_url": "https://github.com/api/v3/users/some-user/repos",
"events_url": "https://github.com/api/v3/users/some-user/events{/privacy}",
"received_events_url": "https://github.com/api/v3/users/some-user/received_events",
"type": "User",
"site_admin": false
}
}

0 comments on commit 26d02e6

Please sign in to comment.