mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-26 19:11:29 +01:00
Merge pull request #349 from hansjoachim/warnings
Fixes various warnings
This commit is contained in:
@@ -37,7 +37,6 @@ import org.owasp.dependencycheck.utils.Settings;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import ch.qos.logback.core.FileAppender;
|
import ch.qos.logback.core.FileAppender;
|
||||||
import java.util.logging.Level;
|
|
||||||
import org.slf4j.impl.StaticLoggerBinder;
|
import org.slf4j.impl.StaticLoggerBinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.owasp.dependencycheck;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.CommandLineParser;
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import java.util.EnumMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +60,7 @@ public class Engine implements FileFilter {
|
|||||||
/**
|
/**
|
||||||
* A Map of analyzers grouped by Analysis phase.
|
* A Map of analyzers grouped by Analysis phase.
|
||||||
*/
|
*/
|
||||||
private EnumMap<AnalysisPhase, List<Analyzer>> analyzers = new EnumMap<AnalysisPhase, List<Analyzer>>(AnalysisPhase.class);
|
private Map<AnalysisPhase, List<Analyzer>> analyzers = new EnumMap<AnalysisPhase, List<Analyzer>>(AnalysisPhase.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Map of analyzers grouped by Analysis phase.
|
* A Map of analyzers grouped by Analysis phase.
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class CentralSearch {
|
|||||||
if ("0".equals(numFound)) {
|
if ("0".equals(numFound)) {
|
||||||
missing = true;
|
missing = true;
|
||||||
} else {
|
} else {
|
||||||
final ArrayList<MavenArtifact> result = new ArrayList<MavenArtifact>();
|
final List<MavenArtifact> result = new ArrayList<MavenArtifact>();
|
||||||
final NodeList docs = (NodeList) xpath.evaluate("/response/result/doc", doc, XPathConstants.NODESET);
|
final NodeList docs = (NodeList) xpath.evaluate("/response/result/doc", doc, XPathConstants.NODESET);
|
||||||
for (int i = 0; i < docs.getLength(); i++) {
|
for (int i = 0; i < docs.getLength(); i++) {
|
||||||
final String g = xpath.evaluate("./str[@name='g']", docs.item(i));
|
final String g = xpath.evaluate("./str[@name='g']", docs.item(i));
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -45,21 +46,21 @@ public final class CweDB {
|
|||||||
/**
|
/**
|
||||||
* A HashMap of the CWE data.
|
* A HashMap of the CWE data.
|
||||||
*/
|
*/
|
||||||
private static final HashMap<String, String> CWE = loadData();
|
private static final Map<String, String> CWE = loadData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a HashMap containing the CWE data from a resource found in the jar.
|
* Loads a HashMap containing the CWE data from a resource found in the jar.
|
||||||
*
|
*
|
||||||
* @return a HashMap of CWE data
|
* @return a HashMap of CWE data
|
||||||
*/
|
*/
|
||||||
private static HashMap<String, String> loadData() {
|
private static Map<String, String> loadData() {
|
||||||
ObjectInputStream oin = null;
|
ObjectInputStream oin = null;
|
||||||
try {
|
try {
|
||||||
final String filePath = "data/cwe.hashmap.serialized";
|
final String filePath = "data/cwe.hashmap.serialized";
|
||||||
final InputStream input = CweDB.class.getClassLoader().getResourceAsStream(filePath);
|
final InputStream input = CweDB.class.getClassLoader().getResourceAsStream(filePath);
|
||||||
oin = new ObjectInputStream(input);
|
oin = new ObjectInputStream(input);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final HashMap<String, String> ret = (HashMap<String, String>) oin.readObject();
|
final Map<String, String> ret = (HashMap<String, String>) oin.readObject();
|
||||||
return ret;
|
return ret;
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
LOGGER.warn("Unable to load CWE data. This should not be an issue.");
|
LOGGER.warn("Unable to load CWE data. This should not be an issue.");
|
||||||
|
|||||||
@@ -17,14 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.owasp.dependencycheck.analyzer;
|
package org.owasp.dependencycheck.analyzer;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.owasp.dependencycheck.BaseTest;
|
|
||||||
import org.owasp.dependencycheck.Engine;
|
|
||||||
import org.owasp.dependencycheck.data.cpe.AbstractDatabaseTestCase;
|
import org.owasp.dependencycheck.data.cpe.AbstractDatabaseTestCase;
|
||||||
import org.owasp.dependencycheck.dependency.Dependency;
|
|
||||||
import org.owasp.dependencycheck.utils.Settings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import org.owasp.dependencycheck.dependency.Dependency;
|
|||||||
import org.owasp.dependencycheck.dependency.Evidence;
|
import org.owasp.dependencycheck.dependency.Evidence;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.owasp.dependencycheck.data.nuget;
|
package org.owasp.dependencycheck.data.nuget;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.owasp.dependencycheck.data.nvdcve;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
@@ -121,7 +122,7 @@ public class CveDBIntegrationTest extends BaseDBTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetMatchingSoftware() throws Exception {
|
public void testGetMatchingSoftware() throws Exception {
|
||||||
CveDB instance = null;
|
CveDB instance = null;
|
||||||
HashMap<String, Boolean> versions = new HashMap<String, Boolean>();
|
Map<String, Boolean> versions = new HashMap<String, Boolean>();
|
||||||
DependencyVersion identifiedVersion = new DependencyVersion("1.0.1o");
|
DependencyVersion identifiedVersion = new DependencyVersion("1.0.1o");
|
||||||
versions.put("cpe:/a:openssl:openssl:1.0.1e", Boolean.FALSE);
|
versions.put("cpe:/a:openssl:openssl:1.0.1e", Boolean.FALSE);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -15,12 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.owasp.dependencycheck.data.update;
|
package org.owasp.dependencycheck.data.update;
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.owasp.dependencycheck.BaseTest;
|
import org.owasp.dependencycheck.BaseTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,13 +20,9 @@ package org.owasp.dependencycheck.suppression;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.owasp.dependencycheck.BaseTest;
|
import org.owasp.dependencycheck.BaseTest;
|
||||||
import org.owasp.dependencycheck.dependency.Dependency;
|
import org.owasp.dependencycheck.dependency.Dependency;
|
||||||
@@ -40,25 +36,6 @@ import org.owasp.dependencycheck.dependency.Vulnerability;
|
|||||||
*/
|
*/
|
||||||
public class SuppressionRuleTest {
|
public class SuppressionRuleTest {
|
||||||
|
|
||||||
public SuppressionRuleTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUpClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void tearDownClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//<editor-fold defaultstate="collapsed" desc="Stupid tests of properties">
|
//<editor-fold defaultstate="collapsed" desc="Stupid tests of properties">
|
||||||
/**
|
/**
|
||||||
* Test of FilePath property, of class SuppressionRule.
|
* Test of FilePath property, of class SuppressionRule.
|
||||||
@@ -91,7 +68,7 @@ public class SuppressionRuleTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCpe() {
|
public void testCpe() {
|
||||||
SuppressionRule instance = new SuppressionRule();
|
SuppressionRule instance = new SuppressionRule();
|
||||||
ArrayList<PropertyType> cpe = new ArrayList<PropertyType>();
|
List<PropertyType> cpe = new ArrayList<PropertyType>();
|
||||||
instance.setCpe(cpe);
|
instance.setCpe(cpe);
|
||||||
assertFalse(instance.hasCpe());
|
assertFalse(instance.hasCpe());
|
||||||
PropertyType pt = new PropertyType();
|
PropertyType pt = new PropertyType();
|
||||||
@@ -109,7 +86,7 @@ public class SuppressionRuleTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetCvssBelow() {
|
public void testGetCvssBelow() {
|
||||||
SuppressionRule instance = new SuppressionRule();
|
SuppressionRule instance = new SuppressionRule();
|
||||||
ArrayList<Float> cvss = new ArrayList<Float>();
|
List<Float> cvss = new ArrayList<Float>();
|
||||||
instance.setCvssBelow(cvss);
|
instance.setCvssBelow(cvss);
|
||||||
assertFalse(instance.hasCvssBelow());
|
assertFalse(instance.hasCvssBelow());
|
||||||
instance.addCvssBelow(0.7f);
|
instance.addCvssBelow(0.7f);
|
||||||
@@ -124,7 +101,7 @@ public class SuppressionRuleTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCwe() {
|
public void testCwe() {
|
||||||
SuppressionRule instance = new SuppressionRule();
|
SuppressionRule instance = new SuppressionRule();
|
||||||
ArrayList<String> cwe = new ArrayList<String>();
|
List<String> cwe = new ArrayList<String>();
|
||||||
instance.setCwe(cwe);
|
instance.setCwe(cwe);
|
||||||
assertFalse(instance.hasCwe());
|
assertFalse(instance.hasCwe());
|
||||||
instance.addCwe("2");
|
instance.addCwe("2");
|
||||||
@@ -139,7 +116,7 @@ public class SuppressionRuleTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCve() {
|
public void testCve() {
|
||||||
SuppressionRule instance = new SuppressionRule();
|
SuppressionRule instance = new SuppressionRule();
|
||||||
ArrayList<String> cve = new ArrayList<String>();
|
List<String> cve = new ArrayList<String>();
|
||||||
instance.setCve(cve);
|
instance.setCve(cve);
|
||||||
assertFalse(instance.hasCve());
|
assertFalse(instance.hasCve());
|
||||||
instance.addCve("CVE-2013-1337");
|
instance.addCve("CVE-2013-1337");
|
||||||
|
|||||||
@@ -20,13 +20,9 @@ package org.owasp.dependencycheck.utils;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,25 +31,6 @@ import org.junit.Test;
|
|||||||
*/
|
*/
|
||||||
public class DependencyVersionTest {
|
public class DependencyVersionTest {
|
||||||
|
|
||||||
public DependencyVersionTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUpClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void tearDownClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of parseVersion method, of class DependencyVersion.
|
* Test of parseVersion method, of class DependencyVersion.
|
||||||
*/
|
*/
|
||||||
@@ -73,6 +50,7 @@ public class DependencyVersionTest {
|
|||||||
assertEquals(2, parts.size());
|
assertEquals(2, parts.size());
|
||||||
assertEquals("x6", parts.get(0));
|
assertEquals("x6", parts.get(0));
|
||||||
assertEquals("0", parts.get(1));
|
assertEquals("0", parts.get(1));
|
||||||
|
// TODO(code review): should this be here/do something?
|
||||||
//assertEquals("0", parts.get(2));
|
//assertEquals("0", parts.get(2));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -84,6 +62,7 @@ public class DependencyVersionTest {
|
|||||||
public void testIterator() {
|
public void testIterator() {
|
||||||
DependencyVersion instance = new DependencyVersion("1.2.3");
|
DependencyVersion instance = new DependencyVersion("1.2.3");
|
||||||
Iterator result = instance.iterator();
|
Iterator result = instance.iterator();
|
||||||
|
assertTrue(result.hasNext());
|
||||||
int count = 1;
|
int count = 1;
|
||||||
while (result.hasNext()) {
|
while (result.hasNext()) {
|
||||||
String v = (String) result.next();
|
String v = (String) result.next();
|
||||||
@@ -155,7 +134,6 @@ public class DependencyVersionTest {
|
|||||||
public void testCompareTo() {
|
public void testCompareTo() {
|
||||||
DependencyVersion instance = new DependencyVersion("1.2.3");
|
DependencyVersion instance = new DependencyVersion("1.2.3");
|
||||||
DependencyVersion version = new DependencyVersion("1.2.3");
|
DependencyVersion version = new DependencyVersion("1.2.3");
|
||||||
int expResult = 0;
|
|
||||||
assertEquals(0, instance.compareTo(version));
|
assertEquals(0, instance.compareTo(version));
|
||||||
version = new DependencyVersion("1.1");
|
version = new DependencyVersion("1.1");
|
||||||
assertEquals(1, instance.compareTo(version));
|
assertEquals(1, instance.compareTo(version));
|
||||||
@@ -204,7 +182,7 @@ public class DependencyVersionTest {
|
|||||||
DependencyVersion instance = new DependencyVersion();
|
DependencyVersion instance = new DependencyVersion();
|
||||||
List<String> versionParts = Arrays.asList("1", "1", "1");
|
List<String> versionParts = Arrays.asList("1", "1", "1");
|
||||||
instance.setVersionParts(versionParts);
|
instance.setVersionParts(versionParts);
|
||||||
List<String> expResult = Arrays.asList("1", "1", "1");;
|
List<String> expResult = Arrays.asList("1", "1", "1");
|
||||||
List<String> result = instance.getVersionParts();
|
List<String> result = instance.getVersionParts();
|
||||||
assertEquals(expResult, result);
|
assertEquals(expResult, result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,7 @@ package org.owasp.dependencycheck.xml.pom;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|||||||
@@ -15,18 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.owasp.dependencycheck.xml.pom;
|
package org.owasp.dependencycheck.xml.pom;
|
||||||
|
|
||||||
import org.owasp.dependencycheck.xml.pom.PomUtils;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import javax.xml.transform.sax.SAXSource;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.owasp.dependencycheck.BaseTest;
|
import org.owasp.dependencycheck.BaseTest;
|
||||||
import org.owasp.dependencycheck.dependency.Dependency;
|
|
||||||
import org.owasp.dependencycheck.xml.pom.Model;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -34,25 +27,6 @@ import org.owasp.dependencycheck.xml.pom.Model;
|
|||||||
*/
|
*/
|
||||||
public class PomUtilsTest {
|
public class PomUtilsTest {
|
||||||
|
|
||||||
public PomUtilsTest() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUpClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
public static void tearDownClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test of readPom method, of class PomUtils.
|
* Test of readPom method, of class PomUtils.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import org.junit.Rule;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
import org.owasp.dependencycheck.utils.Checksum;
|
import org.owasp.dependencycheck.utils.Checksum;
|
||||||
import org.owasp.dependencycheck.utils.Checksum;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user