Skip to content

Commit 540937b

Browse files
committed
more NVD updates
1 parent be6e124 commit 540937b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/vulnloader/nvdloader/loader.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ func query(url string) (*apischema.CVEAPIJSON20, error) {
128128
if err != nil {
129129
return nil, fmt.Errorf("creating HTTP request: %w", err)
130130
}
131-
req.Header.Set("apiKey", os.Getenv("NVD_API_KEY"))
131+
if apiKey := os.Getenv("NVD_API_KEY"); apiKey != "" {
132+
req.Header.Set("apiKey", os.Getenv("NVD_API_KEY"))
133+
}
132134

133135
apiResp, err := queryWithBackoff(req)
134136
if err != nil {
@@ -153,8 +155,8 @@ func queryWithBackoff(req *http.Request) (*apischema.CVEAPIJSON20, error) {
153155
}
154156
}
155157
log.Warnf("Failed query attempt %d for %s: %v", i, req.URL.String(), err)
156-
// Wait some multiple of 3 seconds before next attempt.
157-
time.Sleep(time.Duration(3*i) * time.Second)
158+
// Wait some multiple of 6 seconds before next attempt.
159+
time.Sleep(time.Duration(6*i) * time.Second)
158160
}
159161

160162
return apiResp, err

0 commit comments

Comments
 (0)