Skip to content

Commit

Permalink
fix: support JVN new shcema, ignore CVSS v3 for now (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
kotakanbe authored Feb 23, 2018
1 parent 39e2b72 commit 2a3c286
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,19 @@ func convertNvd(entries []nvd.Entry) (cves []models.CveDetail) {
// ConvertJvn converts Jvn structure(got from JVN) to model structure.
func convertJvn(items []jvn.Item) (cves []models.CveDetail) {
for _, item := range items {
if item.Cvss.Score == "0" || len(item.Cvss.Score) == 0 {
log.Debugf("Skip. CVSS Score is zero. JvnID: %s", item.Identifier)
//ignore invalid item
continue

// TODO support V3
var cvssV2 jvn.Cvss
for _, cvss := range item.Cvsses {
if cvss.Version == "3.0" {
continue
}
if cvss.Score == "0" || len(cvss.Score) == 0 {
log.Debugf("Skip. CVSS Score V2 is zero. JvnID: %s", item.Identifier)
//ignore invalid item
continue
}
cvssV2 = cvss
}

// References
Expand Down Expand Up @@ -147,9 +156,9 @@ func convertJvn(items []jvn.Item) (cves []models.CveDetail) {
JvnID: item.Identifier,
CveID: cveID,

Score: stringToFloat(item.Cvss.Score),
Severity: item.Cvss.Severity,
Vector: item.Cvss.Vector,
Score: stringToFloat(cvssV2.Score),
Severity: cvssV2.Severity,
Vector: cvssV2.Vector,
// Version: item.Cvss.Version,

References: refs,
Expand Down
2 changes: 1 addition & 1 deletion jvn/jvn.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Item struct {
Identifier string `xml:"identifier"`
References []references `xml:"references"`
Cpes []cpe `xml:"cpe"`
Cvss Cvss `xml:"cvss"`
Cvsses []Cvss `xml:"cvss"`
Date string `xml:"date"`
Issued string `xml:"issued"`
Modified string `xml:"modified"`
Expand Down

0 comments on commit 2a3c286

Please sign in to comment.