-
Notifications
You must be signed in to change notification settings - Fork 221
refactor(vulnfeeds): Use OSVSchema Vulnerability structs instead of maintaining a duplicate set #3714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor!
vulnfeeds/vulns/vulns.go
Outdated
@@ -168,57 +150,24 @@ type PackageInfo struct { | |||
Ecosystem string `json:"ecosystem,omitempty" yaml:"ecosystem,omitempty"` | |||
PURL string `json:"purl,omitempty" yaml:"purl,omitempty"` | |||
VersionInfo models.VersionInfo `json:"fixed_version,omitempty" yaml:"fixed_version,omitempty"` | |||
EcosystemSpecific map[string]string `json:"ecosystem_specific,omitempty" yaml:"ecosystem_specific,omitempty"` | |||
EcosystemSpecific map[string]any `json:"ecosystem_specific,omitempty" yaml:"ecosystem_specific,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change to any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to interface{} to align with go bindings
vulnfeeds/vulns/vulns.go
Outdated
|
||
// No CVSS 3.1, try falling back to CVSS 3.0 if available. | ||
if bestVectorString == "" { | ||
for _, metric := range md.CVSSMetricV30 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code here feels quite repeated for V3.0 and V3.1. I guess we can't really extract it into a separate function without using generics, can we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored a bit regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Noticed that we were using an outdated Vulnerability struct in vulns.go. This will update vulnfeeds to use the osvschema go bindings instead, which will keep the fields better up to date.
Also refactored FromCVE to take the specific fields it needs instead of the whole CVE for better modularity.
Sorry for the long PR.