This commit is contained in:
ErikThoreson 2017-12-06 16:34:17 +00:00 committed by GitHub
commit 6746ea4176
2 changed files with 19 additions and 7 deletions

View File

@ -57,6 +57,7 @@ type NVDMetadata struct {
}
type NVDmetadataCVSSv2 struct {
PublishedDateTime string
Vectors string
Score float64
}
@ -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

View File

@ -28,6 +28,7 @@ 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"`
PublishedDateTime string `xml:"http://scap.nist.gov/schema/vulnerability/0.4 published-datetime"`
}
type nvdCVSS struct {
@ -64,6 +65,7 @@ func init() {
func (n nvdEntry) Metadata() *NVDMetadata {
metadata := &NVDMetadata{
CVSSv2: NVDmetadataCVSSv2{
PublishedDateTime: n.PublishedDateTime,
Vectors: n.CVSS.BaseMetrics.String(),
Score: n.CVSS.BaseMetrics.Score,
},