From b02bb75f811c9b236c846b64af235809617bc5a2 Mon Sep 17 00:00:00 2001 From: Aurimas Salamachinas Date: Thu, 20 Jul 2023 15:11:24 +0300 Subject: [PATCH] Add secret type display to secret scanning alert (#2834) --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/secret_scanning.go | 25 +++++++++++++------------ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index cff3c9c1b4e..35e61043ab8 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -19846,6 +19846,14 @@ func (s *SecretScanningAlert) GetSecretType() string { return *s.SecretType } +// GetSecretTypeDisplayName returns the SecretTypeDisplayName field if it's non-nil, zero value otherwise. +func (s *SecretScanningAlert) GetSecretTypeDisplayName() string { + if s == nil || s.SecretTypeDisplayName == nil { + return "" + } + return *s.SecretTypeDisplayName +} + // GetState returns the State field if it's non-nil, zero value otherwise. func (s *SecretScanningAlert) GetState() string { if s == nil || s.State == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 1ea06998a2e..29d1fd4f1a5 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -23152,6 +23152,16 @@ func TestSecretScanningAlert_GetSecretType(tt *testing.T) { s.GetSecretType() } +func TestSecretScanningAlert_GetSecretTypeDisplayName(tt *testing.T) { + var zeroValue string + s := &SecretScanningAlert{SecretTypeDisplayName: &zeroValue} + s.GetSecretTypeDisplayName() + s = &SecretScanningAlert{} + s.GetSecretTypeDisplayName() + s = nil + s.GetSecretTypeDisplayName() +} + func TestSecretScanningAlert_GetState(tt *testing.T) { var zeroValue string s := &SecretScanningAlert{State: &zeroValue} diff --git a/github/secret_scanning.go b/github/secret_scanning.go index 36ad555377e..b8295cbf791 100644 --- a/github/secret_scanning.go +++ b/github/secret_scanning.go @@ -16,18 +16,19 @@ type SecretScanningService service // SecretScanningAlert represents a GitHub secret scanning alert. type SecretScanningAlert struct { - Number *int `json:"number,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - LocationsURL *string `json:"locations_url,omitempty"` - State *string `json:"state,omitempty"` - Resolution *string `json:"resolution,omitempty"` - ResolvedAt *Timestamp `json:"resolved_at,omitempty"` - ResolvedBy *User `json:"resolved_by,omitempty"` - SecretType *string `json:"secret_type,omitempty"` - Secret *string `json:"secret,omitempty"` - Repository *Repository `json:"repository,omitempty"` + Number *int `json:"number,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + LocationsURL *string `json:"locations_url,omitempty"` + State *string `json:"state,omitempty"` + Resolution *string `json:"resolution,omitempty"` + ResolvedAt *Timestamp `json:"resolved_at,omitempty"` + ResolvedBy *User `json:"resolved_by,omitempty"` + SecretType *string `json:"secret_type,omitempty"` + SecretTypeDisplayName *string `json:"secret_type_display_name,omitempty"` + Secret *string `json:"secret,omitempty"` + Repository *Repository `json:"repository,omitempty"` } // SecretScanningAlertLocation represents the location for a secret scanning alert.