You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// e.g. https://github.com/github/advisory-database/blob/2d3bc73d2117893b217233aeb95b9236c7b93761/advisories/github-reviewed/2019/05/GHSA-j59f-6m4q-62h6/GHSA-j59f-6m4q-62h6.json#L14
382
-
// Trim the suffix to avoid errors
383
-
cvssVectorV3:=strings.TrimSuffix(s.Score, "/")
384
-
eb:=oops.With("cvss_vector_v3", cvssVectorV3)
385
-
switch {
386
-
casestrings.HasPrefix(cvssVectorV3, "CVSS:3.0"):
387
-
cvss, err:=gocvss30.ParseVector(cvssVectorV3)
388
-
iferr!=nil {
389
-
return"", 0, eb.Wrapf(err, "failed to parse CVSSv3.0 vector")
390
-
}
391
-
// cvss.EnvironmentalScore() returns the optimal score required from Vector.
392
-
// If the Environmental Metrics is not set, it will be the same value as TemporalScore(),
393
-
// and if Temporal Metrics is not set, it will be the same value as Basescore().
// e.g. https://github.com/github/advisory-database/blob/2d3bc73d2117893b217233aeb95b9236c7b93761/advisories/github-reviewed/2019/05/GHSA-j59f-6m4q-62h6/GHSA-j59f-6m4q-62h6.json#L14
425
+
// Trim the suffix to avoid errors
426
+
vector:=strings.TrimSuffix(score, "/")
427
+
eb:=oops.With("cvss_vector_v3", vector)
428
+
switch {
429
+
casestrings.HasPrefix(vector, "CVSS:3.0"):
430
+
cvss, err:=gocvss30.ParseVector(vector)
431
+
iferr!=nil {
432
+
return"", 0, eb.Wrapf(err, "failed to parse CVSSv3.0 vector")
433
+
}
434
+
returnvector, cvss.EnvironmentalScore(), nil
435
+
casestrings.HasPrefix(vector, "CVSS:3.1"):
436
+
cvss, err:=gocvss31.ParseVector(vector)
437
+
iferr!=nil {
438
+
return"", 0, eb.Wrapf(err, "failed to parse CVSSv3.1 vector")
439
+
}
440
+
returnvector, cvss.EnvironmentalScore(), nil
441
+
default:
442
+
return"", 0, eb.Errorf("vector does not have CVSS v3 prefix: \"CVSS:3.0\" or \"CVSS:3.1\"")
443
+
}
444
+
}
445
+
446
+
// parseSeverityV40 parses a CVSSv4.0 vector string and returns the vector and score
0 commit comments