From 6b483ab22474e15aaab6cf3971fce92172c7af04 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Wed, 21 Jul 2021 01:27:03 -0400 Subject: [PATCH 1/4] fix derecated field --- github/code-scanning.go | 2 +- github/github-accessors.go | 16 ++++++++-------- github/github-accessors_test.go | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index 640ec899f54..cf1c6ecec9e 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -72,7 +72,7 @@ type Alert struct { Rule *Rule `json:"rule,omitempty"` Tool *Tool `json:"tool,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` - Open *bool `json:"open,omitempty"` + State *string `json:"state,omitempty"` ClosedBy *User `json:"closed_by,omitempty"` ClosedAt *Timestamp `json:"closed_at,omitempty"` URL *string `json:"url,omitempty"` diff --git a/github/github-accessors.go b/github/github-accessors.go index 2d51bfdfb6e..c75deff7016 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -220,14 +220,6 @@ func (a *Alert) GetMostRecentInstance() *MostRecentInstance { return a.MostRecentInstance } -// GetOpen returns the Open field if it's non-nil, zero value otherwise. -func (a *Alert) GetOpen() bool { - if a == nil || a.Open == nil { - return false - } - return *a.Open -} - // GetRule returns the Rule field. func (a *Alert) GetRule() *Rule { if a == nil { @@ -260,6 +252,14 @@ func (a *Alert) GetRuleSeverity() string { return *a.RuleSeverity } +// GetState returns the State field if it's non-nil, zero value otherwise. +func (a *Alert) GetState() string { + if a == nil || a.State == nil { + return "" + } + return *a.State +} + // GetTool returns the Tool field. func (a *Alert) GetTool() *Tool { if a == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 86bb6c3ec67..61f36ce2a28 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -234,16 +234,6 @@ func TestAlert_GetMostRecentInstance(tt *testing.T) { a.GetMostRecentInstance() } -func TestAlert_GetOpen(tt *testing.T) { - var zeroValue bool - a := &Alert{Open: &zeroValue} - a.GetOpen() - a = &Alert{} - a.GetOpen() - a = nil - a.GetOpen() -} - func TestAlert_GetRule(tt *testing.T) { a := &Alert{} a.GetRule() @@ -281,6 +271,16 @@ func TestAlert_GetRuleSeverity(tt *testing.T) { a.GetRuleSeverity() } +func TestAlert_GetState(tt *testing.T) { + var zeroValue string + a := &Alert{State: &zeroValue} + a.GetState() + a = &Alert{} + a.GetState() + a = nil + a.GetState() +} + func TestAlert_GetTool(tt *testing.T) { a := &Alert{} a.GetTool() From db7f32553c1b35c27aa6666f9567b7f96c84fa02 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Wed, 21 Jul 2021 01:35:29 -0400 Subject: [PATCH 2/4] fixing test case --- github/code-scanning_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 7403582fc58..6ef8d84aef0 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -96,7 +96,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { ] }, "created_at":"2020-05-06T12:00:00Z", - "open":true, + "state":"open", "closed_by":null, "closed_at":null, "url":"https://api.github.com/repos/o/r/code-scanning/alerts/25", @@ -138,7 +138,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { ] }, "created_at":"2020-05-06T12:00:00Z", - "open":true, + "state":"open", "closed_by":null, "closed_at":null, "url":"https://api.github.com/repos/o/r/code-scanning/alerts/88", @@ -169,7 +169,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { Help: String("Expression has no effect"), }, CreatedAt: &date, - Open: Bool(true), + State: String("open"), ClosedBy: nil, ClosedAt: nil, URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/25"), @@ -205,7 +205,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { Help: String("Expression has no effect"), }, CreatedAt: &date, - Open: Bool(true), + State: String("open"), ClosedBy: nil, ClosedAt: nil, URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/88"), @@ -288,7 +288,7 @@ func TestActionsService_GetAlert(t *testing.T) { ] }, "created_at":"2019-01-02T15:04:05Z", - "open":true, + "state":"open", "closed_by":null, "closed_at":null, "url":"https://api.github.com/repos/o/r/code-scanning/alerts/88", @@ -316,7 +316,7 @@ func TestActionsService_GetAlert(t *testing.T) { Help: String("Expression has no effect"), }, CreatedAt: &date, - Open: Bool(true), + State: String("open"), ClosedBy: nil, ClosedAt: nil, URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/88"), @@ -370,7 +370,7 @@ func TestAlert_Marshal(t *testing.T) { Version: String("v"), }, CreatedAt: &Timestamp{referenceTime}, - Open: Bool(false), + State: String("fixed"), ClosedBy: &User{ Login: String("l"), ID: Int64(1), @@ -395,7 +395,7 @@ func TestAlert_Marshal(t *testing.T) { "version": "v" }, "created_at": ` + referenceTimeStr + `, - "open": false, + "state": "fixed", "closed_by": { "login": "l", "id": 1, From c911339855dc93e6fce1fae6c72a4f39de5d8ba1 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Fri, 30 Jul 2021 10:57:25 -0400 Subject: [PATCH 3/4] Adding SeverityLevel --- github/code-scanning.go | 1 + github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/github/code-scanning.go b/github/code-scanning.go index cf1c6ecec9e..9c888ce19bc 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -24,6 +24,7 @@ type Rule struct { Severity *string `json:"severity,omitempty"` Description *string `json:"description,omitempty"` Name *string `json:"name,omitempty"` + SeverityLevel *string `json:"security_severity_level,omitempty"` FullDescription *string `json:"full_description,omitempty"` Tags []string `json:"tags,omitempty"` Help *string `json:"help,omitempty"` diff --git a/github/github-accessors.go b/github/github-accessors.go index c75deff7016..61a5a3b4e4f 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -14364,6 +14364,14 @@ func (r *Rule) GetSeverity() string { return *r.Severity } +// GetSeverityLevel returns the SeverityLevel field if it's non-nil, zero value otherwise. +func (r *Rule) GetSeverityLevel() string { + if r == nil || r.SeverityLevel == nil { + return "" + } + return *r.SeverityLevel +} + // GetBusy returns the Busy field if it's non-nil, zero value otherwise. func (r *Runner) GetBusy() bool { if r == nil || r.Busy == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 61f36ce2a28..862701ebe50 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -16786,6 +16786,16 @@ func TestRule_GetSeverity(tt *testing.T) { r.GetSeverity() } +func TestRule_GetSeverityLevel(tt *testing.T) { + var zeroValue string + r := &Rule{SeverityLevel: &zeroValue} + r.GetSeverityLevel() + r = &Rule{} + r.GetSeverityLevel() + r = nil + r.GetSeverityLevel() +} + func TestRunner_GetBusy(tt *testing.T) { var zeroValue bool r := &Runner{Busy: &zeroValue} From 4afeb34a4f59614b949442b3f7a99240e8026401 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Fri, 30 Jul 2021 13:55:29 -0400 Subject: [PATCH 4/4] renaming struct field --- github/code-scanning.go | 16 ++++++++-------- github/github-accessors.go | 16 ++++++++-------- github/github-accessors_test.go | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index 9c888ce19bc..dbaeb346b3f 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -20,14 +20,14 @@ type CodeScanningService service // Rule represents the complete details of GitHub Code Scanning alert type. type Rule struct { - ID *string `json:"id,omitempty"` - Severity *string `json:"severity,omitempty"` - Description *string `json:"description,omitempty"` - Name *string `json:"name,omitempty"` - SeverityLevel *string `json:"security_severity_level,omitempty"` - FullDescription *string `json:"full_description,omitempty"` - Tags []string `json:"tags,omitempty"` - Help *string `json:"help,omitempty"` + ID *string `json:"id,omitempty"` + Severity *string `json:"severity,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + SecuritySeverityLevel *string `json:"security_severity_level,omitempty"` + FullDescription *string `json:"full_description,omitempty"` + Tags []string `json:"tags,omitempty"` + Help *string `json:"help,omitempty"` } // Location represents the exact location of the GitHub Code Scanning Alert in the scanned project. diff --git a/github/github-accessors.go b/github/github-accessors.go index 61a5a3b4e4f..5e106397889 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -14356,20 +14356,20 @@ func (r *Rule) GetName() string { return *r.Name } -// GetSeverity returns the Severity field if it's non-nil, zero value otherwise. -func (r *Rule) GetSeverity() string { - if r == nil || r.Severity == nil { +// GetSecuritySeverityLevel returns the SecuritySeverityLevel field if it's non-nil, zero value otherwise. +func (r *Rule) GetSecuritySeverityLevel() string { + if r == nil || r.SecuritySeverityLevel == nil { return "" } - return *r.Severity + return *r.SecuritySeverityLevel } -// GetSeverityLevel returns the SeverityLevel field if it's non-nil, zero value otherwise. -func (r *Rule) GetSeverityLevel() string { - if r == nil || r.SeverityLevel == nil { +// GetSeverity returns the Severity field if it's non-nil, zero value otherwise. +func (r *Rule) GetSeverity() string { + if r == nil || r.Severity == nil { return "" } - return *r.SeverityLevel + return *r.Severity } // GetBusy returns the Busy field if it's non-nil, zero value otherwise. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 862701ebe50..ecc078a415f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -16776,24 +16776,24 @@ func TestRule_GetName(tt *testing.T) { r.GetName() } -func TestRule_GetSeverity(tt *testing.T) { +func TestRule_GetSecuritySeverityLevel(tt *testing.T) { var zeroValue string - r := &Rule{Severity: &zeroValue} - r.GetSeverity() + r := &Rule{SecuritySeverityLevel: &zeroValue} + r.GetSecuritySeverityLevel() r = &Rule{} - r.GetSeverity() + r.GetSecuritySeverityLevel() r = nil - r.GetSeverity() + r.GetSecuritySeverityLevel() } -func TestRule_GetSeverityLevel(tt *testing.T) { +func TestRule_GetSeverity(tt *testing.T) { var zeroValue string - r := &Rule{SeverityLevel: &zeroValue} - r.GetSeverityLevel() + r := &Rule{Severity: &zeroValue} + r.GetSeverity() r = &Rule{} - r.GetSeverityLevel() + r.GetSeverity() r = nil - r.GetSeverityLevel() + r.GetSeverity() } func TestRunner_GetBusy(tt *testing.T) {