Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion github/code-scanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@ import (
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/
type CodeScanningService service

// Tool represents the tool used to generate a GitHub Code Scanning Alert.
//
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository
type Tool struct {
Name *string `json:"name,omitempty"`
GUID *string `json:"guid,omitempty"`
Version *string `json:"version,omitempty"`
}

// Alert represents an individual GitHub Code Scanning Alert on a single repository.
//
// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository
type Alert struct {
RuleID *string `json:"rule_id,omitempty"`
RuleSeverity *string `json:"rule_severity,omitempty"`
RuleDescription *string `json:"rule_description,omitempty"`
Tool *string `json:"tool,omitempty"`
Tool *Tool `json:"tool,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
Open *bool `json:"open,omitempty"`
ClosedBy *User `json:"closed_by,omitempty"`
Expand Down
24 changes: 18 additions & 6 deletions github/code-scanning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
"rule_id":"js/trivial-conditional",
"rule_severity":"warning",
"rule_description":"Useless conditional",
"tool":"CodeQL",
"tool": {
"name": "CodeQL",
"guid": null,
"version": "1.4.0"
},
"created_at":"2020-05-06T12:00:00Z",
"open":true,
"closed_by":null,
Expand All @@ -76,7 +80,11 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
"rule_id":"js/useless-expression",
"rule_severity":"warning",
"rule_description":"Expression has no effect",
"tool":"CodeQL",
"tool": {
"name": "CodeQL",
"guid": null,
"version": "1.4.0"
},
"created_at":"2020-05-06T12:00:00Z",
"open":true,
"closed_by":null,
Expand All @@ -99,7 +107,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
RuleID: String("js/trivial-conditional"),
RuleSeverity: String("warning"),
RuleDescription: String("Useless conditional"),
Tool: String("CodeQL"),
Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")},
CreatedAt: &date,
Open: Bool(true),
ClosedBy: nil,
Expand All @@ -111,7 +119,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) {
RuleID: String("js/useless-expression"),
RuleSeverity: String("warning"),
RuleDescription: String("Expression has no effect"),
Tool: String("CodeQL"),
Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")},
CreatedAt: &date,
Open: Bool(true),
ClosedBy: nil,
Expand Down Expand Up @@ -148,7 +156,11 @@ func TestActionsService_GetAlert(t *testing.T) {
fmt.Fprint(w, `{"rule_id":"js/useless-expression",
"rule_severity":"warning",
"rule_description":"Expression has no effect",
"tool":"CodeQL",
"tool": {
"name": "CodeQL",
"guid": null,
"version": "1.4.0"
},
"created_at":"2019-01-02T15:04:05Z",
"open":true,
"closed_by":null,
Expand All @@ -168,7 +180,7 @@ func TestActionsService_GetAlert(t *testing.T) {
RuleID: String("js/useless-expression"),
RuleSeverity: String("warning"),
RuleDescription: String("Expression has no effect"),
Tool: String("CodeQL"),
Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")},
CreatedAt: &date,
Open: Bool(true),
ClosedBy: nil,
Expand Down
34 changes: 29 additions & 5 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 31 additions & 4 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.