Skip to content

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

Merged
merged 9 commits into from
Jul 24, 2025

Conversation

jess-lowe
Copy link
Contributor

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.

Copy link
Contributor

@hogo6002 hogo6002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor!

@@ -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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change to any?

Copy link
Contributor Author

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


// No CVSS 3.1, try falling back to CVSS 3.0 if available.
if bestVectorString == "" {
for _, metric := range md.CVSSMetricV30 {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored a bit regardless.

@jess-lowe jess-lowe requested a review from hogo6002 July 24, 2025 00:35
Copy link
Contributor

@hogo6002 hogo6002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jess-lowe jess-lowe merged commit 0730a2e into google:master Jul 24, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants