mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-13 23:33:37 +01:00
Changed order to prevent blocking, CallableDownloadTasks automatically submit the results to the process executor queue now
Former-commit-id: a6671690125a13045e93e40a95c033b8f99cf391
This commit is contained in:
@@ -19,12 +19,14 @@
|
||||
package org.owasp.dependencycheck.data.update;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.owasp.dependencycheck.data.UpdateException;
|
||||
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
||||
import org.owasp.dependencycheck.utils.DownloadFailedException;
|
||||
import org.owasp.dependencycheck.utils.Downloader;
|
||||
@@ -40,15 +42,22 @@ public class CallableDownloadTask implements Callable<Future<ProcessTask>> {
|
||||
* Simple constructor for the callable download task.
|
||||
*
|
||||
* @param nvdCveInfo the NVD CVE info
|
||||
* @param first the first file
|
||||
* @param second the second file
|
||||
* @param processor the processor service to submit the downloaded files to
|
||||
* @param cveDB the CVE DB to use to store the vulnerability data
|
||||
*/
|
||||
public CallableDownloadTask(NvdCveInfo nvdCveInfo, File first, File second, ExecutorService processor, CveDB cveDB, DataStoreMetaInfo properties) {
|
||||
public CallableDownloadTask(NvdCveInfo nvdCveInfo, ExecutorService processor, CveDB cveDB, DataStoreMetaInfo properties) throws UpdateException {
|
||||
final File file1;
|
||||
final File file2;
|
||||
try {
|
||||
file1 = File.createTempFile("cve" + nvdCveInfo.getId() + "_", ".xml");
|
||||
file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + "_", ".xml");
|
||||
} catch (IOException ex) {
|
||||
throw new UpdateException(ex);
|
||||
}
|
||||
|
||||
this.nvdCveInfo = nvdCveInfo;
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
this.first = file1;
|
||||
this.second = file2;
|
||||
this.processorService = processor;
|
||||
this.cveDB = cveDB;
|
||||
this.properties = properties;
|
||||
|
||||
@@ -148,15 +148,7 @@ public class StandardUpdate {
|
||||
final Set<Future<Future<ProcessTask>>> downloadFutures = new HashSet<Future<Future<ProcessTask>>>(maxUpdates);
|
||||
for (NvdCveInfo cve : updateable) {
|
||||
if (cve.getNeedsUpdate()) {
|
||||
final File file1;
|
||||
final File file2;
|
||||
try {
|
||||
file1 = File.createTempFile("cve" + cve.getId() + "_", ".xml");
|
||||
file2 = File.createTempFile("cve_1_2_" + cve.getId() + "_", ".xml");
|
||||
} catch (IOException ex) {
|
||||
throw new UpdateException(ex);
|
||||
}
|
||||
final CallableDownloadTask call = new CallableDownloadTask(cve, file1, file2, processExecutor, cveDB, properties);
|
||||
final CallableDownloadTask call = new CallableDownloadTask(cve, processExecutor, cveDB, properties);
|
||||
downloadFutures.add(downloadExecutors.submit(call));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user