Skip to content

Commit

Permalink
fix(fetcher/jvn): not register invalid CVE-ID (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n authored Dec 28, 2021
1 parent 591e34d commit 473b08f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fetcher/jvn/jvn.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"regexp"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -406,12 +407,17 @@ func parseJvnTime(strtime string) (t time.Time, err error) {
return
}

var cveIDPattern = regexp.MustCompile(`^CVE-[0-9]{4}-[0-9]{4,}$`)

func getCveIDs(item Item) []string {
cveIDsMap := map[string]bool{}
for _, ref := range item.References {
switch ref.Source {
case "NVD", "CVE":
cveIDsMap[ref.ID] = true
id := strings.TrimSpace(ref.ID)
if cveIDPattern.MatchString(id) {
cveIDsMap[id] = true
}
}
}
cveIDs := []string{}
Expand Down

0 comments on commit 473b08f

Please sign in to comment.