From 3cc63ea021249cd2b4ffd5cf682be8bb489bd523 Mon Sep 17 00:00:00 2001 From: Matt Fleury Date: Mon, 14 Apr 2025 09:59:54 -0400 Subject: [PATCH 1/8] feat: adding epss to dependabot alerts --- github/dependabot_alerts.go | 7 +++++++ github/dependabot_alerts_test.go | 8 ++++++++ github/github-accessors.go | 24 ++++++++++++++++++++++++ github/github-accessors_test.go | 16 ++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/github/dependabot_alerts.go b/github/dependabot_alerts.go index c274f07bece..e0910da2d47 100644 --- a/github/dependabot_alerts.go +++ b/github/dependabot_alerts.go @@ -29,6 +29,12 @@ type AdvisoryCWEs struct { Name *string `json:"name,omitempty"` } +// AdvisoryEPSS represents the advisory pertaining to the Exploit Prediction Scoring System. +type AdvisoryEPSS struct { + Percentage *float64 `json:"percentage,omitempty"` + Percentile *float64 `json:"percentile,omitempty"` +} + // DependabotSecurityAdvisory represents the GitHub Security Advisory. type DependabotSecurityAdvisory struct { GHSAID *string `json:"ghsa_id,omitempty"` @@ -39,6 +45,7 @@ type DependabotSecurityAdvisory struct { Severity *string `json:"severity,omitempty"` CVSS *AdvisoryCVSS `json:"cvss,omitempty"` CWEs []*AdvisoryCWEs `json:"cwes,omitempty"` + EPSS *AdvisoryEPSS `json:"epss,omitempty"` Identifiers []*AdvisoryIdentifier `json:"identifiers,omitempty"` References []*AdvisoryReference `json:"references,omitempty"` PublishedAt *Timestamp `json:"published_at,omitempty"` diff --git a/github/dependabot_alerts_test.go b/github/dependabot_alerts_test.go index 3a46855e011..c5254c1a5d0 100644 --- a/github/dependabot_alerts_test.go +++ b/github/dependabot_alerts_test.go @@ -281,6 +281,10 @@ func TestDependabotSecurityAdvisory_Marshal(t *testing.T) { Name: Ptr("Exposure of Sensitive Information to an Unauthorized Actor"), }, }, + EPSS: &AdvisoryEPSS{ + Percentage: Ptr(0.05), + Percentile: Ptr(0.5), + }, Identifiers: []*AdvisoryIdentifier{ { Type: Ptr("GHSA"), @@ -353,6 +357,10 @@ func TestDependabotSecurityAdvisory_Marshal(t *testing.T) { "name": "Exposure of Sensitive Information to an Unauthorized Actor" } ], + "epss": { + "percentage": 0.05, + "percentile": 0.5 + }, "identifiers": [ { "type": "GHSA", diff --git a/github/github-accessors.go b/github/github-accessors.go index 1e2442789d6..7f923d008f9 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -398,6 +398,22 @@ func (a *AdvisoryCWEs) GetName() string { return *a.Name } +// GetPercentage returns the Percentage field. +func (a *AdvisoryEPSS) GetPercentage() *float64 { + if a == nil { + return nil + } + return a.Percentage +} + +// GetPercentile returns the Percentile field. +func (a *AdvisoryEPSS) GetPercentile() *float64 { + if a == nil { + return nil + } + return a.Percentile +} + // GetType returns the Type field if it's non-nil, zero value otherwise. func (a *AdvisoryIdentifier) GetType() string { if a == nil || a.Type == nil { @@ -6854,6 +6870,14 @@ func (d *DependabotSecurityAdvisory) GetDescription() string { return *d.Description } +// GetEPSS returns the EPSS field. +func (d *DependabotSecurityAdvisory) GetEPSS() *AdvisoryEPSS { + if d == nil { + return nil + } + return d.EPSS +} + // GetGHSAID returns the GHSAID field if it's non-nil, zero value otherwise. func (d *DependabotSecurityAdvisory) GetGHSAID() string { if d == nil || d.GHSAID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 8dadb706cd6..ee8cd747974 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -507,6 +507,22 @@ func TestAdvisoryCWEs_GetName(tt *testing.T) { a.GetName() } +func TestAdvisoryEPSS_GetPercentage(tt *testing.T) { + tt.Parallel() + a := &AdvisoryEPSS{} + a.GetPercentage() + a = nil + a.GetPercentage() +} + +func TestAdvisoryEPSS_GetPercentile(tt *testing.T) { + tt.Parallel() + a := &AdvisoryEPSS{} + a.GetPercentile() + a = nil + a.GetPercentile() +} + func TestAdvisoryIdentifier_GetType(tt *testing.T) { tt.Parallel() var zeroValue string From f7463651c614beb01849c9b9db95dffece4a4dad Mon Sep 17 00:00:00 2001 From: Matt Fleury Date: Mon, 14 Apr 2025 10:03:50 -0400 Subject: [PATCH 2/8] adding generated file --- github/github-accessors_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index ee8cd747974..c9dfa0fd391 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -8920,6 +8920,14 @@ func TestDependabotSecurityAdvisory_GetDescription(tt *testing.T) { d.GetDescription() } +func TestDependabotSecurityAdvisory_GetEPSS(tt *testing.T) { + tt.Parallel() + d := &DependabotSecurityAdvisory{} + d.GetEPSS() + d = nil + d.GetEPSS() +} + func TestDependabotSecurityAdvisory_GetGHSAID(tt *testing.T) { tt.Parallel() var zeroValue string From 76900a9de7fb51b455f5eb93670d78f3c0984142 Mon Sep 17 00:00:00 2001 From: Matt Fleury Date: Mon, 14 Apr 2025 10:17:20 -0400 Subject: [PATCH 3/8] feat: fixing spaces --- github/dependabot_alerts_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/dependabot_alerts_test.go b/github/dependabot_alerts_test.go index c5254c1a5d0..e57de513a3f 100644 --- a/github/dependabot_alerts_test.go +++ b/github/dependabot_alerts_test.go @@ -357,7 +357,7 @@ func TestDependabotSecurityAdvisory_Marshal(t *testing.T) { "name": "Exposure of Sensitive Information to an Unauthorized Actor" } ], - "epss": { + "epss": { "percentage": 0.05, "percentile": 0.5 }, From 9fa1dbfd4f221f2af667153a8589902db140a770 Mon Sep 17 00:00:00 2001 From: Matt Fleury <166510074+mdfleury-wbd@users.noreply.github.com> Date: Mon, 14 Apr 2025 10:43:23 -0400 Subject: [PATCH 4/8] Update github/dependabot_alerts.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/dependabot_alerts.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/github/dependabot_alerts.go b/github/dependabot_alerts.go index e0910da2d47..9803339ff19 100644 --- a/github/dependabot_alerts.go +++ b/github/dependabot_alerts.go @@ -30,6 +30,9 @@ type AdvisoryCWEs struct { } // AdvisoryEPSS represents the advisory pertaining to the Exploit Prediction Scoring System. +// +// For more information, see: +// https://github.blog/changelog/2024-10-10-epss-scores-in-the-github-advisory-database/ type AdvisoryEPSS struct { Percentage *float64 `json:"percentage,omitempty"` Percentile *float64 `json:"percentile,omitempty"` From 515415eff326cd0e008aa9a58fcb3a1dc9933097 Mon Sep 17 00:00:00 2001 From: Matt Fleury Date: Mon, 14 Apr 2025 14:06:06 -0400 Subject: [PATCH 5/8] feat: removing omitempty --- github/dependabot_alerts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/dependabot_alerts.go b/github/dependabot_alerts.go index 9803339ff19..7f4ef3d7085 100644 --- a/github/dependabot_alerts.go +++ b/github/dependabot_alerts.go @@ -34,8 +34,8 @@ type AdvisoryCWEs struct { // For more information, see: // https://github.blog/changelog/2024-10-10-epss-scores-in-the-github-advisory-database/ type AdvisoryEPSS struct { - Percentage *float64 `json:"percentage,omitempty"` - Percentile *float64 `json:"percentile,omitempty"` + Percentage *float64 `json:"percentage"` + Percentile *float64 `json:"percentile"` } // DependabotSecurityAdvisory represents the GitHub Security Advisory. From a54f0c725be58eec2b13a67c9630b6f1f0b23cac Mon Sep 17 00:00:00 2001 From: Matt Fleury <166510074+mdfleury-wbd@users.noreply.github.com> Date: Tue, 15 Apr 2025 07:52:34 -0400 Subject: [PATCH 6/8] Update github/dependabot_alerts.go Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/dependabot_alerts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/dependabot_alerts.go b/github/dependabot_alerts.go index 7f4ef3d7085..67e624c9e88 100644 --- a/github/dependabot_alerts.go +++ b/github/dependabot_alerts.go @@ -34,8 +34,8 @@ type AdvisoryCWEs struct { // For more information, see: // https://github.blog/changelog/2024-10-10-epss-scores-in-the-github-advisory-database/ type AdvisoryEPSS struct { - Percentage *float64 `json:"percentage"` - Percentile *float64 `json:"percentile"` + Percentage float64 `json:"percentage"` + Percentile float64 `json:"percentile"` } // DependabotSecurityAdvisory represents the GitHub Security Advisory. From b6095698d3118125a5767114bed68aa3ca63959b Mon Sep 17 00:00:00 2001 From: Matt Fleury Date: Tue, 15 Apr 2025 08:03:10 -0400 Subject: [PATCH 7/8] regenerating after changing types --- github/github-accessors.go | 16 ---------------- github/github-accessors_test.go | 16 ---------------- 2 files changed, 32 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 7f923d008f9..4a32702755a 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -398,22 +398,6 @@ func (a *AdvisoryCWEs) GetName() string { return *a.Name } -// GetPercentage returns the Percentage field. -func (a *AdvisoryEPSS) GetPercentage() *float64 { - if a == nil { - return nil - } - return a.Percentage -} - -// GetPercentile returns the Percentile field. -func (a *AdvisoryEPSS) GetPercentile() *float64 { - if a == nil { - return nil - } - return a.Percentile -} - // GetType returns the Type field if it's non-nil, zero value otherwise. func (a *AdvisoryIdentifier) GetType() string { if a == nil || a.Type == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index c9dfa0fd391..9efb190b522 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -507,22 +507,6 @@ func TestAdvisoryCWEs_GetName(tt *testing.T) { a.GetName() } -func TestAdvisoryEPSS_GetPercentage(tt *testing.T) { - tt.Parallel() - a := &AdvisoryEPSS{} - a.GetPercentage() - a = nil - a.GetPercentage() -} - -func TestAdvisoryEPSS_GetPercentile(tt *testing.T) { - tt.Parallel() - a := &AdvisoryEPSS{} - a.GetPercentile() - a = nil - a.GetPercentile() -} - func TestAdvisoryIdentifier_GetType(tt *testing.T) { tt.Parallel() var zeroValue string From 311bdc2e0ec104ab7cbc2901fbda1e6ada123393 Mon Sep 17 00:00:00 2001 From: Matt Fleury Date: Tue, 15 Apr 2025 08:05:46 -0400 Subject: [PATCH 8/8] removing ptrs from tests --- github/dependabot_alerts_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/dependabot_alerts_test.go b/github/dependabot_alerts_test.go index e57de513a3f..8410825a2d0 100644 --- a/github/dependabot_alerts_test.go +++ b/github/dependabot_alerts_test.go @@ -282,8 +282,8 @@ func TestDependabotSecurityAdvisory_Marshal(t *testing.T) { }, }, EPSS: &AdvisoryEPSS{ - Percentage: Ptr(0.05), - Percentile: Ptr(0.5), + Percentage: 0.05, + Percentile: 0.5, }, Identifiers: []*AdvisoryIdentifier{ {