Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent ConcurrentModificationException on addFalseNegativeCPEs #3619

Merged
merged 3 commits into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ private void removeWrongVersionMatches(Dependency dependency) {
private void addFalseNegativeCPEs(Dependency dependency) {
final CpeBuilder builder = new CpeBuilder();
//TODO move this to the hint analyzer
final List<Identifier> identifiersToAdd = new ArrayList<>();
dependency.getVulnerableSoftwareIdentifiers().stream()
.filter((i) -> (i instanceof CpeIdentifier))
.map(i -> (CpeIdentifier) i)
Expand All @@ -437,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 @@ -451,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