Skip to content

Commit

Permalink
fixes #4685
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylong committed Jul 27, 2022
1 parent 422ea5c commit 47f5f5a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
Expand Up @@ -113,7 +113,12 @@ protected void analyzeDependency(Dependency dependency, Engine engine) throws An
if (rules.isEmpty()) {
return;
}
rules.forEach((rule) -> rule.process(dependency));
rules.forEach((rule) -> {
rule.process(dependency);
if (!rule.isMatched() && !rule.isBase()) {
LOGGER.debug("Suppression Rule had zero matches: {}", rule.toString());
}
});
}

/**
Expand Down
Expand Up @@ -103,6 +103,29 @@ public class SuppressionRule {
*/
private Calendar until;

/**
* A flag whether or not the rule matched a dependency & CPE.
*/
private boolean matched = false;

/**
* Get the value of matched.
*
* @return the value of matched
*/
public boolean isMatched() {
return matched;
}

/**
* Set the value of matched.
*
* @param matched new value of matched
*/
public void setMatched(boolean matched) {
this.matched = matched;
}

/**
* Get the (@code{nullable}) value of until.
*
Expand Down Expand Up @@ -467,6 +490,7 @@ public void process(Dependency dependency) {
for (PropertyType c : this.cpe) {
if (identifierMatches(c, i)) {
if (!isBase()) {
matched = true;
if (this.notes != null) {
i.setNotes(this.notes);
}
Expand Down Expand Up @@ -507,7 +531,6 @@ public void process(Dependency dependency) {
removeVulns.add(v);
break;
}

}
}
if (!remove) {
Expand All @@ -524,13 +547,12 @@ public void process(Dependency dependency) {
}
}
}
if (remove) {
if (!isBase()) {
if (this.notes != null) {
v.setNotes(this.notes);
}
dependency.addSuppressedVulnerability(v);
if (remove && !isBase()) {
matched = true;
if (this.notes != null) {
v.setNotes(this.notes);
}
dependency.addSuppressedVulnerability(v);
}
}
removeVulns.forEach((v) -> {
Expand Down Expand Up @@ -646,6 +668,9 @@ public String toString() {
if (sha1 != null) {
sb.append("sha1=").append(sha1).append(',');
}
if (packageUrl != null) {
sb.append("packageUrl=").append(packageUrl).append(',');
}
if (gav != null) {
sb.append("gav=").append(gav).append(',');
}
Expand Down

0 comments on commit 47f5f5a

Please sign in to comment.