Skip to content

Commit

Permalink
Merge pull request #2664 from puerco/metric-temporal
Browse files Browse the repository at this point in the history
krel: Support Tempral CVE metrics
  • Loading branch information
k8s-ci-robot authored Sep 14, 2022
2 parents 7225a74 + 746139f commit 6726748
Showing 1 changed file with 19 additions and 8 deletions.
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

0 comments on commit 6726748

Please sign in to comment.