mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-20 08:14:44 +01:00
Changed order to prevent blocking, CallableDownloadTasks automatically submit the results to the process executor queue now
Former-commit-id: 536fd58f195fd46de16d56064453409d0e39536b
This commit is contained in:
@@ -19,12 +19,14 @@
|
|||||||
package org.owasp.dependencycheck.data.update;
|
package org.owasp.dependencycheck.data.update;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import org.owasp.dependencycheck.data.UpdateException;
|
||||||
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
||||||
import org.owasp.dependencycheck.utils.DownloadFailedException;
|
import org.owasp.dependencycheck.utils.DownloadFailedException;
|
||||||
import org.owasp.dependencycheck.utils.Downloader;
|
import org.owasp.dependencycheck.utils.Downloader;
|
||||||
@@ -40,15 +42,22 @@ public class CallableDownloadTask implements Callable<Future<ProcessTask>> {
|
|||||||
* Simple constructor for the callable download task.
|
* Simple constructor for the callable download task.
|
||||||
*
|
*
|
||||||
* @param nvdCveInfo the NVD CVE info
|
* @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 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, 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.nvdCveInfo = nvdCveInfo;
|
||||||
this.first = first;
|
this.first = file1;
|
||||||
this.second = second;
|
this.second = file2;
|
||||||
this.processorService = processor;
|
this.processorService = processor;
|
||||||
this.cveDB = cveDB;
|
this.cveDB = cveDB;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
|||||||
@@ -148,15 +148,7 @@ public class StandardUpdate {
|
|||||||
final Set<Future<Future<ProcessTask>>> downloadFutures = new HashSet<Future<Future<ProcessTask>>>(maxUpdates);
|
final Set<Future<Future<ProcessTask>>> downloadFutures = new HashSet<Future<Future<ProcessTask>>>(maxUpdates);
|
||||||
for (NvdCveInfo cve : updateable) {
|
for (NvdCveInfo cve : updateable) {
|
||||||
if (cve.getNeedsUpdate()) {
|
if (cve.getNeedsUpdate()) {
|
||||||
final File file1;
|
final CallableDownloadTask call = new CallableDownloadTask(cve, processExecutor, cveDB, properties);
|
||||||
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);
|
|
||||||
downloadFutures.add(downloadExecutors.submit(call));
|
downloadFutures.add(downloadExecutors.submit(call));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user