+
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
9 changes: 9 additions & 0 deletions github/code_scanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ type AlertListOptions struct {
// The name of a code scanning tool. Only results by this tool will be listed.
ToolName string `url:"tool_name,omitempty"`

// The GUID of a code scanning tool. Only results by this tool will be listed.
ToolGUID string `url:"tool_guid,omitempty"`

// The direction to sort the results by. Possible values are: asc, desc. Default: desc.
Direction string `url:"direction,omitempty"`

// The property by which to sort the results. Possible values are: created, updated. Default: created.
Sort string `url:"sort,omitempty"`

ListCursorOptions

// Add ListOptions so offset pagination with integer type "page" query parameter is accepted
Expand Down
20 changes: 10 additions & 10 deletions github/code_scanning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {

mux.HandleFunc("/orgs/o/code-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL"})
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL", "tool_guid": "guid", "direction": "asc", "sort": "updated"})
fmt.Fprint(w, `[{
"repository": {
"id": 1,
Expand All @@ -159,7 +159,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {
"rule_description":"Useless conditional",
"tool": {
"name": "CodeQL",
"guid": null,
"guid": "guid",
"version": "1.4.0"
},
"rule": {
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {
}]`)
})

opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL"}
opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL", ToolGUID: "guid", Direction: "asc", Sort: "updated"}
ctx := context.Background()
alerts, _, err := client.CodeScanning.ListAlertsForOrg(ctx, "o", opts)
if err != nil {
Expand All @@ -257,7 +257,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {
RuleID: Ptr("js/trivial-conditional"),
RuleSeverity: Ptr("warning"),
RuleDescription: Ptr("Useless conditional"),
Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")},
Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")},
Rule: &Rule{
ID: Ptr("js/trivial-conditional"),
Severity: Ptr("warning"),
Expand Down Expand Up @@ -477,14 +477,14 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {

mux.HandleFunc("/repos/o/r/code-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL"})
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL", "tool_guid": "guid", "direction": "asc", "sort": "updated"})
fmt.Fprint(w, `[{
"rule_id":"js/trivial-conditional",
"rule_severity":"warning",
"rule_description":"Useless conditional",
"tool": {
"name": "CodeQL",
"guid": null,
"guid": "guid",
"version": "1.4.0"
},
"rule": {
Expand Down Expand Up @@ -526,7 +526,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
"rule_description":"Expression has no effect",
"tool": {
"name": "CodeQL",
"guid": null,
"guid": "guid",
"version": "1.4.0"
},
"rule": {
Expand Down Expand Up @@ -564,7 +564,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
}]`)
})

opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL"}
opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL", ToolGUID: "guid", Direction: "asc", Sort: "updated"}
ctx := context.Background()
alerts, _, err := client.CodeScanning.ListAlertsForRepo(ctx, "o", "r", opts)
if err != nil {
Expand All @@ -577,7 +577,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
RuleID: Ptr("js/trivial-conditional"),
RuleSeverity: Ptr("warning"),
RuleDescription: Ptr("Useless conditional"),
Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")},
Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")},
Rule: &Rule{
ID: Ptr("js/trivial-conditional"),
Severity: Ptr("warning"),
Expand Down Expand Up @@ -613,7 +613,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
RuleID: Ptr("js/useless-expression"),
RuleSeverity: Ptr("warning"),
RuleDescription: Ptr("Expression has no effect"),
Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")},
Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")},
Rule: &Rule{
ID: Ptr("js/useless-expression"),
Severity: Ptr("warning"),
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载