Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Update ¶
Update is a function that updates the NVD (National Vulnerability Database) by fetching the latest CVE (Common Vulnerabilities and Exposures) data. It takes a driver.Collection and a driver.Graph as parameters. The function retrieves the last modified date from the configuration, and if available, checks if it is older than 120 days compared to the current date. If the last modified date is older than 120 days, the function updates the start date to 120 days before the last modified date and sets the restart flag to true. The function then constructs the URL for fetching the CVE data from the NVD API based on the results per page, last modified start date, and current date. It makes an HTTP GET request to the constructed URL, including the NVD API key if available. The function reads the response body and unmarshals it into a struct representing the NVD statistics. It calculates the number of pages required to fetch all the CVE data based on the total number of results and the number of results per page. The function uses a progress bar to track the progress of downloading and processing the CVE data. It spawns multiple goroutines to download and process the CVE data concurrently, with a maximum number of goroutines based on the availability of the NVD API key. After downloading and processing each page of CVE data, the function waits for 35 seconds before proceeding to the next page. Finally, the function updates the last modified date in the configuration and, if the restart flag is set, recursively calls itself to continue updating the NVD data. If any error occurs during the update process, the function logs the error and returns it.