diff --git a/dependency-check-ant/pom.xml b/dependency-check-ant/pom.xml
index 19cd62adb..59af44b24 100644
--- a/dependency-check-ant/pom.xml
+++ b/dependency-check-ant/pom.xml
@@ -20,7 +20,7 @@ Copyright (c) 2013 - Jeremy Long. All Rights Reserved.
org.owaspdependency-check-parent
- 1.2.6-SNAPSHOT
+ 1.2.6dependency-check-ant
diff --git a/dependency-check-cli/pom.xml b/dependency-check-cli/pom.xml
index c89fbe155..96b2d11c6 100644
--- a/dependency-check-cli/pom.xml
+++ b/dependency-check-cli/pom.xml
@@ -20,7 +20,7 @@ Copyright (c) 2012 - Jeremy Long. All Rights Reserved.
org.owaspdependency-check-parent
- 1.2.6-SNAPSHOT
+ 1.2.6dependency-check-cli
@@ -286,12 +286,12 @@ Copyright (c) 2012 - Jeremy Long. All Rights Reserved.
org.codehaus.mojoappassembler-maven-plugin
- 1.7
+ 1.8.1org.owasp.dependencycheck.App
- dependency-check
+ dependency-check${project.build.directory}/release
diff --git a/dependency-check-cli/src/main/assembly/release.xml b/dependency-check-cli/src/main/assembly/release.xml
index 7ebf60d62..a2dd05d87 100644
--- a/dependency-check-cli/src/main/assembly/release.xml
+++ b/dependency-check-cli/src/main/assembly/release.xml
@@ -2,10 +2,8 @@
release
diff --git a/dependency-check-core/pom.xml b/dependency-check-core/pom.xml
index 8512ae327..b64f35368 100644
--- a/dependency-check-core/pom.xml
+++ b/dependency-check-core/pom.xml
@@ -20,7 +20,7 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
org.owaspdependency-check-parent
- 1.2.6-SNAPSHOT
+ 1.2.6dependency-check-core
@@ -419,6 +419,12 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
4.3.1test
+
com.google.code.findbugsannotations
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java
index ac18ec90a..e59d6c77c 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java
@@ -120,9 +120,11 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
// Try evacuating the error stream
rdr = new BufferedReader(new InputStreamReader(proc.getErrorStream(), "UTF-8"));
String line = null;
+ // CheckStyle:VisibilityModifier OFF
while (rdr.ready() && (line = rdr.readLine()) != null) {
LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.stderr", line);
}
+ // CheckStyle:VisibilityModifier ON
int rc = 0;
doc = builder.parse(proc.getInputStream());
@@ -233,9 +235,11 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
final Process p = pb.start();
// Try evacuating the error stream
rdr = new BufferedReader(new InputStreamReader(p.getErrorStream(), "UTF-8"));
+ // CheckStyle:VisibilityModifier OFF
while (rdr.ready() && rdr.readLine() != null) {
// We expect this to complain
}
+ // CheckStyle:VisibilityModifier ON
final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(p.getInputStream());
final XPath xpath = XPathFactory.newInstance().newXPath();
final String error = xpath.evaluate("/assembly/error", doc);
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java
index ade039960..b062359c4 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java
@@ -1,14 +1,22 @@
+/*
+ * This file is part of dependency-check-core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (c) 2014 Jeremy Long. All Rights Reserved.
+ */
package org.owasp.dependencycheck.analyzer;
-import org.owasp.dependencycheck.Engine;
-import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
-import org.owasp.dependencycheck.data.nexus.MavenArtifact;
-import org.owasp.dependencycheck.data.central.CentralSearch;
-import org.owasp.dependencycheck.dependency.Confidence;
-import org.owasp.dependencycheck.dependency.Dependency;
-import org.owasp.dependencycheck.utils.InvalidSettingException;
-import org.owasp.dependencycheck.utils.Settings;
-
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
@@ -16,11 +24,23 @@ import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.owasp.dependencycheck.Engine;
+import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
+import org.owasp.dependencycheck.data.central.CentralSearch;
+import org.owasp.dependencycheck.data.nexus.MavenArtifact;
+import org.owasp.dependencycheck.dependency.Confidence;
+import org.owasp.dependencycheck.dependency.Dependency;
+import org.owasp.dependencycheck.utils.InvalidSettingException;
+import org.owasp.dependencycheck.utils.Settings;
/**
- * Created by colezlaw on 10/9/14.
+ * Analyzer which will attempt to locate a dependency, and the GAV information, by querying Central for the dependency's
+ * SHA-1 digest.
+ *
+ * @author colezlaw
*/
public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
+
/**
* The logger.
*/
@@ -29,7 +49,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The name of the analyzer.
*/
- private static final String ANALYZER_NAME = "Central Analyzer";
+ private static final String ANALYZER_NAME = "Central Analyzer";
/**
* The phase in which this analyzer runs.
@@ -42,16 +62,21 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
private static final Set SUPPORTED_EXTENSIONS = newHashSet("jar");
/**
- * The analyzer should be disabled if there are errors, so this is a flag
- * to determine if such an error has occurred.
+ * The analyzer should be disabled if there are errors, so this is a flag to determine if such an error has
+ * occurred.
*/
- protected boolean errorFlag = false;
+ private boolean errorFlag = false;
/**
* The searcher itself.
*/
private CentralSearch searcher;
+ /**
+ * Field indicating if the analyzer is enabled.
+ */
+ private final boolean enabled = checkEnabled();
+
/**
* Determine whether to enable this analyzer or not.
*
@@ -59,6 +84,15 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
*/
@Override
public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Determines if this analyzer is enabled.
+ *
+ * @return true if the analyzer is enabled; otherwise false
+ */
+ private boolean checkEnabled() {
boolean retval = false;
try {
@@ -68,7 +102,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
LOGGER.info("Enabling the Central analyzer");
retval = true;
} else {
- LOGGER.info("Nexus analyzer is enabled, disabling Central");
+ LOGGER.info("Nexus analyzer is enabled, disabling the Central Analyzer");
}
} else {
LOGGER.info("Central analyzer disabled");
@@ -76,14 +110,13 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
} catch (InvalidSettingException ise) {
LOGGER.warning("Invalid setting. Disabling the Central analyzer");
}
-
return retval;
}
/**
* Initializes the analyzer once before any analysis is performed.
*
- * @throws Exception if there's an error during initalization
+ * @throws Exception if there's an error during initialization
*/
@Override
public void initializeFileTypeAnalyzer() throws Exception {
@@ -106,7 +139,8 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
return ANALYZER_NAME;
}
- /** Returns the key used in the properties file to to reference the analyzer's enabled property.
+ /**
+ * Returns the key used in the properties file to to reference the analyzer's enabled property.
*
* @return the analyzer's enabled property setting key.
*/
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java
index 22db369ad..0da7a5147 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java
@@ -24,7 +24,6 @@ import java.net.URL;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-
import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
import org.owasp.dependencycheck.data.nexus.MavenArtifact;
@@ -34,8 +33,6 @@ import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.utils.InvalidSettingException;
import org.owasp.dependencycheck.utils.Settings;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
/**
* Analyzer which will attempt to locate a dependency on a Nexus service by SHA-1 digest of the dependency.
*
@@ -51,6 +48,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
* @author colezlaw
*/
public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
+
/**
* The default URL - this will be used by the CentralAnalyzer to determine whether to enable this.
*/
@@ -82,24 +80,28 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
private NexusSearch searcher;
/**
- * Determine whether to enable this analyzer or not.
- *
- * @return whether the analyzer should be enabled
+ * Field indicating if the analyzer is enabled.
*/
- @Override
- public boolean isEnabled() {
+ private final boolean enabled = checkEnabled();
+
+ /**
+ * Determines if this analyzer is enabled
+ *
+ * @return true if the analyzer is enabled; otherwise false
+ */
+ private boolean checkEnabled() {
/* Enable this analyzer ONLY if the Nexus URL has been set to something
- other than the default one (if it's the default one, we'll use the
- central one) and it's enabled by the user.
+ other than the default one (if it's the default one, we'll use the
+ central one) and it's enabled by the user.
*/
boolean retval = false;
try {
- if ((! DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL)))
- && Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)) {
+ if ((!DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL)))
+ && Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)) {
LOGGER.info("Enabling Nexus analyzer");
retval = true;
} else {
- LOGGER.info("Nexus analyzer disabled");
+ LOGGER.info("Nexus analyzer disabled, using Central instead");
}
} catch (InvalidSettingException ise) {
LOGGER.warning("Invalid setting. Disabling Nexus analyzer");
@@ -108,6 +110,16 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
return retval;
}
+ /**
+ * Determine whether to enable this analyzer or not.
+ *
+ * @return whether the analyzer should be enabled
+ */
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
/**
* Initializes the analyzer once before any analysis is performed.
*
@@ -184,7 +196,7 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
*/
@Override
public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException {
- if (! isEnabled()) {
+ if (!isEnabled()) {
return;
}
try {
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java
index 8977d13e7..fb6d86a1d 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java
@@ -1,17 +1,22 @@
+/*
+ * This file is part of dependency-check-core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (c) 2014 Jeremy Long. All Rights Reserved.
+ */
package org.owasp.dependencycheck.data.central;
-import org.owasp.dependencycheck.data.nexus.MavenArtifact;
-import org.owasp.dependencycheck.utils.InvalidSettingException;
-import org.owasp.dependencycheck.utils.Settings;
-import org.owasp.dependencycheck.utils.URLConnectionFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
@@ -19,6 +24,16 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+import org.owasp.dependencycheck.data.nexus.MavenArtifact;
+import org.owasp.dependencycheck.utils.Settings;
+import org.owasp.dependencycheck.utils.URLConnectionFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
/**
* Class of methods to search Maven Central via Central.
@@ -26,6 +41,7 @@ import java.util.logging.Logger;
* @author colezlaw
*/
public class CentralSearch {
+
/**
* The URL for the Central service
*/
@@ -41,17 +57,11 @@ public class CentralSearch {
*/
private static final Logger LOGGER = Logger.getLogger(CentralSearch.class.getName());
- /**
- * Determines whether we'll continue using the analyzer. If there's some sort
- * of HTTP failure, we'll disable the analyzer.
- */
- private boolean isEnabled = true;
-
/**
* Creates a NexusSearch for the given repository URL.
*
- * @param rootURL the URL of the repository on which searches should execute.
- * Only parameters are added to this (so it should end in /select)
+ * @param rootURL the URL of the repository on which searches should execute. Only parameters are added to this (so
+ * it should end in /select)
*/
public CentralSearch(URL rootURL) {
this.rootURL = rootURL;
@@ -70,8 +80,8 @@ public class CentralSearch {
*
* @param sha1 the SHA-1 hash string for which to search
* @return the populated Maven GAV.
- * @throws IOException if it's unable to connect to the specified repository or if
- * the specified artifact is not found.
+ * @throws IOException if it's unable to connect to the specified repository or if the specified artifact is not
+ * found.
*/
public List searchSha1(String sha1) throws IOException {
if (null == sha1 || !sha1.matches("^[0-9A-Fa-f]{40}$")) {
@@ -80,7 +90,7 @@ public class CentralSearch {
final URL url = new URL(rootURL + String.format("?q=1:\"%s\"&wt=xml", sha1));
- LOGGER.info(String.format("Searching Central url %s", url.toString()));
+ LOGGER.fine(String.format("Searching Central url %s", url.toString()));
// Determine if we need to use a proxy. The rules:
// 1) If the proxy is set, AND the setting is set to true, use the proxy
@@ -106,8 +116,8 @@ public class CentralSearch {
if ("0".equals(numFound)) {
missing = true;
} else {
- ArrayList result = new ArrayList();
- NodeList docs = (NodeList)xpath.evaluate("/response/result/doc", doc, XPathConstants.NODESET);
+ final ArrayList result = new ArrayList();
+ final NodeList docs = (NodeList) xpath.evaluate("/response/result/doc", doc, XPathConstants.NODESET);
for (int i = 0; i < docs.getLength(); i++) {
final String g = xpath.evaluate("./str[@name='g']", docs.item(i));
LOGGER.finest(String.format("GroupId: %s", g));
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/package-info.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/package-info.java
new file mode 100644
index 000000000..9b51647d6
--- /dev/null
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/package-info.java
@@ -0,0 +1,14 @@
+/**
+ *
+ *
+ * org.owasp.dependencycheck.data.central
+ *
+ *
+ *
+ * Contains classes related to searching Maven Central.
+ *
+ * These are used to abstract Maven Central searching away from OWASP Dependency Check so they can be reused elsewhere.
+ *
+ *
+ */
+package org.owasp.dependencycheck.data.central;
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java
index fa35d5eb3..857abb6cc 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java
@@ -54,6 +54,7 @@ import org.owasp.dependencycheck.utils.Pair;
* @author Jeremy Long
*/
public final class CpeMemoryIndex {
+
/**
* The logger.
*/
@@ -160,7 +161,7 @@ public final class CpeMemoryIndex {
*/
@SuppressWarnings("unchecked")
private Analyzer createSearchingAnalyzer() {
- final Map fieldAnalyzers = new HashMap();
+ final Map fieldAnalyzers = new HashMap();
fieldAnalyzers.put(Fields.DOCUMENT_KEY, new KeywordAnalyzer());
productSearchFieldAnalyzer = new SearchFieldAnalyzer(LuceneUtils.CURRENT_VERSION);
vendorSearchFieldAnalyzer = new SearchFieldAnalyzer(LuceneUtils.CURRENT_VERSION);
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java
index da6b2ae58..461f1a030 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java
@@ -306,14 +306,14 @@ public class CveDB {
* @throws DatabaseException thrown when there is an error retrieving the data from the DB
*/
public Set> getVendorProductList() throws DatabaseException {
- final HashSet data = new HashSet>();
+ final Set> data = new HashSet>();
ResultSet rs = null;
PreparedStatement ps = null;
try {
ps = getConnection().prepareStatement(SELECT_VENDOR_PRODUCT_LIST);
rs = ps.executeQuery();
while (rs.next()) {
- data.add(new Pair(rs.getString(1), rs.getString(2)));
+ data.add(new Pair(rs.getString(1), rs.getString(2)));
}
} catch (SQLException ex) {
final String msg = "An unexpected SQL Exception occurred; please see the verbose log for more details.";
@@ -731,7 +731,7 @@ public class CveDB {
* @param previous a flag indicating if previous versions of the product are vulnerable
* @return true if the identified version is affected, otherwise false
*/
- private boolean isAffected(String vendor, String product, DependencyVersion identifiedVersion, String cpeId, String previous) {
+ protected boolean isAffected(String vendor, String product, DependencyVersion identifiedVersion, String cpeId, String previous) {
boolean affected = false;
final boolean isStruts = "apache".equals(vendor) && "struts".equals(product);
final DependencyVersion v = parseDependencyVersion(cpeId);
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java
index cadcb2ae6..a4261abfe 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DatabaseProperties.java
@@ -142,8 +142,8 @@ public class DatabaseProperties {
*
* @return a map of the database meta data
*/
- public Map getMetaData() {
- final TreeMap map = new TreeMap();
+ public Map getMetaData() {
+ final TreeMap map = new TreeMap();
for (Entry