mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-18 07:14:09 +01:00
Updated as properties moved to the DB
Former-commit-id: 5b9f503949b4a7d4a03e313bf60ff756d7c18b2d
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.owasp.dependencycheck.data.update;
|
package org.owasp.dependencycheck.data.update;
|
||||||
|
|
||||||
|
import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -45,27 +46,30 @@ public class CallableDownloadTask implements Callable<Future<ProcessTask>> {
|
|||||||
* @param processor the processor service to submit the downloaded files to
|
* @param processor the processor service to submit the downloaded files to
|
||||||
* @param cveDB the CVE DB to use to store the vulnerability data
|
* @param cveDB the CVE DB to use to store the vulnerability data
|
||||||
*/
|
*/
|
||||||
public CallableDownloadTask(NvdCveInfo nvdCveInfo, ExecutorService processor, CveDB cveDB, DataStoreMetaInfo properties) throws UpdateException {
|
public CallableDownloadTask(NvdCveInfo nvdCveInfo, ExecutorService processor, CveDB cveDB) {
|
||||||
|
this.nvdCveInfo = nvdCveInfo;
|
||||||
|
this.processorService = processor;
|
||||||
|
this.cveDB = cveDB;
|
||||||
|
this.properties = cveDB.getDatabaseProperties();
|
||||||
|
|
||||||
final File file1;
|
final File file1;
|
||||||
final File file2;
|
final File file2;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
file1 = File.createTempFile("cve" + nvdCveInfo.getId() + "_", ".xml");
|
file1 = File.createTempFile("cve" + nvdCveInfo.getId() + "_", ".xml");
|
||||||
file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + "_", ".xml");
|
file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + "_", ".xml");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UpdateException(ex);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nvdCveInfo = nvdCveInfo;
|
|
||||||
this.first = file1;
|
this.first = file1;
|
||||||
this.second = file2;
|
this.second = file2;
|
||||||
this.processorService = processor;
|
|
||||||
this.cveDB = cveDB;
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The DataStoreMeta information.
|
* The DataStoreMeta information.
|
||||||
*/
|
*/
|
||||||
private DataStoreMetaInfo properties;
|
private DatabaseProperties properties;
|
||||||
/**
|
/**
|
||||||
* The CVE DB to use when processing the files.
|
* The CVE DB to use when processing the files.
|
||||||
*/
|
*/
|
||||||
@@ -170,15 +174,25 @@ public class CallableDownloadTask implements Callable<Future<ProcessTask>> {
|
|||||||
final URL url2 = new URL(nvdCveInfo.getOldSchemaVersionUrl());
|
final URL url2 = new URL(nvdCveInfo.getOldSchemaVersionUrl());
|
||||||
String msg = String.format("Download Started for NVD CVE - %s", nvdCveInfo.getId());
|
String msg = String.format("Download Started for NVD CVE - %s", nvdCveInfo.getId());
|
||||||
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.INFO, msg);
|
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.INFO, msg);
|
||||||
Downloader.fetchFile(url1, first);
|
try {
|
||||||
Downloader.fetchFile(url2, second);
|
Downloader.fetchFile(url1, first);
|
||||||
|
Downloader.fetchFile(url2, second);
|
||||||
|
} catch (DownloadFailedException ex) {
|
||||||
|
msg = String.format("Download Failed for NVD CVE - %s%nSome CVEs may not be reported.", nvdCveInfo.getId());
|
||||||
|
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.WARNING, msg);
|
||||||
|
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.FINE, null, ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
msg = String.format("Download Complete for NVD CVE - %s", nvdCveInfo.getId());
|
msg = String.format("Download Complete for NVD CVE - %s", nvdCveInfo.getId());
|
||||||
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.INFO, msg);
|
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.INFO, msg);
|
||||||
|
|
||||||
final ProcessTask task = new ProcessTask(cveDB, properties, this);
|
final ProcessTask task = new ProcessTask(cveDB, properties, this);
|
||||||
return this.processorService.submit(task);
|
return this.processorService.submit(task);
|
||||||
|
|
||||||
} catch (DownloadFailedException ex) {
|
} catch (Throwable ex) {
|
||||||
|
final String msg = String.format("An exception occured downloading NVD CVE - %s%nSome CVEs may not be reported.", nvdCveInfo.getId());
|
||||||
|
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.WARNING, msg);
|
||||||
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.FINE, "Download Task Failed", ex);
|
Logger.getLogger(CallableDownloadTask.class.getName()).log(Level.FINE, "Download Task Failed", ex);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user