Skip to content

Commit

Permalink
fix(jvn): only logging if invalid cpe format in JVN (#181)
Browse files Browse the repository at this point in the history
* fix(jvn): only warning if invalid cpe format

* warn to info
  • Loading branch information
kotakanbe authored Feb 26, 2021
1 parent a2bfda9 commit 1aa7ea7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fetcher/jvn/xml/jvn.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,12 @@ func makeJvnURLs(years []int) (urls []string) {
func convertToModel(item *Item) (cves []models.CveDetail, err error) {
var cvss2, cvss3 Cvss
for _, cvss := range item.Cvsses {
switch cvss.Version {
case "2.0":
if strings.HasPrefix(cvss.Version, "2") {
cvss2 = cvss
case "3.0":
} else if strings.HasPrefix(cvss.Version, "3") {
cvss3 = cvss
} else {
log.Warnf("Unknown CVSS version format: %s", cvss.Version)
}
}

Expand Down Expand Up @@ -331,7 +332,9 @@ func convertToModel(item *Item) (cves []models.CveDetail, err error) {
for _, c := range item.Cpes {
cpeBase, err := fetcher.ParseCpeURI(c.Value)
if err != nil {
return nil, err
// logging only
log.Infof("Failed to parse CPE URI: %s, %s", c.Value, err)
continue
}
cpes = append(cpes, models.Cpe{
CpeBase: *cpeBase,
Expand Down

0 comments on commit 1aa7ea7

Please sign in to comment.