Merge branch 'master' of github.com:jeremylong/DependencyCheck

This commit is contained in:
Jeremy Long
2015-11-22 07:31:27 -05:00
9 changed files with 21 additions and 31 deletions

View File

@@ -26,7 +26,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
@@ -416,12 +415,10 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
FileOutputStream fos = null; FileOutputStream fos = null;
try { try {
final File parent = file.getParentFile(); final File parent = file.getParentFile();
if (!parent.isDirectory()) { if (!parent.isDirectory() && !parent.mkdirs()) {
if (!parent.mkdirs()) {
final String msg = String.format("Unable to build directory '%s'.", parent.getAbsolutePath()); final String msg = String.format("Unable to build directory '%s'.", parent.getAbsolutePath());
throw new AnalysisException(msg); throw new AnalysisException(msg);
} }
}
fos = new FileOutputStream(file); fos = new FileOutputStream(file);
IOUtils.copy(input, fos); IOUtils.copy(input, fos);
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {

View File

@@ -104,7 +104,7 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
*/ */
boolean retval = false; boolean retval = false;
try { try {
if ((!DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL))) if (!DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL))
&& Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)) { && Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)) {
LOGGER.info("Enabling Nexus analyzer"); LOGGER.info("Enabling Nexus analyzer");
retval = true; retval = true;

View File

@@ -73,7 +73,7 @@ public class NvdCveAnalyzer implements Analyzer {
* @return true or false. * @return true or false.
*/ */
public boolean isOpen() { public boolean isOpen() {
return (cveDB != null); return cveDB != null;
} }
/** /**

View File

@@ -27,7 +27,6 @@ import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.logging.Level;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.owasp.dependencycheck.utils.DBUtils; import org.owasp.dependencycheck.utils.DBUtils;
import org.owasp.dependencycheck.utils.DependencyVersion; import org.owasp.dependencycheck.utils.DependencyVersion;
@@ -302,7 +301,7 @@ public final class ConnectionFactory {
Statement statement = null; Statement statement = null;
try { try {
statement = conn.createStatement(); statement = conn.createStatement();
boolean success = statement.execute(dbStructureUpdate); final boolean success = statement.execute(dbStructureUpdate);
if (!success && statement.getUpdateCount() <= 0) { if (!success && statement.getUpdateCount() <= 0) {
throw new DatabaseException(String.format("Unable to upgrade the database schema to %s", schema)); throw new DatabaseException(String.format("Unable to upgrade the database schema to %s", schema));
} }

View File

@@ -182,14 +182,12 @@ public final class ExtractionUtil {
while ((entry = input.getNextEntry()) != null) { while ((entry = input.getNextEntry()) != null) {
if (entry.isDirectory()) { if (entry.isDirectory()) {
final File dir = new File(destination, entry.getName()); final File dir = new File(destination, entry.getName());
if (!dir.exists()) { if (!dir.exists() && !dir.mkdirs()) {
if (!dir.mkdirs()) {
final String msg = String.format( final String msg = String.format(
"Unable to create directory '%s'.", "Unable to create directory '%s'.",
dir.getAbsolutePath()); dir.getAbsolutePath());
throw new AnalysisException(msg); throw new AnalysisException(msg);
} }
}
} else { } else {
extractFile(input, destination, filter, entry); extractFile(input, destination, filter, entry);
} }
@@ -264,13 +262,11 @@ public final class ExtractionUtil {
private static void createParentFile(final File file) private static void createParentFile(final File file)
throws ExtractionException { throws ExtractionException {
final File parent = file.getParentFile(); final File parent = file.getParentFile();
if (!parent.isDirectory()) { if (!parent.isDirectory() && !parent.mkdirs()) {
if (!parent.mkdirs()) {
final String msg = String.format( final String msg = String.format(
"Unable to build directory '%s'.", "Unable to build directory '%s'.",
parent.getAbsolutePath()); parent.getAbsolutePath());
throw new ExtractionException(msg); throw new ExtractionException(msg);
} }
} }
}
} }

View File

@@ -174,7 +174,7 @@ public class AggregateMojo extends BaseDependencyCheckMojo {
} }
} }
} }
Set<MavenProject> addedDescendants = new HashSet<MavenProject>(); final Set<MavenProject> addedDescendants = new HashSet<MavenProject>();
for (MavenProject dec : descendants) { for (MavenProject dec : descendants) {
for (String mod : dec.getModules()) { for (String mod : dec.getModules()) {
try { try {

View File

@@ -26,7 +26,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;

View File

@@ -52,7 +52,6 @@ public final class URLConnectionFactory {
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE", justification = "Just being extra safe") @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE", justification = "Just being extra safe")
public static HttpURLConnection createHttpURLConnection(URL url) throws URLConnectionFailureException { public static HttpURLConnection createHttpURLConnection(URL url) throws URLConnectionFailureException {
HttpURLConnection conn = null; HttpURLConnection conn = null;
Proxy proxy;
final String proxyUrl = Settings.getString(Settings.KEYS.PROXY_SERVER); final String proxyUrl = Settings.getString(Settings.KEYS.PROXY_SERVER);
try { try {
if (proxyUrl != null) { if (proxyUrl != null) {
@@ -74,7 +73,7 @@ public final class URLConnectionFactory {
Authenticator.setDefault(auth); Authenticator.setDefault(auth);
} }
proxy = new Proxy(Proxy.Type.HTTP, address); final Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
conn = (HttpURLConnection) url.openConnection(proxy); conn = (HttpURLConnection) url.openConnection(proxy);
} else { } else {
conn = (HttpURLConnection) url.openConnection(); conn = (HttpURLConnection) url.openConnection();

View File

@@ -127,7 +127,7 @@ Copyright (c) 2012 - Jeremy Long
<!-- new versions of lucene are compiled with JDK 1.7 and cannot be used ubiquitously in Jenkins <!-- new versions of lucene are compiled with JDK 1.7 and cannot be used ubiquitously in Jenkins
thus, we cannot upgrade beyond 4.7.2 --> thus, we cannot upgrade beyond 4.7.2 -->
<apache.lucene.version>4.7.2</apache.lucene.version> <apache.lucene.version>4.7.2</apache.lucene.version>
<slf4j.version>1.7.12</slf4j.version> <slf4j.version>1.7.13</slf4j.version>
<logback.version>1.1.3</logback.version> <logback.version>1.1.3</logback.version>
<reporting.checkstyle-plugin.version>2.17</reporting.checkstyle-plugin.version> <reporting.checkstyle-plugin.version>2.17</reporting.checkstyle-plugin.version>
<reporting.cobertura-plugin.version>2.7</reporting.cobertura-plugin.version> <reporting.cobertura-plugin.version>2.7</reporting.cobertura-plugin.version>
@@ -475,7 +475,7 @@ Copyright (c) 2012 - Jeremy Long
<dependency> <dependency>
<groupId>com.google.code.findbugs</groupId> <groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId> <artifactId>annotations</artifactId>
<version>3.0.0</version> <version>3.0.1u2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
@@ -607,7 +607,7 @@ Copyright (c) 2012 - Jeremy Long
<dependency> <dependency>
<groupId>org.jmockit</groupId> <groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId> <artifactId>jmockit</artifactId>
<version>1.19</version> <version>1.20</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>