Skip to content

Commit 2261cf1

Browse files
authored
Update SuppressionRule.java
1 parent 5521cfe commit 2261cf1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

core/src/main/java/org/owasp/dependencycheck/xml/suppression/SuppressionRule.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,27 @@ protected boolean purlMatches(PropertyType suppressionEntry, Identifier identifi
262262
protected boolean identifierMatches(PropertyType suppressionEntry, Identifier identifier) {
263263
if (identifier instanceof PurlIdentifier) {
264264
return suppressionEntry.matches(((PurlIdentifier) identifier).toGav());
265-
} else if (identifier instanceof CpeIdentifier) {
266-
try {
267-
String cpeVal = ((CpeIdentifier) identifier).getCpe().toCpe22Uri();
268-
return suppressionEntry.isRegex()
269-
? suppressionEntry.matches(cpeVal)
270-
: cpeVal.toLowerCase().startsWith(
271-
suppressionEntry.getValue().toLowerCase().replaceAll(":$", "")
272-
);
265+
} {
266+
try {
267+
String cpeVal = ((CpeIdentifier) identifier).getCpe().toCpe22Uri();
268+
269+
if (suppressionEntry.isRegex()) {
270+
return suppressionEntry.matches(cpeVal);
271+
}
272+
273+
String ruleVal = suppressionEntry.getValue();
274+
String rulePrefix = ruleVal.replaceAll(":$", "");
275+
276+
if (suppressionEntry.isCaseSensitive()) {
277+
return cpeVal.startsWith(rulePrefix);
278+
} else {
279+
return cpeVal.toLowerCase().startsWith(rulePrefix.toLowerCase());
280+
}
281+
282+
} catch (CpeEncodingException ex) {
283+
LOGGER.debug("Unable to convert CPE", ex);
284+
}
285+
}
273286
} catch (CpeEncodingException ex) {
274287
LOGGER.debug("Unable to convert CPE", ex);
275288
}

0 commit comments

Comments
 (0)