mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-15 16:23:37 +01:00
location of data files is no longer the working directory, rather the location of the JAR file itself
Former-commit-id: b3f83447f9422618d6db60d49488830381787110
This commit is contained in:
@@ -28,6 +28,7 @@ import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -75,7 +76,11 @@ public class Index extends AbstractIndex implements CachedWebDataSource {
|
||||
*/
|
||||
public Directory getDirectory() throws IOException {
|
||||
String fileName = Settings.getString(Settings.KEYS.CPE_INDEX);
|
||||
File path = new File(fileName);
|
||||
String filePath = Index.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
String decodedPath = URLDecoder.decode(filePath, "UTF-8");
|
||||
|
||||
File path = new File(decodedPath + File.separator + fileName);
|
||||
path = new File(path.getCanonicalPath());
|
||||
Directory dir = FSDirectory.open(path);
|
||||
|
||||
return dir;
|
||||
|
||||
@@ -21,6 +21,7 @@ package org.codesecure.dependencycheck.data.nvdcve;
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -73,8 +74,13 @@ public class Index extends AbstractIndex implements CachedWebDataSource {
|
||||
*/
|
||||
public Directory getDirectory() throws IOException {
|
||||
String fileName = Settings.getString(Settings.KEYS.CVE_INDEX);
|
||||
File path = new File(fileName);
|
||||
String filePath = Index.class.getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
String decodedPath = URLDecoder.decode(filePath, "UTF-8");
|
||||
|
||||
File path = new File(decodedPath + File.separator + fileName);
|
||||
path = new File(path.getCanonicalPath());
|
||||
Directory dir = FSDirectory.open(path);
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user