diff --git a/ext/vulnmdsrc/nvd/nvd.go b/ext/vulnmdsrc/nvd/nvd.go index 5be08b97..92775763 100644 --- a/ext/vulnmdsrc/nvd/nvd.go +++ b/ext/vulnmdsrc/nvd/nvd.go @@ -57,8 +57,9 @@ type NVDMetadata struct { } type NVDmetadataCVSSv2 struct { - Vectors string - Score float64 + PublishedDateTime string + Vectors string + Score float64 } func init() { @@ -160,8 +161,17 @@ func getDataFeeds(dataFeedHashes map[string]string, localPath string) (map[strin } } + //A custom HTTP client limiting the amound of Idle connections is helpful when retrieving the feeds from nvd.nist.gov due to the number of timeouts. + var netClient = &http.Client{} + tr := &http.Transport{ + MaxIdleConns: 20, + MaxIdleConnsPerHost: 20, + } + + netClient = &http.Client{Transport: tr} + // Download data feed. - r, err := http.Get(fmt.Sprintf(dataFeedURL, dataFeedName)) + r, err := netClient.Get(fmt.Sprintf(dataFeedURL, dataFeedName)) if err != nil { log.WithError(err).WithField(logDataFeedName, dataFeedName).Error("could not download NVD data feed") return dataFeedReaders, dataFeedHashes, commonerr.ErrCouldNotDownload diff --git a/ext/vulnmdsrc/nvd/xml.go b/ext/vulnmdsrc/nvd/xml.go index 99e1420d..31ca35a2 100644 --- a/ext/vulnmdsrc/nvd/xml.go +++ b/ext/vulnmdsrc/nvd/xml.go @@ -26,8 +26,9 @@ type nvd struct { } type nvdEntry struct { - Name string `xml:"http://scap.nist.gov/schema/vulnerability/0.4 cve-id"` - CVSS nvdCVSS `xml:"http://scap.nist.gov/schema/vulnerability/0.4 cvss"` + Name string `xml:"http://scap.nist.gov/schema/vulnerability/0.4 cve-id"` + CVSS nvdCVSS `xml:"http://scap.nist.gov/schema/vulnerability/0.4 cvss"` + PublishedDateTime string `xml:"http://scap.nist.gov/schema/vulnerability/0.4 published-datetime"` } type nvdCVSS struct { @@ -64,8 +65,9 @@ func init() { func (n nvdEntry) Metadata() *NVDMetadata { metadata := &NVDMetadata{ CVSSv2: NVDmetadataCVSSv2{ - Vectors: n.CVSS.BaseMetrics.String(), - Score: n.CVSS.BaseMetrics.Score, + PublishedDateTime: n.PublishedDateTime, + Vectors: n.CVSS.BaseMetrics.String(), + Score: n.CVSS.BaseMetrics.Score, }, }