From 3f8a64020bf6aeff2f5cc8be7776fee7996947fd Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Mon, 21 Jun 2021 18:19:01 -0400 Subject: [PATCH 01/29] Fixes Code Scanning Alert tool field --- github/code-scanning.go | 8 +++++++- github/code-scanning_test.go | 24 ++++++++++++++++------ github/github-accessors.go | 34 +++++++++++++++++++++++++++----- github/github-accessors_test.go | 35 +++++++++++++++++++++++++++++---- 4 files changed, 85 insertions(+), 16 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index 9eb711cf437..a43b1979a46 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -18,11 +18,17 @@ import ( // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/ type CodeScanningService service +type Tool struct { + Name *string `json:"name,omitempty"` + GUID *string `json:"guid,omitempty"` + Version *string `json:"version,omitempty"` +} + type Alert struct { RuleID *string `json:"rule_id,omitempty"` RuleSeverity *string `json:"rule_severity,omitempty"` RuleDescription *string `json:"rule_description,omitempty"` - Tool *string `json:"tool,omitempty"` + Tool *Tool `json:"tool,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` Open *bool `json:"open,omitempty"` ClosedBy *User `json:"closed_by,omitempty"` diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index be9fb3de4c3..2e89856535e 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -64,7 +64,11 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { "rule_id":"js/trivial-conditional", "rule_severity":"warning", "rule_description":"Useless conditional", - "tool":"CodeQL", + "tool": { + "name": "CodeQL", + "guid": null, + "version": "1.4.0" + }, "created_at":"2020-05-06T12:00:00Z", "open":true, "closed_by":null, @@ -76,7 +80,11 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { "rule_id":"js/useless-expression", "rule_severity":"warning", "rule_description":"Expression has no effect", - "tool":"CodeQL", + "tool": { + "name": "CodeQL", + "guid": null, + "version": "1.4.0" + }, "created_at":"2020-05-06T12:00:00Z", "open":true, "closed_by":null, @@ -99,7 +107,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { RuleID: String("js/trivial-conditional"), RuleSeverity: String("warning"), RuleDescription: String("Useless conditional"), - Tool: String("CodeQL"), + Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, CreatedAt: &date, Open: Bool(true), ClosedBy: nil, @@ -111,7 +119,7 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { RuleID: String("js/useless-expression"), RuleSeverity: String("warning"), RuleDescription: String("Expression has no effect"), - Tool: String("CodeQL"), + Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, CreatedAt: &date, Open: Bool(true), ClosedBy: nil, @@ -148,7 +156,11 @@ func TestActionsService_GetAlert(t *testing.T) { fmt.Fprint(w, `{"rule_id":"js/useless-expression", "rule_severity":"warning", "rule_description":"Expression has no effect", - "tool":"CodeQL", + "tool": { + "name": "CodeQL", + "guid": null, + "version": "1.4.0" + }, "created_at":"2019-01-02T15:04:05Z", "open":true, "closed_by":null, @@ -168,7 +180,7 @@ func TestActionsService_GetAlert(t *testing.T) { RuleID: String("js/useless-expression"), RuleSeverity: String("warning"), RuleDescription: String("Expression has no effect"), - Tool: String("CodeQL"), + Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, CreatedAt: &date, Open: Bool(true), ClosedBy: nil, diff --git a/github/github-accessors.go b/github/github-accessors.go index 1c17384eac0..5e3b8ac1711 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -212,12 +212,12 @@ func (a *Alert) GetRuleSeverity() string { return *a.RuleSeverity } -// GetTool returns the Tool field if it's non-nil, zero value otherwise. -func (a *Alert) GetTool() string { - if a == nil || a.Tool == nil { - return "" +// GetTool returns the Tool field. +func (a *Alert) GetTool() *Tool { + if a == nil { + return nil } - return *a.Tool + return a.Tool } // GetURL returns the URL field if it's non-nil, zero value otherwise. @@ -14932,6 +14932,30 @@ func (t *Timeline) GetURL() string { return *t.URL } +// GetGUID returns the GUID field if it's non-nil, zero value otherwise. +func (t *Tool) GetGUID() string { + if t == nil || t.GUID == nil { + return "" + } + return *t.GUID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (t *Tool) GetName() string { + if t == nil || t.Name == nil { + return "" + } + return *t.Name +} + +// GetVersion returns the Version field if it's non-nil, zero value otherwise. +func (t *Tool) GetVersion() string { + if t == nil || t.Version == nil { + return "" + } + return *t.Version +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (t *TopicResult) GetCreatedAt() Timestamp { if t == nil || t.CreatedAt == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 750c6a40f8f..50a3a327a43 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -231,10 +231,7 @@ func TestAlert_GetRuleSeverity(tt *testing.T) { } func TestAlert_GetTool(tt *testing.T) { - var zeroValue string - a := &Alert{Tool: &zeroValue} - a.GetTool() - a = &Alert{} + a := &Alert{} a.GetTool() a = nil a.GetTool() @@ -17481,6 +17478,36 @@ func TestTimeline_GetURL(tt *testing.T) { t.GetURL() } +func TestTool_GetGUID(tt *testing.T) { + var zeroValue string + t := &Tool{GUID: &zeroValue} + t.GetGUID() + t = &Tool{} + t.GetGUID() + t = nil + t.GetGUID() +} + +func TestTool_GetName(tt *testing.T) { + var zeroValue string + t := &Tool{Name: &zeroValue} + t.GetName() + t = &Tool{} + t.GetName() + t = nil + t.GetName() +} + +func TestTool_GetVersion(tt *testing.T) { + var zeroValue string + t := &Tool{Version: &zeroValue} + t.GetVersion() + t = &Tool{} + t.GetVersion() + t = nil + t.GetVersion() +} + func TestTopicResult_GetCreatedAt(tt *testing.T) { var zeroValue Timestamp t := &TopicResult{CreatedAt: &zeroValue} From 2e9db798f1ea2b50f1cce2f0940057c94a491b69 Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Mon, 21 Jun 2021 19:12:18 -0400 Subject: [PATCH 02/29] Update github/code-scanning.go Co-authored-by: Stephen --- github/code-scanning.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/github/code-scanning.go b/github/code-scanning.go index a43b1979a46..020b0da0d5c 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -24,6 +24,9 @@ type Tool struct { Version *string `json:"version,omitempty"` } +// Alert represents an individual GitHub Code Scanning Alert on a single repository. +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Alert struct { RuleID *string `json:"rule_id,omitempty"` RuleSeverity *string `json:"rule_severity,omitempty"` From ce450a9aa87decce110d30971ab37adf5b9d139c Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Mon, 21 Jun 2021 19:12:29 -0400 Subject: [PATCH 03/29] Update github/code-scanning.go Co-authored-by: Stephen --- github/code-scanning.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/github/code-scanning.go b/github/code-scanning.go index 020b0da0d5c..8602c446322 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -18,6 +18,9 @@ import ( // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/ type CodeScanningService service +// Tool represents the tool used to generate a GitHub Code Scanning Alert. +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Tool struct { Name *string `json:"name,omitempty"` GUID *string `json:"guid,omitempty"` From be0483609319c97c4d86814ecf6f1188b11d1f1e Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Wed, 7 Jul 2021 18:01:06 -0700 Subject: [PATCH 04/29] add rule struct to alert --- github/code-scanning.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/github/code-scanning.go b/github/code-scanning.go index 8602c446322..3431cbc700e 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -18,6 +18,16 @@ import ( // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/ type CodeScanningService service +type Rule struct { + ID *string `json:"id"` + Severity *string `json:"severity"` + Description *string `json:"description"` + Name *string `json:"name"` + FullDescription *string `json:"full_description"` + Tags *[]string `json:"tags"` + Help *string `json:"help"` +} `json:"rule"` + // Tool represents the tool used to generate a GitHub Code Scanning Alert. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository @@ -34,6 +44,7 @@ type Alert struct { RuleID *string `json:"rule_id,omitempty"` RuleSeverity *string `json:"rule_severity,omitempty"` RuleDescription *string `json:"rule_description,omitempty"` + Rule *Rule `json:"rule,omitempty"` Tool *Tool `json:"tool,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` Open *bool `json:"open,omitempty"` From 294102e7a5c0429273441d7601a57b577ef57d5a Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Thu, 8 Jul 2021 11:07:12 -0700 Subject: [PATCH 05/29] Update code-scanning.go --- 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 3431cbc700e..f2eaaa2fe0c 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -26,7 +26,7 @@ type Rule struct { FullDescription *string `json:"full_description"` Tags *[]string `json:"tags"` Help *string `json:"help"` -} `json:"rule"` +} // Tool represents the tool used to generate a GitHub Code Scanning Alert. // From e1b1cd8cef06d697fa397e9989c12b4f442c020d Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Thu, 8 Jul 2021 11:42:12 -0700 Subject: [PATCH 06/29] Update code-scanning.go --- github/code-scanning.go | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index f2eaaa2fe0c..63c461f9550 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -19,15 +19,38 @@ import ( type CodeScanningService service type Rule struct { - ID *string `json:"id"` - Severity *string `json:"severity"` - Description *string `json:"description"` - Name *string `json:"name"` - FullDescription *string `json:"full_description"` - Tags *[]string `json:"tags"` - Help *string `json:"help"` + ID *string `json:"id,omitempty"` + Severity *string `json:"severity,omitempty"` + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + FullDescription *string `json:"full_description,omitempty"` + Tags *[]string `json:"tags,omitempty"` + Help *string `json:"help,omitempty"` } +type Location struct { + Path *string `json:"path,omitempty"` + StartLine *int `json:"start_line,omitempty"` + EndLine *int `json:"end_line,omitempty"` + StartColumn *int `json:"start_column,omitempty"` + EndColumn *int `json:"end_column,omitempty"` +} + +type Message struct { + Text *string `json:"text,omitempty"` +} + +type MostRecentInstance struct { + Ref *string `json:"ref,omitempty"` + AnalysisKey *string `json:"analysis_key,omitempty"` + Environment *string `json:"environment,omitempty"` + State *string `json:"state,omitempty"` + CommitSha *string `json:"commit_sha,omitempty"` + Message *Message `json:"message,omitempty"` + Location *Location `json:"location,omitempty"` + Classifications *[]string `json:"classifications,omitempty"` +} + // Tool represents the tool used to generate a GitHub Code Scanning Alert. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository @@ -52,6 +75,7 @@ type Alert struct { ClosedAt *Timestamp `json:"closed_at,omitempty"` URL *string `json:"url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` + MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` } // ID returns the ID associated with an alert. It is the number at the end of the security alert's URL. From ef2facd63c7f3608c7af58445fbe67d53ef6544f Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Fri, 16 Jul 2021 16:38:03 -0400 Subject: [PATCH 07/29] adding the generated accessors --- github/github-accessors.go | 184 +++++++++++++++++++++++++++ github/github-accessors_test.go | 218 ++++++++++++++++++++++++++++++++ 2 files changed, 402 insertions(+) diff --git a/github/github-accessors.go b/github/github-accessors.go index 5e3b8ac1711..f2268e924ef 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -180,6 +180,14 @@ func (a *Alert) GetHTMLURL() string { return *a.HTMLURL } +// GetMostRecentInstance returns the MostRecentInstance field. +func (a *Alert) GetMostRecentInstance() *MostRecentInstance { + if a == nil { + return nil + } + 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 { @@ -188,6 +196,14 @@ func (a *Alert) GetOpen() bool { return *a.Open } +// GetRule returns the Rule field. +func (a *Alert) GetRule() *Rule { + if a == nil { + return nil + } + return a.Rule +} + // GetRuleDescription returns the RuleDescription field if it's non-nil, zero value otherwise. func (a *Alert) GetRuleDescription() string { if a == nil || a.RuleDescription == nil { @@ -6812,6 +6828,46 @@ func (l *ListRepositories) GetTotalCount() int { return *l.TotalCount } +// GetEndColumn returns the EndColumn field if it's non-nil, zero value otherwise. +func (l *Location) GetEndColumn() int { + if l == nil || l.EndColumn == nil { + return 0 + } + return *l.EndColumn +} + +// GetEndLine returns the EndLine field if it's non-nil, zero value otherwise. +func (l *Location) GetEndLine() int { + if l == nil || l.EndLine == nil { + return 0 + } + return *l.EndLine +} + +// GetPath returns the Path field if it's non-nil, zero value otherwise. +func (l *Location) GetPath() string { + if l == nil || l.Path == nil { + return "" + } + return *l.Path +} + +// GetStartColumn returns the StartColumn field if it's non-nil, zero value otherwise. +func (l *Location) GetStartColumn() int { + if l == nil || l.StartColumn == nil { + return 0 + } + return *l.StartColumn +} + +// GetStartLine returns the StartLine field if it's non-nil, zero value otherwise. +func (l *Location) GetStartLine() int { + if l == nil || l.StartLine == nil { + return 0 + } + return *l.StartLine +} + // GetEffectiveDate returns the EffectiveDate field if it's non-nil, zero value otherwise. func (m *MarketplacePendingChange) GetEffectiveDate() Timestamp { if m == nil || m.EffectiveDate == nil { @@ -7260,6 +7316,14 @@ func (m *MembershipEvent) GetTeam() *Team { return m.Team } +// GetText returns the Text field if it's non-nil, zero value otherwise. +func (m *Message) GetText() string { + if m == nil || m.Text == nil { + return "" + } + return *m.Text +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (m *MetaEvent) GetAction() string { if m == nil || m.Action == nil { @@ -7588,6 +7652,70 @@ func (m *MilestoneStats) GetTotalMilestones() int { return *m.TotalMilestones } +// GetAnalysisKey returns the AnalysisKey field if it's non-nil, zero value otherwise. +func (m *MostRecentInstance) GetAnalysisKey() string { + if m == nil || m.AnalysisKey == nil { + return "" + } + return *m.AnalysisKey +} + +// GetClassifications returns the Classifications field if it's non-nil, zero value otherwise. +func (m *MostRecentInstance) GetClassifications() []string { + if m == nil || m.Classifications == nil { + return nil + } + return *m.Classifications +} + +// GetCommitSha returns the CommitSha field if it's non-nil, zero value otherwise. +func (m *MostRecentInstance) GetCommitSha() string { + if m == nil || m.CommitSha == nil { + return "" + } + return *m.CommitSha +} + +// GetEnvironment returns the Environment field if it's non-nil, zero value otherwise. +func (m *MostRecentInstance) GetEnvironment() string { + if m == nil || m.Environment == nil { + return "" + } + return *m.Environment +} + +// GetLocation returns the Location field. +func (m *MostRecentInstance) GetLocation() *Location { + if m == nil { + return nil + } + return m.Location +} + +// GetMessage returns the Message field. +func (m *MostRecentInstance) GetMessage() *Message { + if m == nil { + return nil + } + return m.Message +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (m *MostRecentInstance) GetRef() string { + if m == nil || m.Ref == nil { + return "" + } + return *m.Ref +} + +// GetState returns the State field if it's non-nil, zero value otherwise. +func (m *MostRecentInstance) GetState() string { + if m == nil || m.State == nil { + return "" + } + return *m.State +} + // GetBase returns the Base field if it's non-nil, zero value otherwise. func (n *NewPullRequest) GetBase() string { if n == nil || n.Base == nil { @@ -13620,6 +13748,62 @@ func (r *ReviewersRequest) GetNodeID() string { return *r.NodeID } +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (r *Rule) GetDescription() string { + if r == nil || r.Description == nil { + return "" + } + return *r.Description +} + +// GetFullDescription returns the FullDescription field if it's non-nil, zero value otherwise. +func (r *Rule) GetFullDescription() string { + if r == nil || r.FullDescription == nil { + return "" + } + return *r.FullDescription +} + +// GetHelp returns the Help field if it's non-nil, zero value otherwise. +func (r *Rule) GetHelp() string { + if r == nil || r.Help == nil { + return "" + } + return *r.Help +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (r *Rule) GetID() string { + if r == nil || r.ID == nil { + return "" + } + return *r.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (r *Rule) GetName() string { + if r == nil || r.Name == nil { + return "" + } + 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 { + return "" + } + return *r.Severity +} + +// GetTags returns the Tags field if it's non-nil, zero value otherwise. +func (r *Rule) GetTags() []string { + if r == nil || r.Tags == nil { + return nil + } + return *r.Tags +} + // 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 50a3a327a43..0fbd734a0a4 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -190,6 +190,13 @@ func TestAlert_GetHTMLURL(tt *testing.T) { a.GetHTMLURL() } +func TestAlert_GetMostRecentInstance(tt *testing.T) { + a := &Alert{} + a.GetMostRecentInstance() + a = nil + a.GetMostRecentInstance() +} + func TestAlert_GetOpen(tt *testing.T) { var zeroValue bool a := &Alert{Open: &zeroValue} @@ -200,6 +207,13 @@ func TestAlert_GetOpen(tt *testing.T) { a.GetOpen() } +func TestAlert_GetRule(tt *testing.T) { + a := &Alert{} + a.GetRule() + a = nil + a.GetRule() +} + func TestAlert_GetRuleDescription(tt *testing.T) { var zeroValue string a := &Alert{RuleDescription: &zeroValue} @@ -8024,6 +8038,56 @@ func TestListRepositories_GetTotalCount(tt *testing.T) { l.GetTotalCount() } +func TestLocation_GetEndColumn(tt *testing.T) { + var zeroValue int + l := &Location{EndColumn: &zeroValue} + l.GetEndColumn() + l = &Location{} + l.GetEndColumn() + l = nil + l.GetEndColumn() +} + +func TestLocation_GetEndLine(tt *testing.T) { + var zeroValue int + l := &Location{EndLine: &zeroValue} + l.GetEndLine() + l = &Location{} + l.GetEndLine() + l = nil + l.GetEndLine() +} + +func TestLocation_GetPath(tt *testing.T) { + var zeroValue string + l := &Location{Path: &zeroValue} + l.GetPath() + l = &Location{} + l.GetPath() + l = nil + l.GetPath() +} + +func TestLocation_GetStartColumn(tt *testing.T) { + var zeroValue int + l := &Location{StartColumn: &zeroValue} + l.GetStartColumn() + l = &Location{} + l.GetStartColumn() + l = nil + l.GetStartColumn() +} + +func TestLocation_GetStartLine(tt *testing.T) { + var zeroValue int + l := &Location{StartLine: &zeroValue} + l.GetStartLine() + l = &Location{} + l.GetStartLine() + l = nil + l.GetStartLine() +} + func TestMarketplacePendingChange_GetEffectiveDate(tt *testing.T) { var zeroValue Timestamp m := &MarketplacePendingChange{EffectiveDate: &zeroValue} @@ -8527,6 +8591,16 @@ func TestMembershipEvent_GetTeam(tt *testing.T) { m.GetTeam() } +func TestMessage_GetText(tt *testing.T) { + var zeroValue string + m := &Message{Text: &zeroValue} + m.GetText() + m = &Message{} + m.GetText() + m = nil + m.GetText() +} + func TestMetaEvent_GetAction(tt *testing.T) { var zeroValue string m := &MetaEvent{Action: &zeroValue} @@ -8913,6 +8987,80 @@ func TestMilestoneStats_GetTotalMilestones(tt *testing.T) { m.GetTotalMilestones() } +func TestMostRecentInstance_GetAnalysisKey(tt *testing.T) { + var zeroValue string + m := &MostRecentInstance{AnalysisKey: &zeroValue} + m.GetAnalysisKey() + m = &MostRecentInstance{} + m.GetAnalysisKey() + m = nil + m.GetAnalysisKey() +} + +func TestMostRecentInstance_GetClassifications(tt *testing.T) { + var zeroValue []string + m := &MostRecentInstance{Classifications: &zeroValue} + m.GetClassifications() + m = &MostRecentInstance{} + m.GetClassifications() + m = nil + m.GetClassifications() +} + +func TestMostRecentInstance_GetCommitSha(tt *testing.T) { + var zeroValue string + m := &MostRecentInstance{CommitSha: &zeroValue} + m.GetCommitSha() + m = &MostRecentInstance{} + m.GetCommitSha() + m = nil + m.GetCommitSha() +} + +func TestMostRecentInstance_GetEnvironment(tt *testing.T) { + var zeroValue string + m := &MostRecentInstance{Environment: &zeroValue} + m.GetEnvironment() + m = &MostRecentInstance{} + m.GetEnvironment() + m = nil + m.GetEnvironment() +} + +func TestMostRecentInstance_GetLocation(tt *testing.T) { + m := &MostRecentInstance{} + m.GetLocation() + m = nil + m.GetLocation() +} + +func TestMostRecentInstance_GetMessage(tt *testing.T) { + m := &MostRecentInstance{} + m.GetMessage() + m = nil + m.GetMessage() +} + +func TestMostRecentInstance_GetRef(tt *testing.T) { + var zeroValue string + m := &MostRecentInstance{Ref: &zeroValue} + m.GetRef() + m = &MostRecentInstance{} + m.GetRef() + m = nil + m.GetRef() +} + +func TestMostRecentInstance_GetState(tt *testing.T) { + var zeroValue string + m := &MostRecentInstance{State: &zeroValue} + m.GetState() + m = &MostRecentInstance{} + m.GetState() + m = nil + m.GetState() +} + func TestNewPullRequest_GetBase(tt *testing.T) { var zeroValue string n := &NewPullRequest{Base: &zeroValue} @@ -15946,6 +16094,76 @@ func TestReviewersRequest_GetNodeID(tt *testing.T) { r.GetNodeID() } +func TestRule_GetDescription(tt *testing.T) { + var zeroValue string + r := &Rule{Description: &zeroValue} + r.GetDescription() + r = &Rule{} + r.GetDescription() + r = nil + r.GetDescription() +} + +func TestRule_GetFullDescription(tt *testing.T) { + var zeroValue string + r := &Rule{FullDescription: &zeroValue} + r.GetFullDescription() + r = &Rule{} + r.GetFullDescription() + r = nil + r.GetFullDescription() +} + +func TestRule_GetHelp(tt *testing.T) { + var zeroValue string + r := &Rule{Help: &zeroValue} + r.GetHelp() + r = &Rule{} + r.GetHelp() + r = nil + r.GetHelp() +} + +func TestRule_GetID(tt *testing.T) { + var zeroValue string + r := &Rule{ID: &zeroValue} + r.GetID() + r = &Rule{} + r.GetID() + r = nil + r.GetID() +} + +func TestRule_GetName(tt *testing.T) { + var zeroValue string + r := &Rule{Name: &zeroValue} + r.GetName() + r = &Rule{} + r.GetName() + r = nil + r.GetName() +} + +func TestRule_GetSeverity(tt *testing.T) { + var zeroValue string + r := &Rule{Severity: &zeroValue} + r.GetSeverity() + r = &Rule{} + r.GetSeverity() + r = nil + r.GetSeverity() +} + +func TestRule_GetTags(tt *testing.T) { + var zeroValue []string + r := &Rule{Tags: &zeroValue} + r.GetTags() + r = &Rule{} + r.GetTags() + r = nil + r.GetTags() +} + func TestRunner_GetBusy(tt *testing.T) { var zeroValue bool r := &Runner{Busy: &zeroValue} From 7f36db512045ae38fcf819a29d861b2bd3a8a907 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Fri, 16 Jul 2021 20:56:53 -0400 Subject: [PATCH 08/29] add go fmt --- github/code-scanning.go | 54 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index 565513015f1..7c0b44c0f06 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -19,13 +19,13 @@ import ( type CodeScanningService service type Rule struct { - ID *string `json:"id,omitempty"` - Severity *string `json:"severity,omitempty"` - Description *string `json:"description,omitempty"` - Name *string `json:"name,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"` + FullDescription *string `json:"full_description,omitempty"` + Tags []string `json:"tags,omitempty"` + Help *string `json:"help,omitempty"` } type Location struct { @@ -41,15 +41,15 @@ type Message struct { } type MostRecentInstance struct { - Ref *string `json:"ref,omitempty"` - AnalysisKey *string `json:"analysis_key,omitempty"` - Environment *string `json:"environment,omitempty"` - State *string `json:"state,omitempty"` - CommitSha *string `json:"commit_sha,omitempty"` - Message *Message `json:"message,omitempty"` - Location *Location `json:"location,omitempty"` - Classifications *[]string `json:"classifications,omitempty"` -} + Ref *string `json:"ref,omitempty"` + AnalysisKey *string `json:"analysis_key,omitempty"` + Environment *string `json:"environment,omitempty"` + State *string `json:"state,omitempty"` + CommitSha *string `json:"commit_sha,omitempty"` + Message *Message `json:"message,omitempty"` + Location *Location `json:"location,omitempty"` + Classifications []string `json:"classifications,omitempty"` +} // Tool represents the tool used to generate a GitHub Code Scanning Alert. // @@ -64,17 +64,17 @@ type Tool struct { // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Alert struct { - RuleID *string `json:"rule_id,omitempty"` - RuleSeverity *string `json:"rule_severity,omitempty"` - RuleDescription *string `json:"rule_description,omitempty"` - Rule *Rule `json:"rule,omitempty"` - Tool *Tool `json:"tool,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - Open *bool `json:"open,omitempty"` - ClosedBy *User `json:"closed_by,omitempty"` - ClosedAt *Timestamp `json:"closed_at,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` + RuleID *string `json:"rule_id,omitempty"` + RuleSeverity *string `json:"rule_severity,omitempty"` + RuleDescription *string `json:"rule_description,omitempty"` + Rule *Rule `json:"rule,omitempty"` + Tool *Tool `json:"tool,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + Open *bool `json:"open,omitempty"` + ClosedBy *User `json:"closed_by,omitempty"` + ClosedAt *Timestamp `json:"closed_at,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` } From d9524bd3b965c31254737b36cc1fb0660f62201d Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Fri, 16 Jul 2021 20:59:24 -0400 Subject: [PATCH 09/29] update accessors --- github/github-accessors.go | 16 ---------------- github/github-accessors_test.go | 20 -------------------- 2 files changed, 36 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 4ed493119b5..30f63ff198e 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -7964,14 +7964,6 @@ func (m *MostRecentInstance) GetAnalysisKey() string { return *m.AnalysisKey } -// GetClassifications returns the Classifications field if it's non-nil, zero value otherwise. -func (m *MostRecentInstance) GetClassifications() []string { - if m == nil || m.Classifications == nil { - return nil - } - return *m.Classifications -} - // GetCommitSha returns the CommitSha field if it's non-nil, zero value otherwise. func (m *MostRecentInstance) GetCommitSha() string { if m == nil || m.CommitSha == nil { @@ -14340,14 +14332,6 @@ func (r *Rule) GetSeverity() string { return *r.Severity } -// GetTags returns the Tags field if it's non-nil, zero value otherwise. -func (r *Rule) GetTags() []string { - if r == nil || r.Tags == nil { - return nil - } - return *r.Tags -} - // 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 fb1c97c30e0..22128e56484 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -9329,16 +9329,6 @@ func TestMostRecentInstance_GetAnalysisKey(tt *testing.T) { m.GetAnalysisKey() } -func TestMostRecentInstance_GetClassifications(tt *testing.T) { - var zeroValue []string - m := &MostRecentInstance{Classifications: &zeroValue} - m.GetClassifications() - m = &MostRecentInstance{} - m.GetClassifications() - m = nil - m.GetClassifications() -} - func TestMostRecentInstance_GetCommitSha(tt *testing.T) { var zeroValue string m := &MostRecentInstance{CommitSha: &zeroValue} @@ -16759,16 +16749,6 @@ func TestRule_GetSeverity(tt *testing.T) { r.GetSeverity() } -func TestRule_GetTags(tt *testing.T) { - var zeroValue []string - r := &Rule{Tags: &zeroValue} - r.GetTags() - r = &Rule{} - r.GetTags() - r = nil - r.GetTags() -} - func TestRunner_GetBusy(tt *testing.T) { var zeroValue bool r := &Runner{Busy: &zeroValue} From 2da7533c6237e7c20afe89aaf91ddad34e834f4a Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 12:35:33 -0400 Subject: [PATCH 10/29] adding test cases to the newly added fields --- github/code-scanning.go | 2 +- github/code-scanning_test.go | 65 ++++++++++++++++++++++++++++++--- github/github-accessors.go | 8 ++-- github/github-accessors_test.go | 10 ++--- 4 files changed, 69 insertions(+), 16 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index 7c0b44c0f06..ce3c634fa96 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -45,7 +45,7 @@ type MostRecentInstance struct { AnalysisKey *string `json:"analysis_key,omitempty"` Environment *string `json:"environment,omitempty"` State *string `json:"state,omitempty"` - CommitSha *string `json:"commit_sha,omitempty"` + CommitSHA *string `json:"commit_sha,omitempty"` Message *Message `json:"message,omitempty"` Location *Location `json:"location,omitempty"` Classifications []string `json:"classifications,omitempty"` diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index efbc9bd6228..553451007da 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -161,6 +161,32 @@ func TestActionsService_GetAlert(t *testing.T) { "guid": null, "version": "1.4.0" }, + "rule": { + "id": "js/useless-expression", + "severity": "warning", + "description": "Expression has no effect", + "name": "js/useless-expression" + }, + "most_recent_instance": { + "ref": "refs/heads/main", + "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", + "environment": "{}", + "state": "open", + "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930", + "message": { + "text": "This path depends on a user-provided value." + }, + "location": { + "path": "spec-main/api-session-spec.ts", + "start_line": 917, + "end_line": 917, + "start_column": 7, + "end_column": 18 + }, + "classifications": [ + "test" + ] + } "created_at":"2019-01-02T15:04:05Z", "open":true, "closed_by":null, @@ -181,12 +207,39 @@ func TestActionsService_GetAlert(t *testing.T) { RuleSeverity: String("warning"), RuleDescription: String("Expression has no effect"), Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, - CreatedAt: &date, - Open: Bool(true), - ClosedBy: nil, - ClosedAt: nil, - URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/88"), - HTMLURL: String("https://github.com/o/r/security/code-scanning/88"), + Rule: &Rule{ + ID: String("js/useless-expression"), + Severity: String("warning"), + Description: String("Expression has no effect"), + Name: String("js/useless-expression"), + FullDescription: String("Expression has no effect"), + Tags: []string{"dummy"}, + Help: String("Expression has no effect"), + }, + CreatedAt: &date, + Open: Bool(true), + ClosedBy: nil, + ClosedAt: nil, + URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/88"), + HTMLURL: String("https://github.com/o/r/security/code-scanning/88"), + MostRecentInstance: &MostRecentInstance{ + Ref: String("refs/heads/main"), + AnalysisKey: String(".github/workflows/codeql-analysis.yml:CodeQL-Build"), + Environment: String("{}"), + State: String("open"), + CommitSHA: String("3f8a64020bf6aeff2f5cc8be7776fee7996947fd"), + Message: &Message{ + Text: String("This path depends on a user-provided value."), + }, + Location: &Location{ + Path: String("spec-main/api-session-spec.ts"), + StartLine: Int(917), + EndLine: Int(917), + StartColumn: Int(7), + EndColumn: Int(18), + }, + Classifications: []string{"test"}, + }, } if !cmp.Equal(alert, want) { t.Errorf("CodeScanning.GetAlert returned %+v, want %+v", alert, want) diff --git a/github/github-accessors.go b/github/github-accessors.go index 30f63ff198e..8c629c5d6a4 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -7964,12 +7964,12 @@ func (m *MostRecentInstance) GetAnalysisKey() string { return *m.AnalysisKey } -// GetCommitSha returns the CommitSha field if it's non-nil, zero value otherwise. -func (m *MostRecentInstance) GetCommitSha() string { - if m == nil || m.CommitSha == nil { +// GetCommitSHA returns the CommitSHA field if it's non-nil, zero value otherwise. +func (m *MostRecentInstance) GetCommitSHA() string { + if m == nil || m.CommitSHA == nil { return "" } - return *m.CommitSha + return *m.CommitSHA } // GetEnvironment returns the Environment field if it's non-nil, zero value otherwise. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 22128e56484..e7568d89264 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -9329,14 +9329,14 @@ func TestMostRecentInstance_GetAnalysisKey(tt *testing.T) { m.GetAnalysisKey() } -func TestMostRecentInstance_GetCommitSha(tt *testing.T) { +func TestMostRecentInstance_GetCommitSHA(tt *testing.T) { var zeroValue string - m := &MostRecentInstance{CommitSha: &zeroValue} - m.GetCommitSha() + m := &MostRecentInstance{CommitSHA: &zeroValue} + m.GetCommitSHA() m = &MostRecentInstance{} - m.GetCommitSha() + m.GetCommitSHA() m = nil - m.GetCommitSha() + m.GetCommitSHA() } func TestMostRecentInstance_GetEnvironment(tt *testing.T) { From b819f9fbcdd77c2e8ac6cdc69facaeee5016586b Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 12:52:50 -0400 Subject: [PATCH 11/29] bugfix testcase --- github/code-scanning_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 553451007da..28c52896396 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -166,6 +166,11 @@ func TestActionsService_GetAlert(t *testing.T) { "severity": "warning", "description": "Expression has no effect", "name": "js/useless-expression" + "full_description": "Expression has no effect", + "tags": [ + "test" + ], + "help": "Expression has no effect", }, "most_recent_instance": { "ref": "refs/heads/main", @@ -213,7 +218,7 @@ func TestActionsService_GetAlert(t *testing.T) { Description: String("Expression has no effect"), Name: String("js/useless-expression"), FullDescription: String("Expression has no effect"), - Tags: []string{"dummy"}, + Tags: []string{"test"}, Help: String("Expression has no effect"), }, CreatedAt: &date, From 07526c1e5396dbfdfc556a2393d913686f99efcb Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 13:01:34 -0400 Subject: [PATCH 12/29] bugfix testcase --- github/code-scanning_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 28c52896396..328147a3dc7 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -172,7 +172,7 @@ func TestActionsService_GetAlert(t *testing.T) { ], "help": "Expression has no effect", }, - "most_recent_instance": { + "most_recent_instance": { "ref": "refs/heads/main", "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", "environment": "{}", From 0182ac0b8b326352d7390f7c7c50f877af1c7e8b Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Sat, 17 Jul 2021 13:09:07 -0400 Subject: [PATCH 13/29] Update code-scanning_test.go --- github/code-scanning_test.go | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 328147a3dc7..d9d5d94521c 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -161,37 +161,6 @@ func TestActionsService_GetAlert(t *testing.T) { "guid": null, "version": "1.4.0" }, - "rule": { - "id": "js/useless-expression", - "severity": "warning", - "description": "Expression has no effect", - "name": "js/useless-expression" - "full_description": "Expression has no effect", - "tags": [ - "test" - ], - "help": "Expression has no effect", - }, - "most_recent_instance": { - "ref": "refs/heads/main", - "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", - "environment": "{}", - "state": "open", - "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930", - "message": { - "text": "This path depends on a user-provided value." - }, - "location": { - "path": "spec-main/api-session-spec.ts", - "start_line": 917, - "end_line": 917, - "start_column": 7, - "end_column": 18 - }, - "classifications": [ - "test" - ] - } "created_at":"2019-01-02T15:04:05Z", "open":true, "closed_by":null, From 80b5d86405f8a2345da162919816daf7a03fd183 Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Sat, 17 Jul 2021 13:16:24 -0400 Subject: [PATCH 14/29] Update code-scanning_test.go --- github/code-scanning_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index d9d5d94521c..1afbd8ae1e2 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -161,6 +161,37 @@ func TestActionsService_GetAlert(t *testing.T) { "guid": null, "version": "1.4.0" }, + "rule": { + "id": "js/useless-expression", + "severity": "warning", + "description": "Expression has no effect", + "name": "js/useless-expression", + "full_description": "Expression has no effect", + "tags": [ + "test" + ], + "help": "Expression has no effect", + }, + "most_recent_instance": { + "ref": "refs/heads/main", + "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", + "environment": "{}", + "state": "open", + "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930", + "message": { + "text": "This path depends on a user-provided value." + }, + "location": { + "path": "spec-main/api-session-spec.ts", + "start_line": 917, + "end_line": 917, + "start_column": 7, + "end_column": 18 + }, + "classifications": [ + "test" + ] + }, "created_at":"2019-01-02T15:04:05Z", "open":true, "closed_by":null, From e0a2eed003ce3e605a68a497988501ead82741c7 Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Sat, 17 Jul 2021 13:22:58 -0400 Subject: [PATCH 15/29] Update code-scanning_test.go --- github/code-scanning_test.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 1afbd8ae1e2..1ed1b33f217 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -172,26 +172,6 @@ func TestActionsService_GetAlert(t *testing.T) { ], "help": "Expression has no effect", }, - "most_recent_instance": { - "ref": "refs/heads/main", - "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", - "environment": "{}", - "state": "open", - "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930", - "message": { - "text": "This path depends on a user-provided value." - }, - "location": { - "path": "spec-main/api-session-spec.ts", - "start_line": 917, - "end_line": 917, - "start_column": 7, - "end_column": 18 - }, - "classifications": [ - "test" - ] - }, "created_at":"2019-01-02T15:04:05Z", "open":true, "closed_by":null, From e62b68e113298e6111470e50221712fc3e0e6421 Mon Sep 17 00:00:00 2001 From: ganeshkumarsv <53483484+ganeshkumarsv@users.noreply.github.com> Date: Sat, 17 Jul 2021 13:26:33 -0400 Subject: [PATCH 16/29] Update code-scanning_test.go --- github/code-scanning_test.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 1ed1b33f217..6497d1baa4d 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -161,17 +161,26 @@ func TestActionsService_GetAlert(t *testing.T) { "guid": null, "version": "1.4.0" }, - "rule": { - "id": "js/useless-expression", - "severity": "warning", - "description": "Expression has no effect", - "name": "js/useless-expression", - "full_description": "Expression has no effect", - "tags": [ + "most_recent_instance": { + "ref": "refs/heads/main", + "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", + "environment": "{}", + "state": "open", + "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930", + "message": { + "text": "This path depends on a user-provided value." + }, + "location": { + "path": "spec-main/api-session-spec.ts", + "start_line": 917, + "end_line": 917, + "start_column": 7, + "end_column": 18 + }, + "classifications": [ "test" - ], - "help": "Expression has no effect", - }, + ] + }, "created_at":"2019-01-02T15:04:05Z", "open":true, "closed_by":null, From a91cf5fce27bf3ef1db6074a95c9a130b939f480 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 13:35:10 -0400 Subject: [PATCH 17/29] bugfix testcase --- github/code-scanning_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 6497d1baa4d..64e36e44238 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -161,6 +161,17 @@ func TestActionsService_GetAlert(t *testing.T) { "guid": null, "version": "1.4.0" }, + "rule": { + "id": "js/useless-expression", + "severity": "warning", + "description": "Arbitrary file write during zip extraction (\"Zip Slip\")", + "name": "js/useless-expression", + "full_description": "Extracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten.", + "tags": [ + "test", + ], + "help": "# Arbitrary file write during zip extraction (\"Zip Slip\")\\nExtracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten ..." + } "most_recent_instance": { "ref": "refs/heads/main", "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", From f0394f38cb234c6f2a19bbff0ff9e7174fdad139 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 13:38:26 -0400 Subject: [PATCH 18/29] bugfix testcase --- github/code-scanning_test.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 64e36e44238..09a4cd8fc05 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -164,14 +164,7 @@ func TestActionsService_GetAlert(t *testing.T) { "rule": { "id": "js/useless-expression", "severity": "warning", - "description": "Arbitrary file write during zip extraction (\"Zip Slip\")", - "name": "js/useless-expression", - "full_description": "Extracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten.", - "tags": [ - "test", - ], - "help": "# Arbitrary file write during zip extraction (\"Zip Slip\")\\nExtracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten ..." - } + }, "most_recent_instance": { "ref": "refs/heads/main", "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", From 9d96c9f7abddd27b4e2d9d2e536b9b53144218ac Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 13:42:40 -0400 Subject: [PATCH 19/29] bugfix testcase --- github/code-scanning_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 09a4cd8fc05..247253d4429 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -162,9 +162,9 @@ func TestActionsService_GetAlert(t *testing.T) { "version": "1.4.0" }, "rule": { - "id": "js/useless-expression", - "severity": "warning", - }, + "id": "useless expression", + "severity": "warning" + }, "most_recent_instance": { "ref": "refs/heads/main", "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", From fc1e16393e2068acad78b61ce7d30cfb1609f59c Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 14:12:58 -0400 Subject: [PATCH 20/29] bugfix testcase --- github/code-scanning_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 247253d4429..862f5740292 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -163,7 +163,14 @@ func TestActionsService_GetAlert(t *testing.T) { }, "rule": { "id": "useless expression", - "severity": "warning" + "severity": "warning", + "description": "Expression has no effect", + "name: "useless expression", + "full_description": "Expression has no effect", + "help": "Expression has no effect", + "tags": [ + "test" + ] }, "most_recent_instance": { "ref": "refs/heads/main", @@ -206,10 +213,10 @@ func TestActionsService_GetAlert(t *testing.T) { RuleDescription: String("Expression has no effect"), Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, Rule: &Rule{ - ID: String("js/useless-expression"), + ID: String("useless expression"), Severity: String("warning"), Description: String("Expression has no effect"), - Name: String("js/useless-expression"), + Name: String("useless expression"), FullDescription: String("Expression has no effect"), Tags: []string{"test"}, Help: String("Expression has no effect"), From 524decb7d6535c33c5451b4442a93de0622a9fc1 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 14:15:54 -0400 Subject: [PATCH 21/29] bugfix testcase --- github/code-scanning_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 862f5740292..918c1ecc548 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -165,7 +165,7 @@ func TestActionsService_GetAlert(t *testing.T) { "id": "useless expression", "severity": "warning", "description": "Expression has no effect", - "name: "useless expression", + "name": "useless expression", "full_description": "Expression has no effect", "help": "Expression has no effect", "tags": [ From 118bdbc28c78d91f68f17c7ea9ca0a8df90534c0 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 14:22:57 -0400 Subject: [PATCH 22/29] bugfix testcase --- github/code-scanning_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 918c1ecc548..a4e0608ed06 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -168,9 +168,6 @@ func TestActionsService_GetAlert(t *testing.T) { "name": "useless expression", "full_description": "Expression has no effect", "help": "Expression has no effect", - "tags": [ - "test" - ] }, "most_recent_instance": { "ref": "refs/heads/main", @@ -218,7 +215,6 @@ func TestActionsService_GetAlert(t *testing.T) { Description: String("Expression has no effect"), Name: String("useless expression"), FullDescription: String("Expression has no effect"), - Tags: []string{"test"}, Help: String("Expression has no effect"), }, CreatedAt: &date, From 5871724fdd27adca22a2f84f8233613529b0c23f Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 14:27:41 -0400 Subject: [PATCH 23/29] bugfix testcase --- github/code-scanning_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index a4e0608ed06..287a80d70aa 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -167,7 +167,7 @@ func TestActionsService_GetAlert(t *testing.T) { "description": "Expression has no effect", "name": "useless expression", "full_description": "Expression has no effect", - "help": "Expression has no effect", + "help": "Expression has no effect" }, "most_recent_instance": { "ref": "refs/heads/main", From bdd87fbc488715608a8b74bae3c89ddbd507bc51 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sat, 17 Jul 2021 14:37:55 -0400 Subject: [PATCH 24/29] bugfix testcase --- github/code-scanning_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 287a80d70aa..c166ea12ad8 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -171,10 +171,8 @@ func TestActionsService_GetAlert(t *testing.T) { }, "most_recent_instance": { "ref": "refs/heads/main", - "analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build", - "environment": "{}", "state": "open", - "commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930", + "commit_sha": "abcdefg12345", "message": { "text": "This path depends on a user-provided value." }, @@ -224,11 +222,9 @@ func TestActionsService_GetAlert(t *testing.T) { URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/88"), HTMLURL: String("https://github.com/o/r/security/code-scanning/88"), MostRecentInstance: &MostRecentInstance{ - Ref: String("refs/heads/main"), - AnalysisKey: String(".github/workflows/codeql-analysis.yml:CodeQL-Build"), - Environment: String("{}"), - State: String("open"), - CommitSHA: String("3f8a64020bf6aeff2f5cc8be7776fee7996947fd"), + Ref: String("refs/heads/main"), + State: String("open"), + CommitSHA: String("abcdefg12345"), Message: &Message{ Text: String("This path depends on a user-provided value."), }, From 2d7443efd097168536e1059ddd7fadd07ddeaba7 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sun, 18 Jul 2021 00:06:36 -0400 Subject: [PATCH 25/29] bugfix testcase --- github/code-scanning_test.go | 124 +++++++++++++++++++++++++++++++---- 1 file changed, 112 insertions(+), 12 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index c166ea12ad8..5d542778422 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -69,6 +69,32 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { "guid": null, "version": "1.4.0" }, + "rule": { + "id": "useless expression", + "severity": "warning", + "description": "Expression has no effect", + "name": "useless expression", + "full_description": "Expression has no effect", + "help": "Expression has no effect" + }, + "most_recent_instance": { + "ref": "refs/heads/main", + "state": "open", + "commit_sha": "abcdefg12345", + "message": { + "text": "This path depends on a user-provided value." + }, + "location": { + "path": "spec-main/api-session-spec.ts", + "start_line": 917, + "end_line": 917, + "start_column": 7, + "end_column": 18 + }, + "classifications": [ + "test" + ] + }, "created_at":"2020-05-06T12:00:00Z", "open":true, "closed_by":null, @@ -85,6 +111,32 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { "guid": null, "version": "1.4.0" }, + "rule": { + "id": "useless expression", + "severity": "warning", + "description": "Expression has no effect", + "name": "useless expression", + "full_description": "Expression has no effect", + "help": "Expression has no effect" + }, + "most_recent_instance": { + "ref": "refs/heads/main", + "state": "open", + "commit_sha": "abcdefg12345", + "message": { + "text": "This path depends on a user-provided value." + }, + "location": { + "path": "spec-main/api-session-spec.ts", + "start_line": 917, + "end_line": 917, + "start_column": 7, + "end_column": 18 + }, + "classifications": [ + "test" + ] + }, "created_at":"2020-05-06T12:00:00Z", "open":true, "closed_by":null, @@ -108,24 +160,72 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { RuleSeverity: String("warning"), RuleDescription: String("Useless conditional"), Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, - CreatedAt: &date, - Open: Bool(true), - ClosedBy: nil, - ClosedAt: nil, - URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/25"), - HTMLURL: String("https://github.com/o/r/security/code-scanning/25"), + Rule: &Rule{ + ID: String("useless expression"), + Severity: String("warning"), + Description: String("Expression has no effect"), + Name: String("useless expression"), + FullDescription: String("Expression has no effect"), + Help: String("Expression has no effect"), + }, + CreatedAt: &date, + Open: Bool(true), + ClosedBy: nil, + ClosedAt: nil, + URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/25"), + HTMLURL: String("https://github.com/o/r/security/code-scanning/25"), + MostRecentInstance: &MostRecentInstance{ + Ref: String("refs/heads/main"), + State: String("open"), + CommitSHA: String("abcdefg12345"), + Message: &Message{ + Text: String("This path depends on a user-provided value."), + }, + Location: &Location{ + Path: String("spec-main/api-session-spec.ts"), + StartLine: Int(917), + EndLine: Int(917), + StartColumn: Int(7), + EndColumn: Int(18), + }, + Classifications: []string{"test"}, + }, }, { RuleID: String("js/useless-expression"), RuleSeverity: String("warning"), RuleDescription: String("Expression has no effect"), Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, - CreatedAt: &date, - Open: Bool(true), - ClosedBy: nil, - ClosedAt: nil, - URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/88"), - HTMLURL: String("https://github.com/o/r/security/code-scanning/88"), + Rule: &Rule{ + ID: String("useless expression"), + Severity: String("warning"), + Description: String("Expression has no effect"), + Name: String("useless expression"), + FullDescription: String("Expression has no effect"), + Help: String("Expression has no effect"), + }, + CreatedAt: &date, + Open: Bool(true), + ClosedBy: nil, + ClosedAt: nil, + URL: String("https://api.github.com/repos/o/r/code-scanning/alerts/88"), + HTMLURL: String("https://github.com/o/r/security/code-scanning/88"), + MostRecentInstance: &MostRecentInstance{ + Ref: String("refs/heads/main"), + State: String("open"), + CommitSHA: String("abcdefg12345"), + Message: &Message{ + Text: String("This path depends on a user-provided value."), + }, + Location: &Location{ + Path: String("spec-main/api-session-spec.ts"), + StartLine: Int(917), + EndLine: Int(917), + StartColumn: Int(7), + EndColumn: Int(18), + }, + Classifications: []string{"test"}, + }, }, } if !cmp.Equal(alerts, want) { From 0e43f9703d71d86745ddb040e5d6a281ce365de1 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sun, 18 Jul 2021 00:28:32 -0400 Subject: [PATCH 26/29] bugfix testcase --- github/code-scanning_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/github/code-scanning_test.go b/github/code-scanning_test.go index 5d542778422..7403582fc58 100644 --- a/github/code-scanning_test.go +++ b/github/code-scanning_test.go @@ -70,10 +70,10 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { "version": "1.4.0" }, "rule": { - "id": "useless expression", + "id": "js/trivial-conditional", "severity": "warning", - "description": "Expression has no effect", - "name": "useless expression", + "description": "Useless conditional", + "name": "js/trivial-conditional", "full_description": "Expression has no effect", "help": "Expression has no effect" }, @@ -112,10 +112,10 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { "version": "1.4.0" }, "rule": { - "id": "useless expression", + "id": "js/useless-expression", "severity": "warning", "description": "Expression has no effect", - "name": "useless expression", + "name": "js/useless-expression", "full_description": "Expression has no effect", "help": "Expression has no effect" }, @@ -161,10 +161,10 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { RuleDescription: String("Useless conditional"), Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, Rule: &Rule{ - ID: String("useless expression"), + ID: String("js/trivial-conditional"), Severity: String("warning"), - Description: String("Expression has no effect"), - Name: String("useless expression"), + Description: String("Useless conditional"), + Name: String("js/trivial-conditional"), FullDescription: String("Expression has no effect"), Help: String("Expression has no effect"), }, @@ -197,10 +197,10 @@ func TestActionsService_ListAlertsForRepo(t *testing.T) { RuleDescription: String("Expression has no effect"), Tool: &Tool{Name: String("CodeQL"), GUID: nil, Version: String("1.4.0")}, Rule: &Rule{ - ID: String("useless expression"), + ID: String("js/useless-expression"), Severity: String("warning"), Description: String("Expression has no effect"), - Name: String("useless expression"), + Name: String("js/useless-expression"), FullDescription: String("Expression has no effect"), Help: String("Expression has no effect"), }, From 70a2c4634527dc4aa1940077d950723bcc20283e Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sun, 18 Jul 2021 15:13:21 -0400 Subject: [PATCH 27/29] adding godoc to the structs --- github/code-scanning.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/github/code-scanning.go b/github/code-scanning.go index ce3c634fa96..b81260b31ca 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -18,6 +18,9 @@ import ( // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/ type CodeScanningService service +// Rule represents the complete details of GitHub Code Scanning alert type. +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Rule struct { ID *string `json:"id,omitempty"` Severity *string `json:"severity,omitempty"` @@ -28,6 +31,9 @@ type Rule struct { Help *string `json:"help,omitempty"` } +// Location represents the exact location of the GitHub Code Scanning Alert in the scanned project. +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Location struct { Path *string `json:"path,omitempty"` StartLine *int `json:"start_line,omitempty"` @@ -36,10 +42,16 @@ type Location struct { EndColumn *int `json:"end_column,omitempty"` } +// Message is a part of MostRecentInstance struct which provides the appropriate message when any action is performed on the analysis object +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Message struct { Text *string `json:"text,omitempty"` } +// MostRecentInstance provides details of the most recent instance of this alert for the default branch or for the specified Git reference +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type MostRecentInstance struct { Ref *string `json:"ref,omitempty"` AnalysisKey *string `json:"analysis_key,omitempty"` From b21b23d90f4b3a97976112b03f901a46772cefe1 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Sun, 18 Jul 2021 15:53:26 -0400 Subject: [PATCH 28/29] adding new fields to the alert struct --- github/code-scanning.go | 28 +++++ github/github-accessors.go | 176 ++++++++++++++++++++++++++ github/github-accessors_test.go | 217 ++++++++++++++++++++++++++++++++ 3 files changed, 421 insertions(+) diff --git a/github/code-scanning.go b/github/code-scanning.go index b81260b31ca..75083af7252 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -72,6 +72,30 @@ type Tool struct { Version *string `json:"version,omitempty"` } +// DismissedBy provides details about the person who dismissed the Alert. +// +// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository +type DismissedBy struct { + Login *string `json:"login,omitempty"` + ID *int `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + AvatarURL *string `json:"avatar_url,omitempty"` + GravatarID *string `json:"gravatar_id,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + FollowersURL *string `json:"followers_url,omitempty"` + FollowingURL *string `json:"following_url,omitempty"` + GistsURL *string `json:"gists_url,omitempty"` + StarredURL *string `json:"starred_url,omitempty"` + SubscriptionsURL *string `json:"subscriptions_url,omitempty"` + OrganizationsURL *string `json:"organizations_url,omitempty"` + ReposURL *string `json:"repos_url,omitempty"` + EventsURL *string `json:"events_url,omitempty"` + ReceivedEventsURL *string `json:"received_events_url,omitempty"` + Type *string `json:"type,omitempty"` + SiteAdmin *bool `json:"site_admin,omitempty"` +} + // Alert represents an individual GitHub Code Scanning Alert on a single repository. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository @@ -88,6 +112,10 @@ type Alert struct { URL *string `json:"url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` + DismissedBy *DismissedBy `json:"dismissed_by,omitempty"` + DismissedAt *Timestamp `json:"dismissed_at,omitempty"` + DismissedReason *string `json:"dismissed_reason,omitempty"` + InstancesURL *string `json:"instances_url,omitempty"` } // ID returns the ID associated with an alert. It is the number at the end of the security alert's URL. diff --git a/github/github-accessors.go b/github/github-accessors.go index 8c629c5d6a4..d3cc22ab037 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -172,6 +172,30 @@ func (a *Alert) GetCreatedAt() Timestamp { return *a.CreatedAt } +// GetDismissedAt returns the DismissedAt field if it's non-nil, zero value otherwise. +func (a *Alert) GetDismissedAt() Timestamp { + if a == nil || a.DismissedAt == nil { + return Timestamp{} + } + return *a.DismissedAt +} + +// GetDismissedBy returns the DismissedBy field. +func (a *Alert) GetDismissedBy() *DismissedBy { + if a == nil { + return nil + } + return a.DismissedBy +} + +// GetDismissedReason returns the DismissedReason field if it's non-nil, zero value otherwise. +func (a *Alert) GetDismissedReason() string { + if a == nil || a.DismissedReason == nil { + return "" + } + return *a.DismissedReason +} + // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. func (a *Alert) GetHTMLURL() string { if a == nil || a.HTMLURL == nil { @@ -180,6 +204,14 @@ func (a *Alert) GetHTMLURL() string { return *a.HTMLURL } +// GetInstancesURL returns the InstancesURL field if it's non-nil, zero value otherwise. +func (a *Alert) GetInstancesURL() string { + if a == nil || a.InstancesURL == nil { + return "" + } + return *a.InstancesURL +} + // GetMostRecentInstance returns the MostRecentInstance field. func (a *Alert) GetMostRecentInstance() *MostRecentInstance { if a == nil { @@ -3564,6 +3596,150 @@ func (d *DismissalRestrictionsRequest) GetUsers() []string { return *d.Users } +// GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetAvatarURL() string { + if d == nil || d.AvatarURL == nil { + return "" + } + return *d.AvatarURL +} + +// GetEventsURL returns the EventsURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetEventsURL() string { + if d == nil || d.EventsURL == nil { + return "" + } + return *d.EventsURL +} + +// GetFollowersURL returns the FollowersURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetFollowersURL() string { + if d == nil || d.FollowersURL == nil { + return "" + } + return *d.FollowersURL +} + +// GetFollowingURL returns the FollowingURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetFollowingURL() string { + if d == nil || d.FollowingURL == nil { + return "" + } + return *d.FollowingURL +} + +// GetGistsURL returns the GistsURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetGistsURL() string { + if d == nil || d.GistsURL == nil { + return "" + } + return *d.GistsURL +} + +// GetGravatarID returns the GravatarID field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetGravatarID() string { + if d == nil || d.GravatarID == nil { + return "" + } + return *d.GravatarID +} + +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetHTMLURL() string { + if d == nil || d.HTMLURL == nil { + return "" + } + return *d.HTMLURL +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetID() int { + if d == nil || d.ID == nil { + return 0 + } + return *d.ID +} + +// GetLogin returns the Login field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetLogin() string { + if d == nil || d.Login == nil { + return "" + } + return *d.Login +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetNodeID() string { + if d == nil || d.NodeID == nil { + return "" + } + return *d.NodeID +} + +// GetOrganizationsURL returns the OrganizationsURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetOrganizationsURL() string { + if d == nil || d.OrganizationsURL == nil { + return "" + } + return *d.OrganizationsURL +} + +// GetReceivedEventsURL returns the ReceivedEventsURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetReceivedEventsURL() string { + if d == nil || d.ReceivedEventsURL == nil { + return "" + } + return *d.ReceivedEventsURL +} + +// GetReposURL returns the ReposURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetReposURL() string { + if d == nil || d.ReposURL == nil { + return "" + } + return *d.ReposURL +} + +// GetSiteAdmin returns the SiteAdmin field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetSiteAdmin() bool { + if d == nil || d.SiteAdmin == nil { + return false + } + return *d.SiteAdmin +} + +// GetStarredURL returns the StarredURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetStarredURL() string { + if d == nil || d.StarredURL == nil { + return "" + } + return *d.StarredURL +} + +// GetSubscriptionsURL returns the SubscriptionsURL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetSubscriptionsURL() string { + if d == nil || d.SubscriptionsURL == nil { + return "" + } + return *d.SubscriptionsURL +} + +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetType() string { + if d == nil || d.Type == nil { + return "" + } + return *d.Type +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (d *DismissedBy) GetURL() string { + if d == nil || d.URL == nil { + return "" + } + return *d.URL +} + // GetDismissalCommitID returns the DismissalCommitID field if it's non-nil, zero value otherwise. func (d *DismissedReview) GetDismissalCommitID() string { if d == nil || d.DismissalCommitID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index e7568d89264..99ef725db16 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -180,6 +180,33 @@ func TestAlert_GetCreatedAt(tt *testing.T) { a.GetCreatedAt() } +func TestAlert_GetDismissedAt(tt *testing.T) { + var zeroValue Timestamp + a := &Alert{DismissedAt: &zeroValue} + a.GetDismissedAt() + a = &Alert{} + a.GetDismissedAt() + a = nil + a.GetDismissedAt() +} + +func TestAlert_GetDismissedBy(tt *testing.T) { + a := &Alert{} + a.GetDismissedBy() + a = nil + a.GetDismissedBy() +} + +func TestAlert_GetDismissedReason(tt *testing.T) { + var zeroValue string + a := &Alert{DismissedReason: &zeroValue} + a.GetDismissedReason() + a = &Alert{} + a.GetDismissedReason() + a = nil + a.GetDismissedReason() +} + func TestAlert_GetHTMLURL(tt *testing.T) { var zeroValue string a := &Alert{HTMLURL: &zeroValue} @@ -190,6 +217,16 @@ func TestAlert_GetHTMLURL(tt *testing.T) { a.GetHTMLURL() } +func TestAlert_GetInstancesURL(tt *testing.T) { + var zeroValue string + a := &Alert{InstancesURL: &zeroValue} + a.GetInstancesURL() + a = &Alert{} + a.GetInstancesURL() + a = nil + a.GetInstancesURL() +} + func TestAlert_GetMostRecentInstance(tt *testing.T) { a := &Alert{} a.GetMostRecentInstance() @@ -4165,6 +4202,186 @@ func TestDismissalRestrictionsRequest_GetUsers(tt *testing.T) { d.GetUsers() } +func TestDismissedBy_GetAvatarURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{AvatarURL: &zeroValue} + d.GetAvatarURL() + d = &DismissedBy{} + d.GetAvatarURL() + d = nil + d.GetAvatarURL() +} + +func TestDismissedBy_GetEventsURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{EventsURL: &zeroValue} + d.GetEventsURL() + d = &DismissedBy{} + d.GetEventsURL() + d = nil + d.GetEventsURL() +} + +func TestDismissedBy_GetFollowersURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{FollowersURL: &zeroValue} + d.GetFollowersURL() + d = &DismissedBy{} + d.GetFollowersURL() + d = nil + d.GetFollowersURL() +} + +func TestDismissedBy_GetFollowingURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{FollowingURL: &zeroValue} + d.GetFollowingURL() + d = &DismissedBy{} + d.GetFollowingURL() + d = nil + d.GetFollowingURL() +} + +func TestDismissedBy_GetGistsURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{GistsURL: &zeroValue} + d.GetGistsURL() + d = &DismissedBy{} + d.GetGistsURL() + d = nil + d.GetGistsURL() +} + +func TestDismissedBy_GetGravatarID(tt *testing.T) { + var zeroValue string + d := &DismissedBy{GravatarID: &zeroValue} + d.GetGravatarID() + d = &DismissedBy{} + d.GetGravatarID() + d = nil + d.GetGravatarID() +} + +func TestDismissedBy_GetHTMLURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{HTMLURL: &zeroValue} + d.GetHTMLURL() + d = &DismissedBy{} + d.GetHTMLURL() + d = nil + d.GetHTMLURL() +} + +func TestDismissedBy_GetID(tt *testing.T) { + var zeroValue int + d := &DismissedBy{ID: &zeroValue} + d.GetID() + d = &DismissedBy{} + d.GetID() + d = nil + d.GetID() +} + +func TestDismissedBy_GetLogin(tt *testing.T) { + var zeroValue string + d := &DismissedBy{Login: &zeroValue} + d.GetLogin() + d = &DismissedBy{} + d.GetLogin() + d = nil + d.GetLogin() +} + +func TestDismissedBy_GetNodeID(tt *testing.T) { + var zeroValue string + d := &DismissedBy{NodeID: &zeroValue} + d.GetNodeID() + d = &DismissedBy{} + d.GetNodeID() + d = nil + d.GetNodeID() +} + +func TestDismissedBy_GetOrganizationsURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{OrganizationsURL: &zeroValue} + d.GetOrganizationsURL() + d = &DismissedBy{} + d.GetOrganizationsURL() + d = nil + d.GetOrganizationsURL() +} + +func TestDismissedBy_GetReceivedEventsURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{ReceivedEventsURL: &zeroValue} + d.GetReceivedEventsURL() + d = &DismissedBy{} + d.GetReceivedEventsURL() + d = nil + d.GetReceivedEventsURL() +} + +func TestDismissedBy_GetReposURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{ReposURL: &zeroValue} + d.GetReposURL() + d = &DismissedBy{} + d.GetReposURL() + d = nil + d.GetReposURL() +} + +func TestDismissedBy_GetSiteAdmin(tt *testing.T) { + var zeroValue bool + d := &DismissedBy{SiteAdmin: &zeroValue} + d.GetSiteAdmin() + d = &DismissedBy{} + d.GetSiteAdmin() + d = nil + d.GetSiteAdmin() +} + +func TestDismissedBy_GetStarredURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{StarredURL: &zeroValue} + d.GetStarredURL() + d = &DismissedBy{} + d.GetStarredURL() + d = nil + d.GetStarredURL() +} + +func TestDismissedBy_GetSubscriptionsURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{SubscriptionsURL: &zeroValue} + d.GetSubscriptionsURL() + d = &DismissedBy{} + d.GetSubscriptionsURL() + d = nil + d.GetSubscriptionsURL() +} + +func TestDismissedBy_GetType(tt *testing.T) { + var zeroValue string + d := &DismissedBy{Type: &zeroValue} + d.GetType() + d = &DismissedBy{} + d.GetType() + d = nil + d.GetType() +} + +func TestDismissedBy_GetURL(tt *testing.T) { + var zeroValue string + d := &DismissedBy{URL: &zeroValue} + d.GetURL() + d = &DismissedBy{} + d.GetURL() + d = nil + d.GetURL() +} + func TestDismissedReview_GetDismissalCommitID(tt *testing.T) { var zeroValue string d := &DismissedReview{DismissalCommitID: &zeroValue} From f5839b31e0033b6b97f7de14749151743f9d4f09 Mon Sep 17 00:00:00 2001 From: GaneshKumar Date: Tue, 20 Jul 2021 00:22:01 -0400 Subject: [PATCH 29/29] addressing review comments --- github/code-scanning.go | 40 +------ github/github-accessors.go | 146 +------------------------- github/github-accessors_test.go | 180 -------------------------------- 3 files changed, 4 insertions(+), 362 deletions(-) diff --git a/github/code-scanning.go b/github/code-scanning.go index 75083af7252..640ec899f54 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -19,8 +19,6 @@ import ( type CodeScanningService service // Rule represents the complete details of GitHub Code Scanning alert type. -// -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Rule struct { ID *string `json:"id,omitempty"` Severity *string `json:"severity,omitempty"` @@ -32,8 +30,6 @@ type Rule struct { } // Location represents the exact location of the GitHub Code Scanning Alert in the scanned project. -// -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Location struct { Path *string `json:"path,omitempty"` StartLine *int `json:"start_line,omitempty"` @@ -42,16 +38,12 @@ type Location struct { EndColumn *int `json:"end_column,omitempty"` } -// Message is a part of MostRecentInstance struct which provides the appropriate message when any action is performed on the analysis object -// -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository +// Message is a part of MostRecentInstance struct which provides the appropriate message when any action is performed on the analysis object. type Message struct { Text *string `json:"text,omitempty"` } -// MostRecentInstance provides details of the most recent instance of this alert for the default branch or for the specified Git reference -// -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository +// MostRecentInstance provides details of the most recent instance of this alert for the default branch or for the specified Git reference. type MostRecentInstance struct { Ref *string `json:"ref,omitempty"` AnalysisKey *string `json:"analysis_key,omitempty"` @@ -64,38 +56,12 @@ type MostRecentInstance struct { } // Tool represents the tool used to generate a GitHub Code Scanning Alert. -// -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Tool struct { Name *string `json:"name,omitempty"` GUID *string `json:"guid,omitempty"` Version *string `json:"version,omitempty"` } -// DismissedBy provides details about the person who dismissed the Alert. -// -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository -type DismissedBy struct { - Login *string `json:"login,omitempty"` - ID *int `json:"id,omitempty"` - NodeID *string `json:"node_id,omitempty"` - AvatarURL *string `json:"avatar_url,omitempty"` - GravatarID *string `json:"gravatar_id,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - FollowersURL *string `json:"followers_url,omitempty"` - FollowingURL *string `json:"following_url,omitempty"` - GistsURL *string `json:"gists_url,omitempty"` - StarredURL *string `json:"starred_url,omitempty"` - SubscriptionsURL *string `json:"subscriptions_url,omitempty"` - OrganizationsURL *string `json:"organizations_url,omitempty"` - ReposURL *string `json:"repos_url,omitempty"` - EventsURL *string `json:"events_url,omitempty"` - ReceivedEventsURL *string `json:"received_events_url,omitempty"` - Type *string `json:"type,omitempty"` - SiteAdmin *bool `json:"site_admin,omitempty"` -} - // Alert represents an individual GitHub Code Scanning Alert on a single repository. // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository @@ -112,7 +78,7 @@ type Alert struct { URL *string `json:"url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` - DismissedBy *DismissedBy `json:"dismissed_by,omitempty"` + DismissedBy *User `json:"dismissed_by,omitempty"` DismissedAt *Timestamp `json:"dismissed_at,omitempty"` DismissedReason *string `json:"dismissed_reason,omitempty"` InstancesURL *string `json:"instances_url,omitempty"` diff --git a/github/github-accessors.go b/github/github-accessors.go index d3cc22ab037..2d51bfdfb6e 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -181,7 +181,7 @@ func (a *Alert) GetDismissedAt() Timestamp { } // GetDismissedBy returns the DismissedBy field. -func (a *Alert) GetDismissedBy() *DismissedBy { +func (a *Alert) GetDismissedBy() *User { if a == nil { return nil } @@ -3596,150 +3596,6 @@ func (d *DismissalRestrictionsRequest) GetUsers() []string { return *d.Users } -// GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetAvatarURL() string { - if d == nil || d.AvatarURL == nil { - return "" - } - return *d.AvatarURL -} - -// GetEventsURL returns the EventsURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetEventsURL() string { - if d == nil || d.EventsURL == nil { - return "" - } - return *d.EventsURL -} - -// GetFollowersURL returns the FollowersURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetFollowersURL() string { - if d == nil || d.FollowersURL == nil { - return "" - } - return *d.FollowersURL -} - -// GetFollowingURL returns the FollowingURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetFollowingURL() string { - if d == nil || d.FollowingURL == nil { - return "" - } - return *d.FollowingURL -} - -// GetGistsURL returns the GistsURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetGistsURL() string { - if d == nil || d.GistsURL == nil { - return "" - } - return *d.GistsURL -} - -// GetGravatarID returns the GravatarID field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetGravatarID() string { - if d == nil || d.GravatarID == nil { - return "" - } - return *d.GravatarID -} - -// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetHTMLURL() string { - if d == nil || d.HTMLURL == nil { - return "" - } - return *d.HTMLURL -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetID() int { - if d == nil || d.ID == nil { - return 0 - } - return *d.ID -} - -// GetLogin returns the Login field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetLogin() string { - if d == nil || d.Login == nil { - return "" - } - return *d.Login -} - -// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetNodeID() string { - if d == nil || d.NodeID == nil { - return "" - } - return *d.NodeID -} - -// GetOrganizationsURL returns the OrganizationsURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetOrganizationsURL() string { - if d == nil || d.OrganizationsURL == nil { - return "" - } - return *d.OrganizationsURL -} - -// GetReceivedEventsURL returns the ReceivedEventsURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetReceivedEventsURL() string { - if d == nil || d.ReceivedEventsURL == nil { - return "" - } - return *d.ReceivedEventsURL -} - -// GetReposURL returns the ReposURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetReposURL() string { - if d == nil || d.ReposURL == nil { - return "" - } - return *d.ReposURL -} - -// GetSiteAdmin returns the SiteAdmin field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetSiteAdmin() bool { - if d == nil || d.SiteAdmin == nil { - return false - } - return *d.SiteAdmin -} - -// GetStarredURL returns the StarredURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetStarredURL() string { - if d == nil || d.StarredURL == nil { - return "" - } - return *d.StarredURL -} - -// GetSubscriptionsURL returns the SubscriptionsURL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetSubscriptionsURL() string { - if d == nil || d.SubscriptionsURL == nil { - return "" - } - return *d.SubscriptionsURL -} - -// GetType returns the Type field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetType() string { - if d == nil || d.Type == nil { - return "" - } - return *d.Type -} - -// GetURL returns the URL field if it's non-nil, zero value otherwise. -func (d *DismissedBy) GetURL() string { - if d == nil || d.URL == nil { - return "" - } - return *d.URL -} - // GetDismissalCommitID returns the DismissalCommitID field if it's non-nil, zero value otherwise. func (d *DismissedReview) GetDismissalCommitID() string { if d == nil || d.DismissalCommitID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 99ef725db16..86bb6c3ec67 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -4202,186 +4202,6 @@ func TestDismissalRestrictionsRequest_GetUsers(tt *testing.T) { d.GetUsers() } -func TestDismissedBy_GetAvatarURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{AvatarURL: &zeroValue} - d.GetAvatarURL() - d = &DismissedBy{} - d.GetAvatarURL() - d = nil - d.GetAvatarURL() -} - -func TestDismissedBy_GetEventsURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{EventsURL: &zeroValue} - d.GetEventsURL() - d = &DismissedBy{} - d.GetEventsURL() - d = nil - d.GetEventsURL() -} - -func TestDismissedBy_GetFollowersURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{FollowersURL: &zeroValue} - d.GetFollowersURL() - d = &DismissedBy{} - d.GetFollowersURL() - d = nil - d.GetFollowersURL() -} - -func TestDismissedBy_GetFollowingURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{FollowingURL: &zeroValue} - d.GetFollowingURL() - d = &DismissedBy{} - d.GetFollowingURL() - d = nil - d.GetFollowingURL() -} - -func TestDismissedBy_GetGistsURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{GistsURL: &zeroValue} - d.GetGistsURL() - d = &DismissedBy{} - d.GetGistsURL() - d = nil - d.GetGistsURL() -} - -func TestDismissedBy_GetGravatarID(tt *testing.T) { - var zeroValue string - d := &DismissedBy{GravatarID: &zeroValue} - d.GetGravatarID() - d = &DismissedBy{} - d.GetGravatarID() - d = nil - d.GetGravatarID() -} - -func TestDismissedBy_GetHTMLURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{HTMLURL: &zeroValue} - d.GetHTMLURL() - d = &DismissedBy{} - d.GetHTMLURL() - d = nil - d.GetHTMLURL() -} - -func TestDismissedBy_GetID(tt *testing.T) { - var zeroValue int - d := &DismissedBy{ID: &zeroValue} - d.GetID() - d = &DismissedBy{} - d.GetID() - d = nil - d.GetID() -} - -func TestDismissedBy_GetLogin(tt *testing.T) { - var zeroValue string - d := &DismissedBy{Login: &zeroValue} - d.GetLogin() - d = &DismissedBy{} - d.GetLogin() - d = nil - d.GetLogin() -} - -func TestDismissedBy_GetNodeID(tt *testing.T) { - var zeroValue string - d := &DismissedBy{NodeID: &zeroValue} - d.GetNodeID() - d = &DismissedBy{} - d.GetNodeID() - d = nil - d.GetNodeID() -} - -func TestDismissedBy_GetOrganizationsURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{OrganizationsURL: &zeroValue} - d.GetOrganizationsURL() - d = &DismissedBy{} - d.GetOrganizationsURL() - d = nil - d.GetOrganizationsURL() -} - -func TestDismissedBy_GetReceivedEventsURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{ReceivedEventsURL: &zeroValue} - d.GetReceivedEventsURL() - d = &DismissedBy{} - d.GetReceivedEventsURL() - d = nil - d.GetReceivedEventsURL() -} - -func TestDismissedBy_GetReposURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{ReposURL: &zeroValue} - d.GetReposURL() - d = &DismissedBy{} - d.GetReposURL() - d = nil - d.GetReposURL() -} - -func TestDismissedBy_GetSiteAdmin(tt *testing.T) { - var zeroValue bool - d := &DismissedBy{SiteAdmin: &zeroValue} - d.GetSiteAdmin() - d = &DismissedBy{} - d.GetSiteAdmin() - d = nil - d.GetSiteAdmin() -} - -func TestDismissedBy_GetStarredURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{StarredURL: &zeroValue} - d.GetStarredURL() - d = &DismissedBy{} - d.GetStarredURL() - d = nil - d.GetStarredURL() -} - -func TestDismissedBy_GetSubscriptionsURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{SubscriptionsURL: &zeroValue} - d.GetSubscriptionsURL() - d = &DismissedBy{} - d.GetSubscriptionsURL() - d = nil - d.GetSubscriptionsURL() -} - -func TestDismissedBy_GetType(tt *testing.T) { - var zeroValue string - d := &DismissedBy{Type: &zeroValue} - d.GetType() - d = &DismissedBy{} - d.GetType() - d = nil - d.GetType() -} - -func TestDismissedBy_GetURL(tt *testing.T) { - var zeroValue string - d := &DismissedBy{URL: &zeroValue} - d.GetURL() - d = &DismissedBy{} - d.GetURL() - d = nil - d.GetURL() -} - func TestDismissedReview_GetDismissalCommitID(tt *testing.T) { var zeroValue string d := &DismissedReview{DismissalCommitID: &zeroValue}