From bad4743a8f59b6b2085598e855f160957b157b8f Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:46:43 -0400 Subject: [PATCH 1/2] Fix SecretScanning API by switching arguments from url to json Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/secret_scanning.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/secret_scanning.go b/github/secret_scanning.go index bea3f0e701..ef82f58b1a 100644 --- a/github/secret_scanning.go +++ b/github/secret_scanning.go @@ -82,14 +82,14 @@ type SecretScanningAlertListOptions struct { type SecretScanningAlertUpdateOptions struct { // Required. Sets the state of the secret scanning alert. Can be either open or resolved. // You must provide resolution when you set the state to resolved. - State *string `url:"state,omitempty"` + State *string `json:"state,omitempty"` // A comma-separated list of secret types to return. By default all secret types are returned. - SecretType *string `url:"secret_type,omitempty"` + SecretType *string `json:"secret_type,omitempty"` // Required when the state is resolved. The reason for resolving the alert. Can be one of false_positive, // wont_fix, revoked, or used_in_tests. - Resolution *string `url:"resolution,omitempty"` + Resolution *string `json:"resolution,omitempty"` } // Lists secret scanning alerts for eligible repositories in an enterprise, from newest to oldest. From 9a30ff0a856bfa8403828983c00f820b97eb562c Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:53:40 -0400 Subject: [PATCH 2/2] Fix API endpoint by reading the docs Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/github-accessors.go | 16 ---------------- github/github-accessors_test.go | 20 -------------------- github/secret_scanning.go | 14 ++++++-------- github/secret_scanning_test.go | 4 ++-- 4 files changed, 8 insertions(+), 46 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index e7cfa86f89..083d613914 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -20958,22 +20958,6 @@ func (s *SecretScanningAlertUpdateOptions) GetResolution() string { return *s.Resolution } -// GetSecretType returns the SecretType field if it's non-nil, zero value otherwise. -func (s *SecretScanningAlertUpdateOptions) GetSecretType() string { - if s == nil || s.SecretType == nil { - return "" - } - return *s.SecretType -} - -// GetState returns the State field if it's non-nil, zero value otherwise. -func (s *SecretScanningAlertUpdateOptions) GetState() string { - if s == nil || s.State == nil { - return "" - } - return *s.State -} - // GetStatus returns the Status field if it's non-nil, zero value otherwise. func (s *SecretScanningPushProtection) GetStatus() string { if s == nil || s.Status == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index e2918beaff..90d15369d0 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -24440,26 +24440,6 @@ func TestSecretScanningAlertUpdateOptions_GetResolution(tt *testing.T) { s.GetResolution() } -func TestSecretScanningAlertUpdateOptions_GetSecretType(tt *testing.T) { - var zeroValue string - s := &SecretScanningAlertUpdateOptions{SecretType: &zeroValue} - s.GetSecretType() - s = &SecretScanningAlertUpdateOptions{} - s.GetSecretType() - s = nil - s.GetSecretType() -} - -func TestSecretScanningAlertUpdateOptions_GetState(tt *testing.T) { - var zeroValue string - s := &SecretScanningAlertUpdateOptions{State: &zeroValue} - s.GetState() - s = &SecretScanningAlertUpdateOptions{} - s.GetState() - s = nil - s.GetState() -} - func TestSecretScanningPushProtection_GetStatus(tt *testing.T) { var zeroValue string s := &SecretScanningPushProtection{Status: &zeroValue} diff --git a/github/secret_scanning.go b/github/secret_scanning.go index ef82f58b1a..30d3da8ebf 100644 --- a/github/secret_scanning.go +++ b/github/secret_scanning.go @@ -80,15 +80,13 @@ type SecretScanningAlertListOptions struct { // SecretScanningAlertUpdateOptions specifies optional parameters to the SecretScanningService.UpdateAlert method. type SecretScanningAlertUpdateOptions struct { - // Required. Sets the state of the secret scanning alert. Can be either open or resolved. - // You must provide resolution when you set the state to resolved. - State *string `json:"state,omitempty"` + // State is required and sets the state of the secret scanning alert. + // Can be either "open" or "resolved". + // You must provide resolution when you set the state to "resolved". + State string `json:"state"` - // A comma-separated list of secret types to return. By default all secret types are returned. - SecretType *string `json:"secret_type,omitempty"` - - // Required when the state is resolved. The reason for resolving the alert. Can be one of false_positive, - // wont_fix, revoked, or used_in_tests. + // Required when the state is "resolved" and represents the reason for resolving the alert. + // Can be one of: "false_positive", "wont_fix", "revoked", or "used_in_tests". Resolution *string `json:"resolution,omitempty"` } diff --git a/github/secret_scanning_test.go b/github/secret_scanning_test.go index 2ca439aa47..7898d29a38 100644 --- a/github/secret_scanning_test.go +++ b/github/secret_scanning_test.go @@ -359,7 +359,7 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { v := new(SecretScanningAlertUpdateOptions) assertNilError(t, json.NewDecoder(r.Body).Decode(v)) - want := &SecretScanningAlertUpdateOptions{State: String("resolved"), Resolution: String("used_in_tests")} + want := &SecretScanningAlertUpdateOptions{State: "resolved", Resolution: String("used_in_tests")} if !cmp.Equal(v, want) { t.Errorf("Request body = %+v, want %+v", v, want) @@ -381,7 +381,7 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) { }) ctx := context.Background() - opts := &SecretScanningAlertUpdateOptions{State: String("resolved"), Resolution: String("used_in_tests")} + opts := &SecretScanningAlertUpdateOptions{State: "resolved", Resolution: String("used_in_tests")} alert, _, err := client.SecretScanning.UpdateAlert(ctx, "o", "r", 1, opts) if err != nil {