Skip to content

Commit

Permalink
Changed resolution strategy to 'gather, then add additional identifie…
Browse files Browse the repository at this point in the history
…rs' instead of a defensive copy
  • Loading branch information
aikebah committed Aug 31, 2021
1 parent edbddd9 commit 24ff2e8
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,8 @@ private void removeWrongVersionMatches(Dependency dependency) {
private void addFalseNegativeCPEs(Dependency dependency) {
final CpeBuilder builder = new CpeBuilder();
//TODO move this to the hint analyzer
// defensive copu for #3618 as I do not have access projects with opensso / opensso_enterprise
// to validate that a move of rules to the hint analyzer will result in the desired effects
List<Identifier> currentVulnSwIds = new ArrayList<>(dependency.getVulnerableSoftwareIdentifiers());
currentVulnSwIds.stream()
List<Identifier> identifiersToAdd = new ArrayList<>();
dependency.getVulnerableSoftwareIdentifiers().stream()
.filter((i) -> (i instanceof CpeIdentifier))
.map(i -> (CpeIdentifier) i)
.forEach((i) -> {
Expand All @@ -440,10 +438,10 @@ private void addFalseNegativeCPEs(Dependency dependency) {
final CpeIdentifier newCpeId2 = new CpeIdentifier(newCpe2, i.getConfidence());
final CpeIdentifier newCpeId3 = new CpeIdentifier(newCpe3, i.getConfidence());
final CpeIdentifier newCpeId4 = new CpeIdentifier(newCpe4, i.getConfidence());
dependency.addVulnerableSoftwareIdentifier(newCpeId1);
dependency.addVulnerableSoftwareIdentifier(newCpeId2);
dependency.addVulnerableSoftwareIdentifier(newCpeId3);
dependency.addVulnerableSoftwareIdentifier(newCpeId4);
identifiersToAdd.add(newCpeId1);
identifiersToAdd.add(newCpeId2);
identifiersToAdd.add(newCpeId3);
identifiersToAdd.add(newCpeId4);

} catch (CpeValidationException ex) {
LOGGER.warn("Unable to add oracle and sun CPEs", ex);
Expand All @@ -454,12 +452,13 @@ private void addFalseNegativeCPEs(Dependency dependency) {
final Cpe newCpe1 = builder.part(Part.APPLICATION).vendor("apache")
.product("xml_security_for_java").version(cpe.getVersion()).build();
final CpeIdentifier newCpeId1 = new CpeIdentifier(newCpe1, i.getConfidence());
dependency.addVulnerableSoftwareIdentifier(newCpeId1);
identifiersToAdd.add(newCpeId1);
} catch (CpeValidationException ex) {
LOGGER.warn("Unable to add apache xml_security_for_java CPE", ex);
}
}
});
identifiersToAdd.forEach(dependency::addVulnerableSoftwareIdentifier);
}

/**
Expand Down

0 comments on commit 24ff2e8

Please sign in to comment.