From e5235bd714d9abc5a3e7d03b34ab71e4c0d0589a Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Sat, 26 Oct 2013 17:21:14 -0400 Subject: [PATCH] added false positive checks for axis vs axis2 Former-commit-id: 69bcb7c2921fe3713c3ad548cd2ceb101b3c0ce2 --- .../analyzer/FalsePositiveAnalyzer.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java index 9c64495a6..b84acd74f 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java @@ -109,6 +109,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer { public void analyze(Dependency dependency, Engine engine) throws AnalysisException { removeJreEntries(dependency); removeBadMatches(dependency); + removeWrongVersionMatches(dependency); removeSpuriousCPE(dependency); addFalseNegativeCPEs(dependency); } @@ -291,6 +292,40 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer { } } + /** + * Removes CPE matches for the wrong version of a dependency. Currently, + * this only covers Axis 1 & 2. + * + * @param dependency the dependency to analyze + */ + private void removeWrongVersionMatches(Dependency dependency) { + final Set identifiers = dependency.getIdentifiers(); + final Iterator itr = identifiers.iterator(); + + final String fileName = dependency.getFileName(); + if (fileName != null && fileName.contains("axis2")) { + while (itr.hasNext()) { + final Identifier i = itr.next(); + if ("cpe".equals(i.getType())) { + final String cpe = i.getValue(); + if (cpe != null && (cpe.startsWith("cpe:/a:apache:axis:") || "cpe:/a:apache:axis".equals(cpe))) { + itr.remove(); + } + } + } + } else if (fileName != null && fileName.contains("axis")) { + while (itr.hasNext()) { + final Identifier i = itr.next(); + if ("cpe".equals(i.getType())) { + final String cpe = i.getValue(); + if (cpe != null && (cpe.startsWith("cpe:/a:apache:axis2:") || "cpe:/a:apache:axis2".equals(cpe))) { + itr.remove(); + } + } + } + } + } + /** * There are some known CPE entries, specifically regarding sun and oracle * products due to the acquisition and changes in product names, that based