Skip to content

Commit

Permalink
Detect reject CVE in nvd and jvn (#175)
Browse files Browse the repository at this point in the history
* implement to remove rejected cves in NVD

* fix(fetcher/jvn): remove reject CVE
  • Loading branch information
shopper29 authored Jan 16, 2021
1 parent c01cf7c commit 15d4b2c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
7 changes: 5 additions & 2 deletions fetcher/jvn/xml/jvn.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,13 @@ func Fetch(metas []models.FeedMeta) ([]Item, error) {
return nil, fmt.Errorf(
"Failed to unmarshal. url: %s, err: %s", res.URL, err)
}
items = append(items, rdf.Items...)
for i, item := range rdf.Items {
if !(strings.Contains(item.Description, "** 未確定 **") || strings.Contains(item.Description, "** サポート外 **") || strings.Contains(item.Description, "** 削除 **")) {
items = append(items, rdf.Items[i])
}
}
}
return items, nil

}

// FetchConvert fetches vulnerability information from JVN and convert it to model
Expand Down
20 changes: 18 additions & 2 deletions fetcher/nvd/json/nvd.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,28 @@ func FetchConvert(metas []models.FeedMeta) (cves []models.CveDetail, err error)

errs := []error{}
for _, res := range results {
nvd := NvdJSON{}
if err = json.Unmarshal(res.Body, &nvd); err != nil {
var nvd, nvdIncludeRejectedCve NvdJSON
if err = json.Unmarshal(res.Body, &nvdIncludeRejectedCve); err != nil {
return nil, fmt.Errorf(
"Failed to unmarshal. url: %s, err: %s",
res.URL, err)
}

nvd.CveDataType = nvdIncludeRejectedCve.CveDataType
nvd.CveDataFormat = nvdIncludeRejectedCve.CveDataFormat
nvd.CveDataVersion = nvdIncludeRejectedCve.CveDataVersion
nvd.CveDataNumberOfCVEs = nvdIncludeRejectedCve.CveDataNumberOfCVEs
nvd.CveDataTimestamp = nvdIncludeRejectedCve.CveDataTimestamp

// Remove rejected CVEs
for i, item := range nvdIncludeRejectedCve.CveItems {
for _, description := range item.Cve.Description.DescriptionData {
if !(strings.Contains(description.Value, "** REJECT **")) {
nvd.CveItems = append(nvd.CveItems, nvdIncludeRejectedCve.CveItems[i])
}
}
}

cs, err := convert(nvd.CveItems)
if err != nil {
errs = append(errs, err)
Expand Down

0 comments on commit 15d4b2c

Please sign in to comment.