Skip to content

Commit 4de2e8f

Browse files
committed
fix: validation
1 parent 63f90c3 commit 4de2e8f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

core/src/main/java/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,19 @@ private void loadPackagedSuppressionBaseData(final SuppressionParser parser, fin
204204
LOGGER.warn("Base suppression rules `{}}` could not be loaded; {}", BASE_SUPPRESSION_FILE, e.getMessage());
205205
return;
206206
}
207-
URL loc = AbstractSuppressionAnalyzer.class.getProtectionDomain().getCodeSource().getLocation();
208-
String jarPath = loc.getFile();
207+
URL jarLocation = AbstractSuppressionAnalyzer.class.getProtectionDomain().getCodeSource().getLocation();
208+
209209
URL validUrl = null;
210210
while (urls.hasNext()) {
211+
String validationBase = jarLocation.getFile();
211212
URL url = urls.next();
212213
String path = url.toString();
213-
if (path.equals("jar:" + jarPath + "!/dependencycheck-base-suppression.xml")) {
214+
if (path.startsWith("file:")) {
215+
validationBase = "file:" + validationBase + "dependencycheck-base-suppression.xml";
216+
} else {
217+
validationBase = "jar:file:" + validationBase + "!/dependencycheck-base-suppression.xml";
218+
}
219+
if (validationBase.equals(path)) {
214220
validUrl = url;
215221
break;
216222
}
@@ -224,6 +230,8 @@ private void loadPackagedSuppressionBaseData(final SuppressionParser parser, fin
224230
} catch (SAXException | IOException ex) {
225231
throw new SuppressionParseException("Unable to parse the base suppression data file", ex);
226232
}
233+
} else {
234+
throw new SuppressionParseException("Unable to load the base suppression data file");
227235
}
228236
if (ruleList != null && !ruleList.isEmpty()) {
229237
if (engine.hasObject(SUPPRESSION_OBJECT_KEY)) {

0 commit comments

Comments
 (0)