Merge branch 'master' of github.com:bkimminich/DependencyCheck into bkimminich-master

Former-commit-id: 4b8d77255bef86d4cb4243eefd80eedadf5ca8f7
This commit is contained in:
Jeremy Long
2014-04-19 08:22:47 -04:00

View File

@@ -69,6 +69,8 @@ import org.owasp.dependencycheck.utils.Settings;
requiresOnline = true) requiresOnline = true)
public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageReport { public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageReport {
private final Logger logger = Logger.getLogger(DependencyCheckMojo.class.getName());
/** /**
* The properties file location. * The properties file location.
*/ */
@@ -200,7 +202,7 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
@Parameter(property = "connectionTimeout", defaultValue = "", required = false) @Parameter(property = "connectionTimeout", defaultValue = "", required = false)
private String connectionTimeout = null; private String connectionTimeout = null;
/** /**
* The Connection Timeout. * The path to the suppression file.
*/ */
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"}) @SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
@Parameter(property = "suppressionFile", defaultValue = "", required = false) @Parameter(property = "suppressionFile", defaultValue = "", required = false)
@@ -393,7 +395,7 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
cve.open(); cve.open();
prop = cve.getDatabaseProperties(); prop = cve.getDatabaseProperties();
} catch (DatabaseException ex) { } catch (DatabaseException ex) {
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.FINE, "Unable to retrieve DB Properties", ex); logger.log(Level.FINE, "Unable to retrieve DB Properties", ex);
} finally { } finally {
if (cve != null) { if (cve != null) {
cve.close(); cve.close();
@@ -403,13 +405,13 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
try { try {
r.generateReports(outDirectory.getCanonicalPath(), format); r.generateReports(outDirectory.getCanonicalPath(), format);
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.SEVERE, logger.log(Level.SEVERE,
"Unexpected exception occurred during analysis; please see the verbose error log for more details."); "Unexpected exception occurred during analysis; please see the verbose error log for more details.");
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.FINE, null, ex); logger.log(Level.FINE, null, ex);
} catch (Throwable ex) { } catch (Throwable ex) {
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.SEVERE, logger.log(Level.SEVERE,
"Unexpected exception occurred during analysis; please see the verbose error log for more details."); "Unexpected exception occurred during analysis; please see the verbose error log for more details.");
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.FINE, null, ex); logger.log(Level.FINE, null, ex);
} }
} }
@@ -816,14 +818,14 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
mojoProperties = this.getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE); mojoProperties = this.getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE);
Settings.mergeProperties(mojoProperties); Settings.mergeProperties(mojoProperties);
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.WARNING, "Unable to load the dependency-check ant task.properties file."); logger.log(Level.WARNING, "Unable to load the dependency-check ant task.properties file.");
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.FINE, null, ex); logger.log(Level.FINE, null, ex);
} finally { } finally {
if (mojoProperties != null) { if (mojoProperties != null) {
try { try {
mojoProperties.close(); mojoProperties.close();
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.FINEST, null, ex); logger.log(Level.FINEST, null, ex);
} }
} }
} }
@@ -943,9 +945,9 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
checkForFailure(engine.getDependencies()); checkForFailure(engine.getDependencies());
} }
} catch (DatabaseException ex) { } catch (DatabaseException ex) {
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.SEVERE, logger.log(Level.SEVERE,
"Unable to connect to the dependency-check database; analysis has stopped"); "Unable to connect to the dependency-check database; analysis has stopped");
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.FINE, "", ex); logger.log(Level.FINE, "", ex);
} finally { } finally {
Settings.cleanup(); Settings.cleanup();
if (engine != null) { if (engine != null) {
@@ -984,9 +986,9 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
generateMavenSiteReport(engine, sink); generateMavenSiteReport(engine, sink);
} }
} catch (DatabaseException ex) { } catch (DatabaseException ex) {
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.SEVERE, logger.log(Level.SEVERE,
"Unable to connect to the dependency-check database; analysis has stopped"); "Unable to connect to the dependency-check database; analysis has stopped");
Logger.getLogger(DependencyCheckMojo.class.getName()).log(Level.FINE, "", ex); logger.log(Level.FINE, "", ex);
} finally { } finally {
Settings.cleanup(); Settings.cleanup();
if (engine != null) { if (engine != null) {
@@ -1010,8 +1012,7 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
} else if ("VULN".equalsIgnoreCase(this.format)) { } else if ("VULN".equalsIgnoreCase(this.format)) {
return "dependency-check-vulnerability"; return "dependency-check-vulnerability";
} else { } else {
Logger.getLogger(DependencyCheckMojo.class logger.log(Level.WARNING, "Unknown report format used during site generatation.");
.getName()).log(Level.WARNING, "Unknown report format used during site generatation.");
return "dependency-check-report"; return "dependency-check-report";
} }
} }
@@ -1149,9 +1150,7 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
final String msg = String.format("%n%n" final String msg = String.format("%n%n"
+ "One or more dependencies were identified with known vulnerabilities:%n%n%s" + "One or more dependencies were identified with known vulnerabilities:%n%n%s"
+ "%n%nSee the dependency-check report for more details.%n%n", summary.toString()); + "%n%nSee the dependency-check report for more details.%n%n", summary.toString());
Logger logger.log(Level.WARNING, msg);
.getLogger(DependencyCheckMojo.class
.getName()).log(Level.WARNING, msg);
} }
} }
} }