package nvdmirror // // Sync NVD data files to destination directory based on given sync // configuration and cache. // // Returns an array of file names which have been updated in the // destination directory. // // This function does the following: // // 1. Fetch the contents of the source meta URLs for CVE feeds and // CPE matches. All source URLs are fetched concurrently. // // 2. Check the size and hash from meta files against the existing // CVE feed and CPE match files in the destination directory. All // file sizes and hashes are checked concurrently. // // 3. Build a list of changed CVE feeds and CPE match files. // // 4. Append the CPE dictionary, CISA KEVC URL, and the CWE list URL. // // 5. Fetch the contents of changed URLs. See note below about HTTP // request headers. // // 6. Return an array of updated files. // // Note: All HTTP requests in steps #1 and #5 above are sent with the // following headers: // // * if-modified-since: The last-modified header from the previous // successful response, if it was set. // // * if-none-match: The etag header from the last successful response, // if it was set. // // * user-agent: User agent from config, or the default user agent if // the config value is unspecified. // func Sync(config SyncConfig, cache Cache, dstDir string) []string { // build sync context ctx := newSyncContext(config, cache, dstDir) // fetch meta files, check for updates, append cpe dictionary URL, // fetch updated files, and then return a list of changed files return ctx.syncUrls(append( ctx.checkMetas(ctx.fetchMetas()), config.GetCpeDictUrl(), config.GetCisaKevcUrl(), config.GetCweListUrl(), )) }