Merge pull request #355 from hansjoachim/warnings

Warnings
This commit is contained in:
Jeremy Long
2015-09-13 19:31:16 -04:00
27 changed files with 57 additions and 43 deletions

View File

@@ -479,6 +479,7 @@ public class Engine implements FileFilter {
* @param file a file extension * @param file a file extension
* @return true or false depending on whether or not the file extension is supported * @return true or false depending on whether or not the file extension is supported
*/ */
@Override
public boolean accept(File file) { public boolean accept(File file) {
if (file == null) { if (file == null) {
return false; return false;

View File

@@ -75,6 +75,7 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
* *
* @return the name of the analyzer. * @return the name of the analyzer.
*/ */
@Override
public String getName() { public String getName() {
return ANALYZER_NAME; return ANALYZER_NAME;
} }
@@ -84,6 +85,7 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
* *
* @return the phase that the analyzer is intended to run in. * @return the phase that the analyzer is intended to run in.
*/ */
@Override
public AnalysisPhase getAnalysisPhase() { public AnalysisPhase getAnalysisPhase() {
return ANALYSIS_PHASE; return ANALYSIS_PHASE;
} }

View File

@@ -69,6 +69,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
* *
* @return the name of the analyzer. * @return the name of the analyzer.
*/ */
@Override
public String getName() { public String getName() {
return ANALYZER_NAME; return ANALYZER_NAME;
} }
@@ -78,6 +79,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
* *
* @return the phase that the analyzer is intended to run in. * @return the phase that the analyzer is intended to run in.
*/ */
@Override
public AnalysisPhase getAnalysisPhase() { public AnalysisPhase getAnalysisPhase() {
return ANALYSIS_PHASE; return ANALYSIS_PHASE;
} }
@@ -378,18 +380,16 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
*/ */
private void addFalseNegativeCPEs(Dependency dependency) { private void addFalseNegativeCPEs(Dependency dependency) {
//TODO move this to the hint analyzer //TODO move this to the hint analyzer
final Iterator<Identifier> itr = dependency.getIdentifiers().iterator(); for (final Identifier identifier : dependency.getIdentifiers()) {
while (itr.hasNext()) { if ("cpe".equals(identifier.getType()) && identifier.getValue() != null
final Identifier i = itr.next(); && (identifier.getValue().startsWith("cpe:/a:oracle:opensso:")
if ("cpe".equals(i.getType()) && i.getValue() != null || identifier.getValue().startsWith("cpe:/a:oracle:opensso_enterprise:")
&& (i.getValue().startsWith("cpe:/a:oracle:opensso:") || identifier.getValue().startsWith("cpe:/a:sun:opensso_enterprise:")
|| i.getValue().startsWith("cpe:/a:oracle:opensso_enterprise:") || identifier.getValue().startsWith("cpe:/a:sun:opensso:"))) {
|| i.getValue().startsWith("cpe:/a:sun:opensso_enterprise:") final String newCpe = String.format("cpe:/a:sun:opensso_enterprise:%s", identifier.getValue().substring(22));
|| i.getValue().startsWith("cpe:/a:sun:opensso:"))) { final String newCpe2 = String.format("cpe:/a:oracle:opensso_enterprise:%s", identifier.getValue().substring(22));
final String newCpe = String.format("cpe:/a:sun:opensso_enterprise:%s", i.getValue().substring(22)); final String newCpe3 = String.format("cpe:/a:sun:opensso:%s", identifier.getValue().substring(22));
final String newCpe2 = String.format("cpe:/a:oracle:opensso_enterprise:%s", i.getValue().substring(22)); final String newCpe4 = String.format("cpe:/a:oracle:opensso:%s", identifier.getValue().substring(22));
final String newCpe3 = String.format("cpe:/a:sun:opensso:%s", i.getValue().substring(22));
final String newCpe4 = String.format("cpe:/a:oracle:opensso:%s", i.getValue().substring(22));
try { try {
dependency.addIdentifier("cpe", dependency.addIdentifier("cpe",
newCpe, newCpe,

View File

@@ -48,6 +48,7 @@ public class FileNameAnalyzer extends AbstractAnalyzer implements Analyzer {
* *
* @return the name of the analyzer. * @return the name of the analyzer.
*/ */
@Override
public String getName() { public String getName() {
return ANALYZER_NAME; return ANALYZER_NAME;
} }
@@ -57,6 +58,7 @@ public class FileNameAnalyzer extends AbstractAnalyzer implements Analyzer {
* *
* @return the phase that the analyzer is intended to run in. * @return the phase that the analyzer is intended to run in.
*/ */
@Override
public AnalysisPhase getAnalysisPhase() { public AnalysisPhase getAnalysisPhase() {
return ANALYSIS_PHASE; return ANALYSIS_PHASE;
} }

View File

@@ -17,7 +17,6 @@
*/ */
package org.owasp.dependencycheck.analyzer; package org.owasp.dependencycheck.analyzer;
import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -195,6 +194,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* *
* @return the phase that the analyzer is intended to run in. * @return the phase that the analyzer is intended to run in.
*/ */
@Override
public AnalysisPhase getAnalysisPhase() { public AnalysisPhase getAnalysisPhase() {
return ANALYSIS_PHASE; return ANALYSIS_PHASE;
} }

View File

@@ -489,7 +489,7 @@ public class CveDB {
deleteReferences = getConnection().prepareStatement(statementBundle.getString("DELETE_REFERENCE")); deleteReferences = getConnection().prepareStatement(statementBundle.getString("DELETE_REFERENCE"));
deleteSoftware = getConnection().prepareStatement(statementBundle.getString("DELETE_SOFTWARE")); deleteSoftware = getConnection().prepareStatement(statementBundle.getString("DELETE_SOFTWARE"));
updateVulnerability = getConnection().prepareStatement(statementBundle.getString("UPDATE_VULNERABILITY")); updateVulnerability = getConnection().prepareStatement(statementBundle.getString("UPDATE_VULNERABILITY"));
final String ids[] = {"id"}; final String[] ids = {"id"};
insertVulnerability = getConnection().prepareStatement(statementBundle.getString("INSERT_VULNERABILITY"), insertVulnerability = getConnection().prepareStatement(statementBundle.getString("INSERT_VULNERABILITY"),
//Statement.RETURN_GENERATED_KEYS); //Statement.RETURN_GENERATED_KEYS);
ids); ids);

View File

@@ -115,7 +115,7 @@ class DriverShim implements Driver {
* @throws SQLFeatureNotSupportedException thrown if the feature is not supported * @throws SQLFeatureNotSupportedException thrown if the feature is not supported
* @see java.sql.Driver#getParentLogger() * @see java.sql.Driver#getParentLogger()
*/ */
//@Override @Override
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
//return driver.getParentLogger(); //return driver.getParentLogger();
Method m = null; Method m = null;

View File

@@ -697,6 +697,7 @@ public class Dependency implements Serializable, Comparable<Dependency> {
* @param o a dependency to compare * @param o a dependency to compare
* @return an integer representing the natural ordering * @return an integer representing the natural ordering
*/ */
@Override
public int compareTo(Dependency o) { public int compareTo(Dependency o) {
return this.getFilePath().compareToIgnoreCase(o.getFilePath()); return this.getFilePath().compareToIgnoreCase(o.getFilePath());
} }

View File

@@ -235,6 +235,7 @@ public class Evidence implements Serializable, Comparable<Evidence> {
* @param o the evidence being compared * @param o the evidence being compared
* @return an integer indicating the ordering of the two objects * @return an integer indicating the ordering of the two objects
*/ */
@Override
public int compareTo(Evidence o) { public int compareTo(Evidence o) {
if (o == null) { if (o == null) {
return 1; return 1;

View File

@@ -51,6 +51,7 @@ public class EvidenceCollection implements Serializable, Iterable<Evidence> {
* Used to iterate over highest confidence evidence contained in the collection. * Used to iterate over highest confidence evidence contained in the collection.
*/ */
private static final Filter<Evidence> HIGHEST_CONFIDENCE = new Filter<Evidence>() { private static final Filter<Evidence> HIGHEST_CONFIDENCE = new Filter<Evidence>() {
@Override
public boolean passes(Evidence evidence) { public boolean passes(Evidence evidence) {
return evidence.getConfidence() == Confidence.HIGHEST; return evidence.getConfidence() == Confidence.HIGHEST;
} }
@@ -59,6 +60,7 @@ public class EvidenceCollection implements Serializable, Iterable<Evidence> {
* Used to iterate over high confidence evidence contained in the collection. * Used to iterate over high confidence evidence contained in the collection.
*/ */
private static final Filter<Evidence> HIGH_CONFIDENCE = new Filter<Evidence>() { private static final Filter<Evidence> HIGH_CONFIDENCE = new Filter<Evidence>() {
@Override
public boolean passes(Evidence evidence) { public boolean passes(Evidence evidence) {
return evidence.getConfidence() == Confidence.HIGH; return evidence.getConfidence() == Confidence.HIGH;
} }
@@ -67,6 +69,7 @@ public class EvidenceCollection implements Serializable, Iterable<Evidence> {
* Used to iterate over medium confidence evidence contained in the collection. * Used to iterate over medium confidence evidence contained in the collection.
*/ */
private static final Filter<Evidence> MEDIUM_CONFIDENCE = new Filter<Evidence>() { private static final Filter<Evidence> MEDIUM_CONFIDENCE = new Filter<Evidence>() {
@Override
public boolean passes(Evidence evidence) { public boolean passes(Evidence evidence) {
return evidence.getConfidence() == Confidence.MEDIUM; return evidence.getConfidence() == Confidence.MEDIUM;
} }
@@ -75,6 +78,7 @@ public class EvidenceCollection implements Serializable, Iterable<Evidence> {
* Used to iterate over low confidence evidence contained in the collection. * Used to iterate over low confidence evidence contained in the collection.
*/ */
private static final Filter<Evidence> LOW_CONFIDENCE = new Filter<Evidence>() { private static final Filter<Evidence> LOW_CONFIDENCE = new Filter<Evidence>() {
@Override
public boolean passes(Evidence evidence) { public boolean passes(Evidence evidence) {
return evidence.getConfidence() == Confidence.LOW; return evidence.getConfidence() == Confidence.LOW;
} }
@@ -83,6 +87,7 @@ public class EvidenceCollection implements Serializable, Iterable<Evidence> {
* Used to iterate over evidence that has was used (aka read) from the collection. * Used to iterate over evidence that has was used (aka read) from the collection.
*/ */
private static final Filter<Evidence> EVIDENCE_USED = new Filter<Evidence>() { private static final Filter<Evidence> EVIDENCE_USED = new Filter<Evidence>() {
@Override
public boolean passes(Evidence evidence) { public boolean passes(Evidence evidence) {
return evidence.isUsed(); return evidence.isUsed();
} }
@@ -222,6 +227,7 @@ public class EvidenceCollection implements Serializable, Iterable<Evidence> {
* *
* @return an Iterator<Evidence>. * @return an Iterator<Evidence>.
*/ */
@Override
public Iterator<Evidence> iterator() { public Iterator<Evidence> iterator() {
return list.iterator(); return list.iterator();
} }

View File

@@ -221,6 +221,7 @@ public class Identifier implements Serializable, Comparable<Identifier> {
* @param o the object being compared * @param o the object being compared
* @return an integer indicating the ordering * @return an integer indicating the ordering
*/ */
@Override
public int compareTo(Identifier o) { public int compareTo(Identifier o) {
if (o == null) { if (o == null) {
return -1; return -1;

View File

@@ -133,6 +133,7 @@ public class Reference implements Serializable, Comparable<Reference> {
* @param o the Reference being compared * @param o the Reference being compared
* @return an integer indicating the ordering of the two objects * @return an integer indicating the ordering of the two objects
*/ */
@Override
public int compareTo(Reference o) { public int compareTo(Reference o) {
if (source.equals(o.source)) { if (source.equals(o.source)) {
if (name.equals(o.name)) { if (name.equals(o.name)) {

View File

@@ -390,6 +390,7 @@ public class Vulnerability implements Serializable, Comparable<Vulnerability> {
* @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than
* the specified vulnerability * the specified vulnerability
*/ */
@Override
public int compareTo(Vulnerability v) { public int compareTo(Vulnerability v) {
return v.getName().compareTo(this.getName()); return v.getName().compareTo(this.getName());
} }

View File

@@ -39,6 +39,7 @@ public class VulnerabilityComparator implements Comparator<Vulnerability>, Seria
* @param o2 a second vulnerability * @param o2 a second vulnerability
* @return the comparison * @return the comparison
*/ */
@Override
public int compare(Vulnerability o1, Vulnerability o2) { public int compare(Vulnerability o1, Vulnerability o2) {
return o2.getName().compareTo(o1.getName()); return o2.getName().compareTo(o1.getName());
} }

View File

@@ -46,6 +46,7 @@ public class VelocityLoggerRedirect implements LogChute {
* *
* @param rsvc the RuntimeServices * @param rsvc the RuntimeServices
*/ */
@Override
public void init(RuntimeServices rsvc) { public void init(RuntimeServices rsvc) {
// do nothing // do nothing
} }
@@ -57,6 +58,7 @@ public class VelocityLoggerRedirect implements LogChute {
* @param level the logging level * @param level the logging level
* @param message the message to be logged * @param message the message to be logged
*/ */
@Override
public void log(int level, String message) { public void log(int level, String message) {
switch (level) { switch (level) {
case TRACE_ID: case TRACE_ID:
@@ -87,6 +89,7 @@ public class VelocityLoggerRedirect implements LogChute {
* @param message the message to be logged * @param message the message to be logged
* @param t a throwable to log * @param t a throwable to log
*/ */
@Override
public void log(int level, String message, Throwable t) { public void log(int level, String message, Throwable t) {
switch (level) { switch (level) {
case TRACE_ID: case TRACE_ID:
@@ -115,6 +118,7 @@ public class VelocityLoggerRedirect implements LogChute {
* @param level the logging level * @param level the logging level
* @return true * @return true
*/ */
@Override
public boolean isLevelEnabled(int level) { public boolean isLevelEnabled(int level) {
return true; return true;
} }

View File

@@ -103,6 +103,7 @@ public class DependencyVersion implements Iterable<String>, Comparable<Dependenc
* *
* @return an iterator for the version parts * @return an iterator for the version parts
*/ */
@Override
public Iterator<String> iterator() { public Iterator<String> iterator() {
return versionParts.iterator(); return versionParts.iterator();
} }

View File

@@ -18,7 +18,6 @@
package org.owasp.dependencycheck.utils; package org.owasp.dependencycheck.utils;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.Closeable; import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -26,7 +25,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;

View File

@@ -23,6 +23,7 @@ public abstract class Filter<T> {
public Iterable<T> filter(final Iterable<T> iterable) { public Iterable<T> filter(final Iterable<T> iterable) {
return new Iterable<T>() { return new Iterable<T>() {
@Override
public Iterator<T> iterator() { public Iterator<T> iterator() {
return filter(iterable.iterator()); return filter(iterable.iterator());
} }
@@ -39,10 +40,12 @@ public abstract class Filter<T> {
toNext(); toNext();
} }
@Override
public boolean hasNext() { public boolean hasNext() {
return next != null; return next != null;
} }
@Override
public T next() { public T next() {
if (next == null) { if (next == null) {
throw new NoSuchElementException(); throw new NoSuchElementException();
@@ -52,6 +55,7 @@ public abstract class Filter<T> {
return returnValue; return returnValue;
} }
@Override
public void remove() { public void remove() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@@ -52,6 +52,7 @@ public class CMakeAnalyzerTest extends BaseDBTestCase {
* *
* @throws Exception if there is a problem * @throws Exception if there is a problem
*/ */
@Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();

View File

@@ -17,39 +17,14 @@
*/ */
package org.owasp.dependencycheck.data.cpe; package org.owasp.dependencycheck.data.cpe;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
/** /**
* *
* @author Jeremy Long * @author Jeremy Long
*/ */
public class IndexEntryTest extends TestCase { public class IndexEntryTest {
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
@Override
public void setUp() throws Exception {
super.setUp();
}
@After
@Override
public void tearDown() throws Exception {
super.tearDown();
}
/** /**
* Test of setName method, of class IndexEntry. * Test of setName method, of class IndexEntry.

View File

@@ -47,11 +47,13 @@ public class TokenPairConcatenatingFilterTest extends BaseTokenStreamTestCase {
public static void tearDownClass() { public static void tearDownClass() {
} }
@Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
} }
@Override
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
super.tearDown(); super.tearDown();

View File

@@ -64,6 +64,7 @@ public class FilterTest {
} }
private static final Filter<String> TEST_FILTER private static final Filter<String> TEST_FILTER
= new Filter<String>() { = new Filter<String>() {
@Override
public boolean passes(String str) { public boolean passes(String str) {
return str.contains("keep"); return str.contains("keep");
} }

View File

@@ -263,6 +263,7 @@ public class AggregateMojo extends BaseDependencyCheckMojo {
* @param locale the location * @param locale the location
* @return the report name * @return the report name
*/ */
@Override
public String getName(Locale locale) { public String getName(Locale locale) {
return "dependency-check:aggregate"; return "dependency-check:aggregate";
} }
@@ -273,6 +274,7 @@ public class AggregateMojo extends BaseDependencyCheckMojo {
* @param locale The Locale to get the description for * @param locale The Locale to get the description for
* @return the description * @return the description
*/ */
@Override
public String getDescription(Locale locale) { public String getDescription(Locale locale) {
return "Generates an aggregate report of all child Maven projects providing details on any " return "Generates an aggregate report of all child Maven projects providing details on any "
+ "published vulnerabilities within project dependencies. This report is a best " + "published vulnerabilities within project dependencies. This report is a best "

View File

@@ -352,6 +352,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
* @throws MavenReportException if a maven report exception occurs * @throws MavenReportException if a maven report exception occurs
* @deprecated use {@link #generate(org.apache.maven.doxia.sink.Sink, java.util.Locale)} instead. * @deprecated use {@link #generate(org.apache.maven.doxia.sink.Sink, java.util.Locale)} instead.
*/ */
@Override
@Deprecated @Deprecated
public final void generate(@SuppressWarnings("deprecation") org.codehaus.doxia.sink.Sink sink, Locale locale) throws MavenReportException { public final void generate(@SuppressWarnings("deprecation") org.codehaus.doxia.sink.Sink sink, Locale locale) throws MavenReportException {
generate((Sink) sink, locale); generate((Sink) sink, locale);
@@ -519,6 +520,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
* *
* @return the output name * @return the output name
*/ */
@Override
public String getOutputName() { public String getOutputName() {
if ("HTML".equalsIgnoreCase(this.format) || "ALL".equalsIgnoreCase(this.format)) { if ("HTML".equalsIgnoreCase(this.format) || "ALL".equalsIgnoreCase(this.format)) {
return "dependency-check-report"; return "dependency-check-report";
@@ -537,6 +539,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
* *
* @return the category name * @return the category name
*/ */
@Override
public String getCategoryName() { public String getCategoryName() {
return MavenReport.CATEGORY_PROJECT_REPORTS; return MavenReport.CATEGORY_PROJECT_REPORTS;
} }

View File

@@ -95,6 +95,7 @@ public class CheckMojo extends BaseDependencyCheckMojo {
* @param locale the location * @param locale the location
* @return the report name * @return the report name
*/ */
@Override
public String getName(Locale locale) { public String getName(Locale locale) {
return "dependency-check"; return "dependency-check";
} }
@@ -105,6 +106,7 @@ public class CheckMojo extends BaseDependencyCheckMojo {
* @param locale The Locale to get the description for * @param locale The Locale to get the description for
* @return the description * @return the description
*/ */
@Override
public String getDescription(Locale locale) { public String getDescription(Locale locale) {
return "Generates a report providing details on any published vulnerabilities within project dependencies. " return "Generates a report providing details on any published vulnerabilities within project dependencies. "
+ "This report is a best effort and may contain false positives and false negatives."; + "This report is a best effort and may contain false positives and false negatives.";

View File

@@ -89,6 +89,7 @@ public class PurgeMojo extends BaseDependencyCheckMojo {
* @param locale the location * @param locale the location
* @return the report name * @return the report name
*/ */
@Override
public String getName(Locale locale) { public String getName(Locale locale) {
return "dependency-check-purge"; return "dependency-check-purge";
} }
@@ -99,6 +100,7 @@ public class PurgeMojo extends BaseDependencyCheckMojo {
* @param locale The Locale to get the description for * @param locale The Locale to get the description for
* @return the description * @return the description
*/ */
@Override
public String getDescription(Locale locale) { public String getDescription(Locale locale) {
return "Purges the local cache of the NVD dataT."; return "Purges the local cache of the NVD dataT.";
} }

View File

@@ -78,6 +78,7 @@ public class UpdateMojo extends BaseDependencyCheckMojo {
* @param locale the location * @param locale the location
* @return the report name * @return the report name
*/ */
@Override
public String getName(Locale locale) { public String getName(Locale locale) {
return "dependency-check-update"; return "dependency-check-update";
} }
@@ -88,6 +89,7 @@ public class UpdateMojo extends BaseDependencyCheckMojo {
* @param locale The Locale to get the description for * @param locale The Locale to get the description for
* @return the description * @return the description
*/ */
@Override
public String getDescription(Locale locale) { public String getDescription(Locale locale) {
return "Updates the local cache of the NVD data from NIST."; return "Updates the local cache of the NVD data from NIST.";
} }