From ea4ee2cd8db189b47c34f821367e184a15dfa6ba Mon Sep 17 00:00:00 2001 From: cpanato Date: Mon, 20 Nov 2023 14:52:27 +0100 Subject: [PATCH] update based on feedback part II Signed-off-by: cpanato --- github/github-accessors.go | 56 +++++++++++++------------- github/github-accessors_test.go | 64 +++++++++++++++--------------- github/security_advisories.go | 20 +++++----- github/security_advisories_test.go | 8 ++-- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 26c07971f60..7a23acd58ae 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -7814,12 +7814,12 @@ func (g *GitObject) GetURL() string { return *g.URL } -// GetGitHubReviewedAt returns the GitHubReviewedAt field if it's non-nil, zero value otherwise. -func (g *GlobalSecurityAdvisory) GetGitHubReviewedAt() Timestamp { - if g == nil || g.GitHubReviewedAt == nil { +// GetGithubReviewedAt returns the GithubReviewedAt field if it's non-nil, zero value otherwise. +func (g *GlobalSecurityAdvisory) GetGithubReviewedAt() Timestamp { + if g == nil || g.GithubReviewedAt == nil { return Timestamp{} } - return *g.GitHubReviewedAt + return *g.GithubReviewedAt } // GetID returns the ID field if it's non-nil, zero value otherwise. @@ -7862,6 +7862,30 @@ func (g *GlobalSecurityAdvisory) GetType() string { return *g.Type } +// GetFirstPatchedVersion returns the FirstPatchedVersion field if it's non-nil, zero value otherwise. +func (g *GlobalSecurityVulnerability) GetFirstPatchedVersion() string { + if g == nil || g.FirstPatchedVersion == nil { + return "" + } + return *g.FirstPatchedVersion +} + +// GetPackage returns the Package field. +func (g *GlobalSecurityVulnerability) GetPackage() *VulnerabilityPackage { + if g == nil { + return nil + } + return g.Package +} + +// GetVulnerableVersionRange returns the VulnerableVersionRange field if it's non-nil, zero value otherwise. +func (g *GlobalSecurityVulnerability) GetVulnerableVersionRange() string { + if g == nil || g.VulnerableVersionRange == nil { + return "" + } + return *g.VulnerableVersionRange +} + // GetInstallation returns the Installation field. func (g *GollumEvent) GetInstallation() *Installation { if g == nil { @@ -24478,30 +24502,6 @@ func (u *UserSuspendOptions) GetReason() string { return *u.Reason } -// GetFirstPatchedVersion returns the FirstPatchedVersion field if it's non-nil, zero value otherwise. -func (v *Vulnerabilities) GetFirstPatchedVersion() string { - if v == nil || v.FirstPatchedVersion == nil { - return "" - } - return *v.FirstPatchedVersion -} - -// GetPackage returns the Package field. -func (v *Vulnerabilities) GetPackage() *VulnerabilityPackage { - if v == nil { - return nil - } - return v.Package -} - -// GetVulnerableVersionRange returns the VulnerableVersionRange field if it's non-nil, zero value otherwise. -func (v *Vulnerabilities) GetVulnerableVersionRange() string { - if v == nil || v.VulnerableVersionRange == nil { - return "" - } - return *v.VulnerableVersionRange -} - // GetEcosystem returns the Ecosystem field if it's non-nil, zero value otherwise. func (v *VulnerabilityPackage) GetEcosystem() string { if v == nil || v.Ecosystem == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index d41e99c00bf..c5cad32ddbc 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -9159,14 +9159,14 @@ func TestGitObject_GetURL(tt *testing.T) { g.GetURL() } -func TestGlobalSecurityAdvisory_GetGitHubReviewedAt(tt *testing.T) { +func TestGlobalSecurityAdvisory_GetGithubReviewedAt(tt *testing.T) { var zeroValue Timestamp - g := &GlobalSecurityAdvisory{GitHubReviewedAt: &zeroValue} - g.GetGitHubReviewedAt() + g := &GlobalSecurityAdvisory{GithubReviewedAt: &zeroValue} + g.GetGithubReviewedAt() g = &GlobalSecurityAdvisory{} - g.GetGitHubReviewedAt() + g.GetGithubReviewedAt() g = nil - g.GetGitHubReviewedAt() + g.GetGithubReviewedAt() } func TestGlobalSecurityAdvisory_GetID(tt *testing.T) { @@ -9219,6 +9219,33 @@ func TestGlobalSecurityAdvisory_GetType(tt *testing.T) { g.GetType() } +func TestGlobalSecurityVulnerability_GetFirstPatchedVersion(tt *testing.T) { + var zeroValue string + g := &GlobalSecurityVulnerability{FirstPatchedVersion: &zeroValue} + g.GetFirstPatchedVersion() + g = &GlobalSecurityVulnerability{} + g.GetFirstPatchedVersion() + g = nil + g.GetFirstPatchedVersion() +} + +func TestGlobalSecurityVulnerability_GetPackage(tt *testing.T) { + g := &GlobalSecurityVulnerability{} + g.GetPackage() + g = nil + g.GetPackage() +} + +func TestGlobalSecurityVulnerability_GetVulnerableVersionRange(tt *testing.T) { + var zeroValue string + g := &GlobalSecurityVulnerability{VulnerableVersionRange: &zeroValue} + g.GetVulnerableVersionRange() + g = &GlobalSecurityVulnerability{} + g.GetVulnerableVersionRange() + g = nil + g.GetVulnerableVersionRange() +} + func TestGollumEvent_GetInstallation(tt *testing.T) { g := &GollumEvent{} g.GetInstallation() @@ -28516,33 +28543,6 @@ func TestUserSuspendOptions_GetReason(tt *testing.T) { u.GetReason() } -func TestVulnerabilities_GetFirstPatchedVersion(tt *testing.T) { - var zeroValue string - v := &Vulnerabilities{FirstPatchedVersion: &zeroValue} - v.GetFirstPatchedVersion() - v = &Vulnerabilities{} - v.GetFirstPatchedVersion() - v = nil - v.GetFirstPatchedVersion() -} - -func TestVulnerabilities_GetPackage(tt *testing.T) { - v := &Vulnerabilities{} - v.GetPackage() - v = nil - v.GetPackage() -} - -func TestVulnerabilities_GetVulnerableVersionRange(tt *testing.T) { - var zeroValue string - v := &Vulnerabilities{VulnerableVersionRange: &zeroValue} - v.GetVulnerableVersionRange() - v = &Vulnerabilities{} - v.GetVulnerableVersionRange() - v = nil - v.GetVulnerableVersionRange() -} - func TestVulnerabilityPackage_GetEcosystem(tt *testing.T) { var zeroValue string v := &VulnerabilityPackage{Ecosystem: &zeroValue} diff --git a/github/security_advisories.go b/github/security_advisories.go index b3e12e77e2e..1c1f15a69a4 100644 --- a/github/security_advisories.go +++ b/github/security_advisories.go @@ -97,19 +97,19 @@ type ListGlobalSecurityAdvisoriesOptions struct { // GlobalSecurityAdvisory represents the global security advisory object response. type GlobalSecurityAdvisory struct { SecurityAdvisory - ID *int64 `json:"id,omitempty"` - RepositoryAdvisoryURL *string `json:"repository_advisory_url,omitempty"` - Type *string `json:"type,omitempty"` - SourceCodeLocation *string `json:"source_code_location,omitempty"` - References []string `json:"references,omitempty"` - Vulnerabilities []*Vulnerabilities `json:"vulnerabilities,omitempty"` - GitHubReviewedAt *Timestamp `json:"github_reviewed_at,omitempty"` - NVDPublishedAt *Timestamp `json:"nvd_published_at,omitempty"` - Credits []*Credit `json:"credits,omitempty"` + ID *int64 `json:"id,omitempty"` + RepositoryAdvisoryURL *string `json:"repository_advisory_url,omitempty"` + Type *string `json:"type,omitempty"` + SourceCodeLocation *string `json:"source_code_location,omitempty"` + References []string `json:"references,omitempty"` + Vulnerabilities []*GlobalSecurityVulnerability `json:"vulnerabilities,omitempty"` + GithubReviewedAt *Timestamp `json:"github_reviewed_at,omitempty"` + NVDPublishedAt *Timestamp `json:"nvd_published_at,omitempty"` + Credits []*Credit `json:"credits,omitempty"` } // Vulnerabilities represents the Vulnerabilities for the global security advisory. -type Vulnerabilities struct { +type GlobalSecurityVulnerability struct { Package *VulnerabilityPackage `json:"package,omitempty"` FirstPatchedVersion *string `json:"first_patched_version,omitempty"` VulnerableVersionRange *string `json:"vulnerable_version_range,omitempty"` diff --git a/github/security_advisories_test.go b/github/security_advisories_test.go index 8f8047f0db1..918e3e05002 100644 --- a/github/security_advisories_test.go +++ b/github/security_advisories_test.go @@ -449,7 +449,7 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { }, }, References: []string{"https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"}, - Vulnerabilities: []*Vulnerabilities{ + Vulnerabilities: []*GlobalSecurityVulnerability{ { Package: &VulnerabilityPackage{ Ecosystem: String("npm"), @@ -463,7 +463,7 @@ func TestListGlobalSecurityAdvisories(t *testing.T) { RepositoryAdvisoryURL: String("https://api.github.com/repos/project/a-package/security-advisories/GHSA-xoxo-1234-xoxo"), Type: String("reviewed"), SourceCodeLocation: String("https://github.com/project/a-package"), - GitHubReviewedAt: &date, + GithubReviewedAt: &date, NVDPublishedAt: &date, Credits: []*Credit{ { @@ -633,10 +633,10 @@ func TestGetGlobalSecurityAdvisories(t *testing.T) { Type: String("reviewed"), SourceCodeLocation: String("https://github.com/project/a-package"), References: []string{"https://nvd.nist.gov/vuln/detail/CVE-xoxo-1234"}, - GitHubReviewedAt: &date, + GithubReviewedAt: &date, NVDPublishedAt: &date, - Vulnerabilities: []*Vulnerabilities{ + Vulnerabilities: []*GlobalSecurityVulnerability{ { Package: &VulnerabilityPackage{ Ecosystem: String("npm"),