From c0987ad382ec621d861489ecafa75e7f3323ed44 Mon Sep 17 00:00:00 2001 From: Abdul Al-Kibbe Date: Fri, 26 Nov 2021 10:19:24 +0100 Subject: [PATCH 1/5] Add CodeScanningService.ListAnalysesForRepo and CodeScanningService.GetAnalysis --- github/code-scanning.go | 85 ++++++++++++++ github/code-scanning_test.go | 200 ++++++++++++++++++++++++++++++++ github/github-accessors.go | 120 +++++++++++++++++++ github/github-accessors_test.go | 147 +++++++++++++++++++++++ 4 files changed, 552 insertions(+) diff --git a/github/code-scanning.go b/github/code-scanning.go index 4508c3390d8..52a65f1ee8d 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -119,6 +119,38 @@ type AlertListOptions struct { ListOptions } +// AnalysesListOptions specifies optional parameters to the CodeScanningService.ListAnalysesForRepo method. +type AnalysesListOptions struct { + // Return code scanning analyses belonging to the same SARIF upload. + SarifID string `url:"sarif_id,omitempty"` + + // Return code scanning analyses for a specific branch reference. The ref can be formatted as refs/heads/ or simply . + Ref string `url:"ref,omitempty"` + + ListOptions +} + +// Analysis represents an individual GitHub Code Scanning Analysis on a single repository. +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository +type Analysis struct { + ID *int64 `json:"id,omitempty"` + Ref *string `json:"ref,omitempty"` + CommitSha *string `json:"commit_sha,omitempty"` + AnalysisKey *string `json:"analysis_key,omitempty"` + Environment *string `json:"environment,omitempty"` + Error *string `json:"error,omitempty"` + Category *string `json:"category,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + ResultsCount *int `json:"results_count,omitempty"` + RulesCount *int `json:"rules_count,omitempty"` + URL *string `json:"url,omitempty"` + SarifID *string `json:"sarif_id,omitempty"` + Tool *Tool `json:"tool,omitempty"` + Deletable *bool `json:"deletable,omitempty"` + Warning *string `json:"warning,omitempty"` +} + // SarifAnalysis specifies the results of a code scanning job. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data @@ -215,3 +247,56 @@ func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo strin return sarifID, resp, nil } + +// ListAnalysesForRepo lists code scanning analyses for a repository. +// +// Lists the details of all code scanning analyses for a repository, starting with the most recent. +// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events +// read permission to use this endpoint. +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository +func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*Analysis, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses", owner, repo) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var analyses []*Analysis + resp, err := s.client.Do(ctx, req, &analyses) + if err != nil { + return nil, resp, err + } + + return analyses, resp, nil +} + +// GetAnalysis gets a single code scanning analysis for a repository. +// +// You must use an access token with the security_events scope to use this endpoint. +// GitHub Apps must have the security_events read permission to use this endpoint. +// +// The security analysis_id is the ID of the analysis, as returned from the ListAnalysesForRepo operation. +// +// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/#get-a-code-scanning-alert +func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*Analysis, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + analysis := new(Analysis) + resp, err := s.client.Do(ctx, req, analysis) + if err != nil { + return nil, resp, err + } + + return analysis, resp, nil +} diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index e96d0a0d14f..195e8a2588f 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -530,3 +530,203 @@ func TestMessage_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/code-scanning/analyses", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"sarif_id": "8981cd8e-b078-4ac3-a3be-1dad7dbd0b582", "ref": "heads/master"}) + fmt.Fprint(w, `[ + { + "ref": "refs/heads/main", + "commit_sha": "d99612c3e1f2970085cfbaeadf8f010ef69bad83", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"python\"}", + "error": "", + "category": ".github/workflows/codeql-analysis.yml:analyze/language:python", + "created_at": "2020-08-27T15:05:21Z", + "results_count": 17, + "rules_count": 49, + "id": 201, + "url": "https://api.github.com/repos/o/r/code-scanning/analyses/201", + "sarif_id": "8981cd8e-b078-4ac3-a3be-1dad7dbd0b582", + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.4.0" + }, + "deletable": true, + "warning": "" + }, + { + "ref": "refs/heads/my-branch", + "commit_sha": "c8cff6510d4d084fb1b4aa13b64b97ca12b07321", + "analysis_key": ".github/workflows/shiftleft.yml:build", + "environment": "{}", + "error": "", + "category": ".github/workflows/shiftleft.yml:build/", + "created_at": "2020-08-27T15:05:21Z", + "results_count": 17, + "rules_count": 32, + "id": 200, + "url": "https://api.github.com/repos/o/r/code-scanning/analyses/200", + "sarif_id": "8981cd8e-b078-4ac3-a3be-1dad7dbd0b582", + "tool": { + "name": "Python Security Analysis", + "guid": null, + "version": "1.2.0" + }, + "deletable": true, + "warning": "" + } + ]`) + }) + + opts := &AnalysesListOptions{SarifID: "8981cd8e-b078-4ac3-a3be-1dad7dbd0b582", Ref: "heads/master"} + ctx := context.Background() + analyses, _, err := client.CodeScanning.ListAnalysesForRepo(ctx, "o", "r", opts) + if err != nil { + t.Errorf("CodeScanning.ListAnalysesForRepo returned error: %v", err) + } + + date := &Timestamp{time.Date(2020, time.August, 27, 15, 05, 21, 0, time.UTC)} + want := []*Analysis{ + { + ID: Int64(201), + Ref: String("refs/heads/main"), + CommitSha: String("d99612c3e1f2970085cfbaeadf8f010ef69bad83"), + AnalysisKey: String(".github/workflows/codeql-analysis.yml:analyze"), + Environment: String("{\"language\":\"python\"}"), + Error: String(""), + Category: String(".github/workflows/codeql-analysis.yml:analyze/language:python"), + CreatedAt: date, + ResultsCount: Int(17), + RulesCount: Int(49), + URL: String("https://api.github.com/repos/o/r/code-scanning/analyses/201"), + SarifID: String("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), + Tool: &Tool{ + Name: String("CodeQL"), + GUID: nil, + Version: String("2.4.0"), + }, + Deletable: Bool(true), + Warning: String(""), + }, + { + ID: Int64(200), + Ref: String("refs/heads/my-branch"), + CommitSha: String("c8cff6510d4d084fb1b4aa13b64b97ca12b07321"), + AnalysisKey: String(".github/workflows/shiftleft.yml:build"), + Environment: String("{}"), + Error: String(""), + Category: String(".github/workflows/shiftleft.yml:build/"), + CreatedAt: date, + ResultsCount: Int(17), + RulesCount: Int(32), + URL: String("https://api.github.com/repos/o/r/code-scanning/analyses/200"), + SarifID: String("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), + Tool: &Tool{ + Name: String("Python Security Analysis"), + GUID: nil, + Version: String("1.2.0"), + }, + Deletable: Bool(true), + Warning: String(""), + }, + } + if !cmp.Equal(analyses, want) { + t.Errorf("CodeScanning.ListAnalysesForRepo returned %+v, want %+v", analyses, want) + } + + const methodName = "ListAnalysesForRepo" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.CodeScanning.ListAnalysesForRepo(ctx, "\n", "\n", opts) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.CodeScanning.ListAnalysesForRepo(ctx, "o", "r", opts) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestCodeScanningService_GetAnalysis(t *testing.T) { + client, mux, _, teardown := setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/code-scanning/analyses/3602840", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "ref": "refs/heads/main", + "commit_sha": "c18c69115654ff0166991962832dc2bd7756e655", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "error": "", + "category": ".github/workflows/codeql-analysis.yml:analyze/language:javascript", + "created_at": "2021-01-13T11:55:49Z", + "results_count": 3, + "rules_count": 67, + "id": 3602840, + "url": "https://api.github.com/repos/o/r/code-scanning/analyses/201", + "sarif_id": "47177e22-5596-11eb-80a1-c1e54ef945c6", + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.4.0" + }, + "deletable": true, + "warning": "" + }`) + }) + + ctx := context.Background() + analysis, _, err := client.CodeScanning.GetAnalysis(ctx, "o", "r", 3602840) + if err != nil { + t.Errorf("CodeScanning.GetAnalysis returned error: %v", err) + } + + date := &Timestamp{time.Date(2021, time.January, 13, 11, 55, 49, 0, time.UTC)} + want := &Analysis{ + ID: Int64(3602840), + Ref: String("refs/heads/main"), + CommitSha: String("c18c69115654ff0166991962832dc2bd7756e655"), + AnalysisKey: String(".github/workflows/codeql-analysis.yml:analyze"), + Environment: String("{\"language\":\"javascript\"}"), + Error: String(""), + Category: String(".github/workflows/codeql-analysis.yml:analyze/language:javascript"), + CreatedAt: date, + ResultsCount: Int(3), + RulesCount: Int(67), + URL: String("https://api.github.com/repos/o/r/code-scanning/analyses/201"), + SarifID: String("47177e22-5596-11eb-80a1-c1e54ef945c6"), + Tool: &Tool{ + Name: String("CodeQL"), + GUID: nil, + Version: String("2.4.0"), + }, + Deletable: Bool(true), + Warning: String(""), + } + if !cmp.Equal(analysis, want) { + t.Errorf("CodeScanning.GetAnalysis returned %+v, want %+v", analysis, want) + } + + const methodName = "GetAnalysis" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.CodeScanning.GetAnalysis(ctx, "\n", "\n", -123) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.CodeScanning.GetAnalysis(ctx, "o", "r", 3602840) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index 7bd870167e6..e61726663d3 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -284,6 +284,126 @@ func (a *Alert) GetURL() string { return *a.URL } +// GetAnalysisKey returns the AnalysisKey field if it's non-nil, zero value otherwise. +func (a *Analysis) GetAnalysisKey() string { + if a == nil || a.AnalysisKey == nil { + return "" + } + return *a.AnalysisKey +} + +// GetCategory returns the Category field if it's non-nil, zero value otherwise. +func (a *Analysis) GetCategory() string { + if a == nil || a.Category == nil { + return "" + } + return *a.Category +} + +// GetCommitSha returns the CommitSha field if it's non-nil, zero value otherwise. +func (a *Analysis) GetCommitSha() string { + if a == nil || a.CommitSha == nil { + return "" + } + return *a.CommitSha +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *Analysis) GetCreatedAt() Timestamp { + if a == nil || a.CreatedAt == nil { + return Timestamp{} + } + return *a.CreatedAt +} + +// GetDeletable returns the Deletable field if it's non-nil, zero value otherwise. +func (a *Analysis) GetDeletable() bool { + if a == nil || a.Deletable == nil { + return false + } + return *a.Deletable +} + +// GetEnvironment returns the Environment field if it's non-nil, zero value otherwise. +func (a *Analysis) GetEnvironment() string { + if a == nil || a.Environment == nil { + return "" + } + return *a.Environment +} + +// GetError returns the Error field if it's non-nil, zero value otherwise. +func (a *Analysis) GetError() string { + if a == nil || a.Error == nil { + return "" + } + return *a.Error +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *Analysis) GetID() int64 { + if a == nil || a.ID == nil { + return 0 + } + return *a.ID +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (a *Analysis) GetRef() string { + if a == nil || a.Ref == nil { + return "" + } + return *a.Ref +} + +// GetResultsCount returns the ResultsCount field if it's non-nil, zero value otherwise. +func (a *Analysis) GetResultsCount() int { + if a == nil || a.ResultsCount == nil { + return 0 + } + return *a.ResultsCount +} + +// GetRulesCount returns the RulesCount field if it's non-nil, zero value otherwise. +func (a *Analysis) GetRulesCount() int { + if a == nil || a.RulesCount == nil { + return 0 + } + return *a.RulesCount +} + +// GetSarifID returns the SarifID field if it's non-nil, zero value otherwise. +func (a *Analysis) GetSarifID() string { + if a == nil || a.SarifID == nil { + return "" + } + return *a.SarifID +} + +// GetTool returns the Tool field. +func (a *Analysis) GetTool() *Tool { + if a == nil { + return nil + } + return a.Tool +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (a *Analysis) GetURL() string { + if a == nil || a.URL == nil { + return "" + } + return *a.URL +} + +// GetWarning returns the Warning field if it's non-nil, zero value otherwise. +func (a *Analysis) GetWarning() string { + if a == nil || a.Warning == nil { + return "" + } + return *a.Warning +} + // GetVerifiablePasswordAuthentication returns the VerifiablePasswordAuthentication field if it's non-nil, zero value otherwise. func (a *APIMeta) GetVerifiablePasswordAuthentication() bool { if a == nil || a.VerifiablePasswordAuthentication == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index bbdff0ad3f5..484a09383c4 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -308,6 +308,153 @@ func TestAlert_GetURL(tt *testing.T) { a.GetURL() } +func TestAnalysis_GetAnalysisKey(tt *testing.T) { + var zeroValue string + a := &Analysis{AnalysisKey: &zeroValue} + a.GetAnalysisKey() + a = &Analysis{} + a.GetAnalysisKey() + a = nil + a.GetAnalysisKey() +} + +func TestAnalysis_GetCategory(tt *testing.T) { + var zeroValue string + a := &Analysis{Category: &zeroValue} + a.GetCategory() + a = &Analysis{} + a.GetCategory() + a = nil + a.GetCategory() +} + +func TestAnalysis_GetCommitSha(tt *testing.T) { + var zeroValue string + a := &Analysis{CommitSha: &zeroValue} + a.GetCommitSha() + a = &Analysis{} + a.GetCommitSha() + a = nil + a.GetCommitSha() +} + +func TestAnalysis_GetCreatedAt(tt *testing.T) { + var zeroValue Timestamp + a := &Analysis{CreatedAt: &zeroValue} + a.GetCreatedAt() + a = &Analysis{} + a.GetCreatedAt() + a = nil + a.GetCreatedAt() +} + +func TestAnalysis_GetDeletable(tt *testing.T) { + var zeroValue bool + a := &Analysis{Deletable: &zeroValue} + a.GetDeletable() + a = &Analysis{} + a.GetDeletable() + a = nil + a.GetDeletable() +} + +func TestAnalysis_GetEnvironment(tt *testing.T) { + var zeroValue string + a := &Analysis{Environment: &zeroValue} + a.GetEnvironment() + a = &Analysis{} + a.GetEnvironment() + a = nil + a.GetEnvironment() +} + +func TestAnalysis_GetError(tt *testing.T) { + var zeroValue string + a := &Analysis{Error: &zeroValue} + a.GetError() + a = &Analysis{} + a.GetError() + a = nil + a.GetError() +} + +func TestAnalysis_GetID(tt *testing.T) { + var zeroValue int64 + a := &Analysis{ID: &zeroValue} + a.GetID() + a = &Analysis{} + a.GetID() + a = nil + a.GetID() +} + +func TestAnalysis_GetRef(tt *testing.T) { + var zeroValue string + a := &Analysis{Ref: &zeroValue} + a.GetRef() + a = &Analysis{} + a.GetRef() + a = nil + a.GetRef() +} + +func TestAnalysis_GetResultsCount(tt *testing.T) { + var zeroValue int + a := &Analysis{ResultsCount: &zeroValue} + a.GetResultsCount() + a = &Analysis{} + a.GetResultsCount() + a = nil + a.GetResultsCount() +} + +func TestAnalysis_GetRulesCount(tt *testing.T) { + var zeroValue int + a := &Analysis{RulesCount: &zeroValue} + a.GetRulesCount() + a = &Analysis{} + a.GetRulesCount() + a = nil + a.GetRulesCount() +} + +func TestAnalysis_GetSarifID(tt *testing.T) { + var zeroValue string + a := &Analysis{SarifID: &zeroValue} + a.GetSarifID() + a = &Analysis{} + a.GetSarifID() + a = nil + a.GetSarifID() +} + +func TestAnalysis_GetTool(tt *testing.T) { + a := &Analysis{} + a.GetTool() + a = nil + a.GetTool() +} + +func TestAnalysis_GetURL(tt *testing.T) { + var zeroValue string + a := &Analysis{URL: &zeroValue} + a.GetURL() + a = &Analysis{} + a.GetURL() + a = nil + a.GetURL() +} + +func TestAnalysis_GetWarning(tt *testing.T) { + var zeroValue string + a := &Analysis{Warning: &zeroValue} + a.GetWarning() + a = &Analysis{} + a.GetWarning() + a = nil + a.GetWarning() +} + func TestAPIMeta_GetVerifiablePasswordAuthentication(tt *testing.T) { var zeroValue bool a := &APIMeta{VerifiablePasswordAuthentication: &zeroValue} From 94bbbe0eb39a4603930f1a737652e25bb7d0732b Mon Sep 17 00:00:00 2001 From: Abdul Al-Kibbe Date: Fri, 26 Nov 2021 10:22:07 +0100 Subject: [PATCH 2/5] Fix docs reference --- github/code-scanning.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index 52a65f1ee8d..fee46b88c44 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -283,7 +283,7 @@ func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, re // // The security analysis_id is the ID of the analysis, as returned from the ListAnalysesForRepo operation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/#get-a-code-scanning-alert +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#get-a-code-scanning-analysis-for-a-repository func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*Analysis, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id) From 7c83191eacc68791a8863bdc672a957df09335ea Mon Sep 17 00:00:00 2001 From: Abdul Al-Kibbe Date: Fri, 26 Nov 2021 14:50:51 +0100 Subject: [PATCH 3/5] Fix unit test naming for CodeScanningService --- github/code-scanning_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 195e8a2588f..cb98626b649 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -16,7 +16,7 @@ import ( "github.com/google/go-cmp/cmp" ) -func TestActionsService_Alert_ID(t *testing.T) { +func TestCodeScanningService_Alert_ID(t *testing.T) { // Test: nil Alert ID == 0 var a *Alert id := a.ID() @@ -54,7 +54,7 @@ func TestActionsService_Alert_ID(t *testing.T) { } } -func TestActionsService_UploadSarif(t *testing.T) { +func TestCodeScanningService_UploadSarif(t *testing.T) { client, mux, _, teardown := setup() defer teardown() @@ -89,7 +89,7 @@ func TestActionsService_UploadSarif(t *testing.T) { }) } -func TestActionsService_ListAlertsForRepo(t *testing.T) { +func TestCodeScanningService_ListAlertsForRepo(t *testing.T) { client, mux, _, teardown := setup() defer teardown() @@ -283,7 +283,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { }) } -func TestActionsService_GetAlert(t *testing.T) { +func TestCodeScanningService_GetAlert(t *testing.T) { client, mux, _, teardown := setup() defer teardown() From 4421a38b5e34cd5e730351c9819f32b35b688d2c Mon Sep 17 00:00:00 2001 From: Abdul Al-Kibbe Date: Sun, 28 Nov 2021 21:42:04 +0100 Subject: [PATCH 4/5] Consistency fixes --- github/code-scanning.go | 10 +++++----- github/code-scanning_test.go | 8 ++++---- github/github-accessors.go | 24 ++++++++++++++++++++---- github/github-accessors_test.go | 30 +++++++++++++++++++++++++----- 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index fee46b88c44..c00a43d3243 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -122,10 +122,10 @@ type AlertListOptions struct { // AnalysesListOptions specifies optional parameters to the CodeScanningService.ListAnalysesForRepo method. type AnalysesListOptions struct { // Return code scanning analyses belonging to the same SARIF upload. - SarifID string `url:"sarif_id,omitempty"` + SarifID *string `url:"sarif_id,omitempty"` // Return code scanning analyses for a specific branch reference. The ref can be formatted as refs/heads/ or simply . - Ref string `url:"ref,omitempty"` + Ref *string `url:"ref,omitempty"` ListOptions } @@ -136,7 +136,7 @@ type AnalysesListOptions struct { type Analysis struct { ID *int64 `json:"id,omitempty"` Ref *string `json:"ref,omitempty"` - CommitSha *string `json:"commit_sha,omitempty"` + CommitSHA *string `json:"commit_sha,omitempty"` AnalysisKey *string `json:"analysis_key,omitempty"` Environment *string `json:"environment,omitempty"` Error *string `json:"error,omitempty"` @@ -251,8 +251,8 @@ func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo strin // ListAnalysesForRepo lists code scanning analyses for a repository. // // Lists the details of all code scanning analyses for a repository, starting with the most recent. -// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events -// read permission to use this endpoint. +// You must use an access token with the security_events scope to use this endpoint. +// GitHub Apps must have the security_events read permission to use this endpoint. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*Analysis, *Response, error) { diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index cb98626b649..748d5257d9b 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -584,7 +584,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { ]`) }) - opts := &AnalysesListOptions{SarifID: "8981cd8e-b078-4ac3-a3be-1dad7dbd0b582", Ref: "heads/master"} + opts := &AnalysesListOptions{SarifID: String("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), Ref: String("heads/master")} ctx := context.Background() analyses, _, err := client.CodeScanning.ListAnalysesForRepo(ctx, "o", "r", opts) if err != nil { @@ -596,7 +596,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { { ID: Int64(201), Ref: String("refs/heads/main"), - CommitSha: String("d99612c3e1f2970085cfbaeadf8f010ef69bad83"), + CommitSHA: String("d99612c3e1f2970085cfbaeadf8f010ef69bad83"), AnalysisKey: String(".github/workflows/codeql-analysis.yml:analyze"), Environment: String("{\"language\":\"python\"}"), Error: String(""), @@ -617,7 +617,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { { ID: Int64(200), Ref: String("refs/heads/my-branch"), - CommitSha: String("c8cff6510d4d084fb1b4aa13b64b97ca12b07321"), + CommitSHA: String("c8cff6510d4d084fb1b4aa13b64b97ca12b07321"), AnalysisKey: String(".github/workflows/shiftleft.yml:build"), Environment: String("{}"), Error: String(""), @@ -694,7 +694,7 @@ func TestCodeScanningService_GetAnalysis(t *testing.T) { want := &Analysis{ ID: Int64(3602840), Ref: String("refs/heads/main"), - CommitSha: String("c18c69115654ff0166991962832dc2bd7756e655"), + CommitSHA: String("c18c69115654ff0166991962832dc2bd7756e655"), AnalysisKey: String(".github/workflows/codeql-analysis.yml:analyze"), Environment: String("{\"language\":\"javascript\"}"), Error: String(""), diff --git a/github/github-accessors.go b/github/github-accessors.go index e61726663d3..b96650d2c34 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -284,6 +284,22 @@ func (a *Alert) GetURL() string { return *a.URL } +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (a *AnalysesListOptions) GetRef() string { + if a == nil || a.Ref == nil { + return "" + } + return *a.Ref +} + +// GetSarifID returns the SarifID field if it's non-nil, zero value otherwise. +func (a *AnalysesListOptions) GetSarifID() string { + if a == nil || a.SarifID == nil { + return "" + } + return *a.SarifID +} + // GetAnalysisKey returns the AnalysisKey field if it's non-nil, zero value otherwise. func (a *Analysis) GetAnalysisKey() string { if a == nil || a.AnalysisKey == nil { @@ -300,12 +316,12 @@ func (a *Analysis) GetCategory() string { return *a.Category } -// GetCommitSha returns the CommitSha field if it's non-nil, zero value otherwise. -func (a *Analysis) GetCommitSha() string { - if a == nil || a.CommitSha == nil { +// GetCommitSHA returns the CommitSHA field if it's non-nil, zero value otherwise. +func (a *Analysis) GetCommitSHA() string { + if a == nil || a.CommitSHA == nil { return "" } - return *a.CommitSha + return *a.CommitSHA } // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 484a09383c4..0dead1ef4e3 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -308,6 +308,26 @@ func TestAlert_GetURL(tt *testing.T) { a.GetURL() } +func TestAnalysesListOptions_GetRef(tt *testing.T) { + var zeroValue string + a := &AnalysesListOptions{Ref: &zeroValue} + a.GetRef() + a = &AnalysesListOptions{} + a.GetRef() + a = nil + a.GetRef() +} + +func TestAnalysesListOptions_GetSarifID(tt *testing.T) { + var zeroValue string + a := &AnalysesListOptions{SarifID: &zeroValue} + a.GetSarifID() + a = &AnalysesListOptions{} + a.GetSarifID() + a = nil + a.GetSarifID() +} + func TestAnalysis_GetAnalysisKey(tt *testing.T) { var zeroValue string a := &Analysis{AnalysisKey: &zeroValue} @@ -328,14 +348,14 @@ func TestAnalysis_GetCategory(tt *testing.T) { a.GetCategory() } -func TestAnalysis_GetCommitSha(tt *testing.T) { +func TestAnalysis_GetCommitSHA(tt *testing.T) { var zeroValue string - a := &Analysis{CommitSha: &zeroValue} - a.GetCommitSha() + a := &Analysis{CommitSHA: &zeroValue} + a.GetCommitSHA() a = &Analysis{} - a.GetCommitSha() + a.GetCommitSHA() a = nil - a.GetCommitSha() + a.GetCommitSHA() } func TestAnalysis_GetCreatedAt(tt *testing.T) { From 94d6ae9ac3324cbed1727d86cc1b62f96a6aa8f7 Mon Sep 17 00:00:00 2001 From: Abdul Al-Kibbe Date: Sun, 28 Nov 2021 22:00:18 +0100 Subject: [PATCH 5/5] Update ScanningAnalysis struct name --- github/code-scanning.go | 12 +- github/code-scanning_test.go | 8 +- github/github-accessors.go | 240 +++++++++++++------------- github/github-accessors_test.go | 294 ++++++++++++++++---------------- 4 files changed, 277 insertions(+), 277 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index c00a43d3243..9616f3a26d0 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -130,10 +130,10 @@ type AnalysesListOptions struct { ListOptions } -// Analysis represents an individual GitHub Code Scanning Analysis on a single repository. +// ScanningAnalysis represents an individual GitHub Code Scanning ScanningAnalysis on a single repository. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository -type Analysis struct { +type ScanningAnalysis struct { ID *int64 `json:"id,omitempty"` Ref *string `json:"ref,omitempty"` CommitSHA *string `json:"commit_sha,omitempty"` @@ -255,7 +255,7 @@ func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo strin // GitHub Apps must have the security_events read permission to use this endpoint. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository -func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*Analysis, *Response, error) { +func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*ScanningAnalysis, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses", owner, repo) u, err := addOptions(u, opts) if err != nil { @@ -267,7 +267,7 @@ func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, re return nil, nil, err } - var analyses []*Analysis + var analyses []*ScanningAnalysis resp, err := s.client.Do(ctx, req, &analyses) if err != nil { return nil, resp, err @@ -284,7 +284,7 @@ func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, re // The security analysis_id is the ID of the analysis, as returned from the ListAnalysesForRepo operation. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#get-a-code-scanning-analysis-for-a-repository -func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*Analysis, *Response, error) { +func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*ScanningAnalysis, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) @@ -292,7 +292,7 @@ func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo strin return nil, nil, err } - analysis := new(Analysis) + analysis := new(ScanningAnalysis) resp, err := s.client.Do(ctx, req, analysis) if err != nil { return nil, resp, err diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 748d5257d9b..0be58153f02 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -574,7 +574,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { "url": "https://api.github.com/repos/o/r/code-scanning/analyses/200", "sarif_id": "8981cd8e-b078-4ac3-a3be-1dad7dbd0b582", "tool": { - "name": "Python Security Analysis", + "name": "Python Security ScanningAnalysis", "guid": null, "version": "1.2.0" }, @@ -592,7 +592,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { } date := &Timestamp{time.Date(2020, time.August, 27, 15, 05, 21, 0, time.UTC)} - want := []*Analysis{ + want := []*ScanningAnalysis{ { ID: Int64(201), Ref: String("refs/heads/main"), @@ -628,7 +628,7 @@ func TestCodeScanningService_ListAnalysesForRepo(t *testing.T) { URL: String("https://api.github.com/repos/o/r/code-scanning/analyses/200"), SarifID: String("8981cd8e-b078-4ac3-a3be-1dad7dbd0b582"), Tool: &Tool{ - Name: String("Python Security Analysis"), + Name: String("Python Security ScanningAnalysis"), GUID: nil, Version: String("1.2.0"), }, @@ -691,7 +691,7 @@ func TestCodeScanningService_GetAnalysis(t *testing.T) { } date := &Timestamp{time.Date(2021, time.January, 13, 11, 55, 49, 0, time.UTC)} - want := &Analysis{ + want := &ScanningAnalysis{ ID: Int64(3602840), Ref: String("refs/heads/main"), CommitSHA: String("c18c69115654ff0166991962832dc2bd7756e655"), diff --git a/github/github-accessors.go b/github/github-accessors.go index b96650d2c34..4c4dc892c06 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -300,126 +300,6 @@ func (a *AnalysesListOptions) GetSarifID() string { return *a.SarifID } -// GetAnalysisKey returns the AnalysisKey field if it's non-nil, zero value otherwise. -func (a *Analysis) GetAnalysisKey() string { - if a == nil || a.AnalysisKey == nil { - return "" - } - return *a.AnalysisKey -} - -// GetCategory returns the Category field if it's non-nil, zero value otherwise. -func (a *Analysis) GetCategory() string { - if a == nil || a.Category == nil { - return "" - } - return *a.Category -} - -// GetCommitSHA returns the CommitSHA field if it's non-nil, zero value otherwise. -func (a *Analysis) GetCommitSHA() string { - if a == nil || a.CommitSHA == nil { - return "" - } - return *a.CommitSHA -} - -// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. -func (a *Analysis) GetCreatedAt() Timestamp { - if a == nil || a.CreatedAt == nil { - return Timestamp{} - } - return *a.CreatedAt -} - -// GetDeletable returns the Deletable field if it's non-nil, zero value otherwise. -func (a *Analysis) GetDeletable() bool { - if a == nil || a.Deletable == nil { - return false - } - return *a.Deletable -} - -// GetEnvironment returns the Environment field if it's non-nil, zero value otherwise. -func (a *Analysis) GetEnvironment() string { - if a == nil || a.Environment == nil { - return "" - } - return *a.Environment -} - -// GetError returns the Error field if it's non-nil, zero value otherwise. -func (a *Analysis) GetError() string { - if a == nil || a.Error == nil { - return "" - } - return *a.Error -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (a *Analysis) GetID() int64 { - if a == nil || a.ID == nil { - return 0 - } - return *a.ID -} - -// GetRef returns the Ref field if it's non-nil, zero value otherwise. -func (a *Analysis) GetRef() string { - if a == nil || a.Ref == nil { - return "" - } - return *a.Ref -} - -// GetResultsCount returns the ResultsCount field if it's non-nil, zero value otherwise. -func (a *Analysis) GetResultsCount() int { - if a == nil || a.ResultsCount == nil { - return 0 - } - return *a.ResultsCount -} - -// GetRulesCount returns the RulesCount field if it's non-nil, zero value otherwise. -func (a *Analysis) GetRulesCount() int { - if a == nil || a.RulesCount == nil { - return 0 - } - return *a.RulesCount -} - -// GetSarifID returns the SarifID field if it's non-nil, zero value otherwise. -func (a *Analysis) GetSarifID() string { - if a == nil || a.SarifID == nil { - return "" - } - return *a.SarifID -} - -// GetTool returns the Tool field. -func (a *Analysis) GetTool() *Tool { - if a == nil { - return nil - } - return a.Tool -} - -// GetURL returns the URL field if it's non-nil, zero value otherwise. -func (a *Analysis) GetURL() string { - if a == nil || a.URL == nil { - return "" - } - return *a.URL -} - -// GetWarning returns the Warning field if it's non-nil, zero value otherwise. -func (a *Analysis) GetWarning() string { - if a == nil || a.Warning == nil { - return "" - } - return *a.Warning -} - // GetVerifiablePasswordAuthentication returns the VerifiablePasswordAuthentication field if it's non-nil, zero value otherwise. func (a *APIMeta) GetVerifiablePasswordAuthentication() bool { if a == nil || a.VerifiablePasswordAuthentication == nil { @@ -15348,6 +15228,126 @@ func (s *SarifID) GetURL() string { return *s.URL } +// GetAnalysisKey returns the AnalysisKey field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetAnalysisKey() string { + if s == nil || s.AnalysisKey == nil { + return "" + } + return *s.AnalysisKey +} + +// GetCategory returns the Category field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetCategory() string { + if s == nil || s.Category == nil { + return "" + } + return *s.Category +} + +// GetCommitSHA returns the CommitSHA field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetCommitSHA() string { + if s == nil || s.CommitSHA == nil { + return "" + } + return *s.CommitSHA +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetCreatedAt() Timestamp { + if s == nil || s.CreatedAt == nil { + return Timestamp{} + } + return *s.CreatedAt +} + +// GetDeletable returns the Deletable field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetDeletable() bool { + if s == nil || s.Deletable == nil { + return false + } + return *s.Deletable +} + +// GetEnvironment returns the Environment field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetEnvironment() string { + if s == nil || s.Environment == nil { + return "" + } + return *s.Environment +} + +// GetError returns the Error field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetError() string { + if s == nil || s.Error == nil { + return "" + } + return *s.Error +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetID() int64 { + if s == nil || s.ID == nil { + return 0 + } + return *s.ID +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetRef() string { + if s == nil || s.Ref == nil { + return "" + } + return *s.Ref +} + +// GetResultsCount returns the ResultsCount field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetResultsCount() int { + if s == nil || s.ResultsCount == nil { + return 0 + } + return *s.ResultsCount +} + +// GetRulesCount returns the RulesCount field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetRulesCount() int { + if s == nil || s.RulesCount == nil { + return 0 + } + return *s.RulesCount +} + +// GetSarifID returns the SarifID field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetSarifID() string { + if s == nil || s.SarifID == nil { + return "" + } + return *s.SarifID +} + +// GetTool returns the Tool field. +func (s *ScanningAnalysis) GetTool() *Tool { + if s == nil { + return nil + } + return s.Tool +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetURL() string { + if s == nil || s.URL == nil { + return "" + } + return *s.URL +} + +// GetWarning returns the Warning field if it's non-nil, zero value otherwise. +func (s *ScanningAnalysis) GetWarning() string { + if s == nil || s.Warning == nil { + return "" + } + return *s.Warning +} + // GetActive returns the Active field if it's non-nil, zero value otherwise. func (s *SCIMUserAttributes) GetActive() bool { if s == nil || s.Active == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 0dead1ef4e3..e3174035ddb 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -328,153 +328,6 @@ func TestAnalysesListOptions_GetSarifID(tt *testing.T) { a.GetSarifID() } -func TestAnalysis_GetAnalysisKey(tt *testing.T) { - var zeroValue string - a := &Analysis{AnalysisKey: &zeroValue} - a.GetAnalysisKey() - a = &Analysis{} - a.GetAnalysisKey() - a = nil - a.GetAnalysisKey() -} - -func TestAnalysis_GetCategory(tt *testing.T) { - var zeroValue string - a := &Analysis{Category: &zeroValue} - a.GetCategory() - a = &Analysis{} - a.GetCategory() - a = nil - a.GetCategory() -} - -func TestAnalysis_GetCommitSHA(tt *testing.T) { - var zeroValue string - a := &Analysis{CommitSHA: &zeroValue} - a.GetCommitSHA() - a = &Analysis{} - a.GetCommitSHA() - a = nil - a.GetCommitSHA() -} - -func TestAnalysis_GetCreatedAt(tt *testing.T) { - var zeroValue Timestamp - a := &Analysis{CreatedAt: &zeroValue} - a.GetCreatedAt() - a = &Analysis{} - a.GetCreatedAt() - a = nil - a.GetCreatedAt() -} - -func TestAnalysis_GetDeletable(tt *testing.T) { - var zeroValue bool - a := &Analysis{Deletable: &zeroValue} - a.GetDeletable() - a = &Analysis{} - a.GetDeletable() - a = nil - a.GetDeletable() -} - -func TestAnalysis_GetEnvironment(tt *testing.T) { - var zeroValue string - a := &Analysis{Environment: &zeroValue} - a.GetEnvironment() - a = &Analysis{} - a.GetEnvironment() - a = nil - a.GetEnvironment() -} - -func TestAnalysis_GetError(tt *testing.T) { - var zeroValue string - a := &Analysis{Error: &zeroValue} - a.GetError() - a = &Analysis{} - a.GetError() - a = nil - a.GetError() -} - -func TestAnalysis_GetID(tt *testing.T) { - var zeroValue int64 - a := &Analysis{ID: &zeroValue} - a.GetID() - a = &Analysis{} - a.GetID() - a = nil - a.GetID() -} - -func TestAnalysis_GetRef(tt *testing.T) { - var zeroValue string - a := &Analysis{Ref: &zeroValue} - a.GetRef() - a = &Analysis{} - a.GetRef() - a = nil - a.GetRef() -} - -func TestAnalysis_GetResultsCount(tt *testing.T) { - var zeroValue int - a := &Analysis{ResultsCount: &zeroValue} - a.GetResultsCount() - a = &Analysis{} - a.GetResultsCount() - a = nil - a.GetResultsCount() -} - -func TestAnalysis_GetRulesCount(tt *testing.T) { - var zeroValue int - a := &Analysis{RulesCount: &zeroValue} - a.GetRulesCount() - a = &Analysis{} - a.GetRulesCount() - a = nil - a.GetRulesCount() -} - -func TestAnalysis_GetSarifID(tt *testing.T) { - var zeroValue string - a := &Analysis{SarifID: &zeroValue} - a.GetSarifID() - a = &Analysis{} - a.GetSarifID() - a = nil - a.GetSarifID() -} - -func TestAnalysis_GetTool(tt *testing.T) { - a := &Analysis{} - a.GetTool() - a = nil - a.GetTool() -} - -func TestAnalysis_GetURL(tt *testing.T) { - var zeroValue string - a := &Analysis{URL: &zeroValue} - a.GetURL() - a = &Analysis{} - a.GetURL() - a = nil - a.GetURL() -} - -func TestAnalysis_GetWarning(tt *testing.T) { - var zeroValue string - a := &Analysis{Warning: &zeroValue} - a.GetWarning() - a = &Analysis{} - a.GetWarning() - a = nil - a.GetWarning() -} - func TestAPIMeta_GetVerifiablePasswordAuthentication(tt *testing.T) { var zeroValue bool a := &APIMeta{VerifiablePasswordAuthentication: &zeroValue} @@ -17956,6 +17809,153 @@ func TestSarifID_GetURL(tt *testing.T) { s.GetURL() } +func TestScanningAnalysis_GetAnalysisKey(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{AnalysisKey: &zeroValue} + s.GetAnalysisKey() + s = &ScanningAnalysis{} + s.GetAnalysisKey() + s = nil + s.GetAnalysisKey() +} + +func TestScanningAnalysis_GetCategory(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{Category: &zeroValue} + s.GetCategory() + s = &ScanningAnalysis{} + s.GetCategory() + s = nil + s.GetCategory() +} + +func TestScanningAnalysis_GetCommitSHA(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{CommitSHA: &zeroValue} + s.GetCommitSHA() + s = &ScanningAnalysis{} + s.GetCommitSHA() + s = nil + s.GetCommitSHA() +} + +func TestScanningAnalysis_GetCreatedAt(tt *testing.T) { + var zeroValue Timestamp + s := &ScanningAnalysis{CreatedAt: &zeroValue} + s.GetCreatedAt() + s = &ScanningAnalysis{} + s.GetCreatedAt() + s = nil + s.GetCreatedAt() +} + +func TestScanningAnalysis_GetDeletable(tt *testing.T) { + var zeroValue bool + s := &ScanningAnalysis{Deletable: &zeroValue} + s.GetDeletable() + s = &ScanningAnalysis{} + s.GetDeletable() + s = nil + s.GetDeletable() +} + +func TestScanningAnalysis_GetEnvironment(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{Environment: &zeroValue} + s.GetEnvironment() + s = &ScanningAnalysis{} + s.GetEnvironment() + s = nil + s.GetEnvironment() +} + +func TestScanningAnalysis_GetError(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{Error: &zeroValue} + s.GetError() + s = &ScanningAnalysis{} + s.GetError() + s = nil + s.GetError() +} + +func TestScanningAnalysis_GetID(tt *testing.T) { + var zeroValue int64 + s := &ScanningAnalysis{ID: &zeroValue} + s.GetID() + s = &ScanningAnalysis{} + s.GetID() + s = nil + s.GetID() +} + +func TestScanningAnalysis_GetRef(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{Ref: &zeroValue} + s.GetRef() + s = &ScanningAnalysis{} + s.GetRef() + s = nil + s.GetRef() +} + +func TestScanningAnalysis_GetResultsCount(tt *testing.T) { + var zeroValue int + s := &ScanningAnalysis{ResultsCount: &zeroValue} + s.GetResultsCount() + s = &ScanningAnalysis{} + s.GetResultsCount() + s = nil + s.GetResultsCount() +} + +func TestScanningAnalysis_GetRulesCount(tt *testing.T) { + var zeroValue int + s := &ScanningAnalysis{RulesCount: &zeroValue} + s.GetRulesCount() + s = &ScanningAnalysis{} + s.GetRulesCount() + s = nil + s.GetRulesCount() +} + +func TestScanningAnalysis_GetSarifID(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{SarifID: &zeroValue} + s.GetSarifID() + s = &ScanningAnalysis{} + s.GetSarifID() + s = nil + s.GetSarifID() +} + +func TestScanningAnalysis_GetTool(tt *testing.T) { + s := &ScanningAnalysis{} + s.GetTool() + s = nil + s.GetTool() +} + +func TestScanningAnalysis_GetURL(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{URL: &zeroValue} + s.GetURL() + s = &ScanningAnalysis{} + s.GetURL() + s = nil + s.GetURL() +} + +func TestScanningAnalysis_GetWarning(tt *testing.T) { + var zeroValue string + s := &ScanningAnalysis{Warning: &zeroValue} + s.GetWarning() + s = &ScanningAnalysis{} + s.GetWarning() + s = nil + s.GetWarning() +} + func TestSCIMUserAttributes_GetActive(tt *testing.T) { var zeroValue bool s := &SCIMUserAttributes{Active: &zeroValue}