diff --git a/.golangci.yml b/.golangci.yml index 11ee2ad7a13..f69a2e6e3b5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -259,7 +259,6 @@ linters: - RequiredStatusChecksRequest - ReviewCustomDeploymentProtectionRuleRequest - SCIMUserAttributes - - SarifAnalysis - SecretScanningAlertUpdateOptions - SecretScanningPatternConfigsUpdateOptions - SourceImportAuthor diff --git a/github/code_scanning.go b/github/code_scanning.go index 0b4e4c1c7b5..8382708e71c 100644 --- a/github/code_scanning.go +++ b/github/code_scanning.go @@ -209,12 +209,13 @@ type ScanningAnalysis struct { // // GitHub API docs: https://docs.github.com/rest/code-scanning?apiVersion=2022-11-28 type SarifAnalysis struct { - CommitSHA *string `json:"commit_sha,omitempty"` - Ref *string `json:"ref,omitempty"` - Sarif *string `json:"sarif,omitempty"` + CommitSHA string `json:"commit_sha"` + Ref string `json:"ref"` + Sarif string `json:"sarif"` CheckoutURI *string `json:"checkout_uri,omitempty"` StartedAt *Timestamp `json:"started_at,omitempty"` ToolName *string `json:"tool_name,omitempty"` + Validate *bool `json:"validate,omitempty"` } // CodeScanningAlertState specifies the state of a code scanning alert. @@ -392,7 +393,7 @@ func (s *CodeScanningService) ListAlertInstances(ctx context.Context, owner, rep // GitHub API docs: https://docs.github.com/rest/code-scanning/code-scanning?apiVersion=2022-11-28#upload-an-analysis-as-sarif-data // //meta:operation POST /repos/{owner}/{repo}/code-scanning/sarifs -func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo string, body *SarifAnalysis) (*SarifID, *Response, error) { +func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo string, body SarifAnalysis) (*SarifID, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/sarifs", owner, repo) req, err := s.client.NewRequest(ctx, "POST", u, body) diff --git a/github/code_scanning_test.go b/github/code_scanning_test.go index 785cec746ba..9746c2ea83b 100644 --- a/github/code_scanning_test.go +++ b/github/code_scanning_test.go @@ -62,7 +62,7 @@ func TestCodeScanningService_UploadSarif(t *testing.T) { URL: Ptr("https://example.com/testurl"), } - sarifAnalysis := &SarifAnalysis{CommitSHA: Ptr("abc"), Ref: Ptr("ref/head/main"), Sarif: Ptr("abc"), CheckoutURI: Ptr("uri"), StartedAt: &referenceTimestamp, ToolName: Ptr("codeql-cli")} + sarifAnalysis := SarifAnalysis{CommitSHA: "abc", Ref: "ref/head/main", Sarif: "abc", CheckoutURI: Ptr("uri"), StartedAt: &referenceTimestamp, ToolName: Ptr("codeql-cli"), Validate: Ptr(true)} mux.HandleFunc("/repos/o/r/code-scanning/sarifs", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") diff --git a/github/github-accessors.go b/github/github-accessors.go index a601eb39122..68baa08e503 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -37526,28 +37526,28 @@ func (s *SarifAnalysis) GetCheckoutURI() string { return *s.CheckoutURI } -// GetCommitSHA returns the CommitSHA field if it's non-nil, zero value otherwise. +// GetCommitSHA returns the CommitSHA field. func (s *SarifAnalysis) GetCommitSHA() string { - if s == nil || s.CommitSHA == nil { + if s == nil { return "" } - return *s.CommitSHA + return s.CommitSHA } -// GetRef returns the Ref field if it's non-nil, zero value otherwise. +// GetRef returns the Ref field. func (s *SarifAnalysis) GetRef() string { - if s == nil || s.Ref == nil { + if s == nil { return "" } - return *s.Ref + return s.Ref } -// GetSarif returns the Sarif field if it's non-nil, zero value otherwise. +// GetSarif returns the Sarif field. func (s *SarifAnalysis) GetSarif() string { - if s == nil || s.Sarif == nil { + if s == nil { return "" } - return *s.Sarif + return s.Sarif } // GetStartedAt returns the StartedAt field if it's non-nil, zero value otherwise. @@ -37566,6 +37566,14 @@ func (s *SarifAnalysis) GetToolName() string { return *s.ToolName } +// GetValidate returns the Validate field if it's non-nil, zero value otherwise. +func (s *SarifAnalysis) GetValidate() bool { + if s == nil || s.Validate == nil { + return false + } + return *s.Validate +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (s *SarifID) GetID() string { if s == nil || s.ID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 17967614c31..825454471bf 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -47060,10 +47060,7 @@ func TestSarifAnalysis_GetCheckoutURI(tt *testing.T) { func TestSarifAnalysis_GetCommitSHA(tt *testing.T) { tt.Parallel() - var zeroValue string - s := &SarifAnalysis{CommitSHA: &zeroValue} - s.GetCommitSHA() - s = &SarifAnalysis{} + s := &SarifAnalysis{} s.GetCommitSHA() s = nil s.GetCommitSHA() @@ -47071,10 +47068,7 @@ func TestSarifAnalysis_GetCommitSHA(tt *testing.T) { func TestSarifAnalysis_GetRef(tt *testing.T) { tt.Parallel() - var zeroValue string - s := &SarifAnalysis{Ref: &zeroValue} - s.GetRef() - s = &SarifAnalysis{} + s := &SarifAnalysis{} s.GetRef() s = nil s.GetRef() @@ -47082,10 +47076,7 @@ func TestSarifAnalysis_GetRef(tt *testing.T) { func TestSarifAnalysis_GetSarif(tt *testing.T) { tt.Parallel() - var zeroValue string - s := &SarifAnalysis{Sarif: &zeroValue} - s.GetSarif() - s = &SarifAnalysis{} + s := &SarifAnalysis{} s.GetSarif() s = nil s.GetSarif() @@ -47113,6 +47104,17 @@ func TestSarifAnalysis_GetToolName(tt *testing.T) { s.GetToolName() } +func TestSarifAnalysis_GetValidate(tt *testing.T) { + tt.Parallel() + var zeroValue bool + s := &SarifAnalysis{Validate: &zeroValue} + s.GetValidate() + s = &SarifAnalysis{} + s.GetValidate() + s = nil + s.GetValidate() +} + func TestSarifID_GetID(tt *testing.T) { tt.Parallel() var zeroValue string