Skip to content
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

krel: Support Tempral CVE metrics #2664

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions pkg/cve/cve.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,25 @@ func (cve *CVE) Validate() error {
return errors.New("string CVSS vector missing from CVE data")
}

// Parse the vector string to make sure it is well formed
bm, err := cvss.NewBase().Decode(cve.CVSSVector)
if err != nil {
return fmt.Errorf("parsing CVSS vector string: %w", err)
}
cve.CalcLink = fmt.Sprintf(
"https://www.first.org/cvss/calculator/%s#%s", bm.Ver.String(), cve.CVSSVector,
)
if len(cve.CVSSVector) == 44 {
// Parse the vector string to make sure it is well formed
bm, err := cvss.NewBase().Decode(cve.CVSSVector)
if err != nil {
return fmt.Errorf("parsing CVSS vector string: %w", err)
}
cve.CalcLink = fmt.Sprintf(
"https://www.first.org/cvss/calculator/%s#%s", bm.Ver.String(), cve.CVSSVector,
)
} else {
// Parse the vector string to make sure it is well formed
bm, err := cvss.NewTemporal().Decode(cve.CVSSVector)
if err != nil {
return fmt.Errorf("parsing CVSS vector string: %w", err)
}
cve.CalcLink = fmt.Sprintf(
"https://www.first.org/cvss/calculator/%s#%s", bm.Ver.String(), cve.CVSSVector,
)
}

if cve.CVSSScore == 0 {
return errors.New("missing CVSS score from CVE data")
Expand Down