Former-commit-id: 7a189b5240ff2c831c6d6f42555148f5f00586bd
This commit is contained in:
Jeremy Long
2015-02-22 10:24:59 -05:00
18 changed files with 55 additions and 49 deletions

View File

@@ -140,7 +140,7 @@ public final class CliParser {
throw new FileNotFoundException(msg); throw new FileNotFoundException(msg);
} else if (!path.contains("*") && !path.contains("?")) { } else if (!path.contains("*") && !path.contains("?")) {
File f = new File(path); File f = new File(path);
if ("o".equals(argumentName.substring(0, 1).toLowerCase()) && !"ALL".equals(this.getReportFormat().toUpperCase())) { if ("o".equalsIgnoreCase(argumentName.substring(0, 1)) && !"ALL".equalsIgnoreCase(this.getReportFormat())) {
final String checkPath = path.toLowerCase(); final String checkPath = path.toLowerCase();
if (checkPath.endsWith(".html") || checkPath.endsWith(".xml") || checkPath.endsWith(".htm")) { if (checkPath.endsWith(".html") || checkPath.endsWith(".xml") || checkPath.endsWith(".htm")) {
if (f.getParentFile() == null) { if (f.getParentFile() == null) {

View File

@@ -116,7 +116,7 @@ public class Engine {
* Loads the analyzers specified in the configuration file (or system properties). * Loads the analyzers specified in the configuration file (or system properties).
*/ */
private void loadAnalyzers() { private void loadAnalyzers() {
if (analyzers.size() > 0) { if (!analyzers.isEmpty()) {
return; return;
} }
for (AnalysisPhase phase : AnalysisPhase.values()) { for (AnalysisPhase phase : AnalysisPhase.values()) {

View File

@@ -110,7 +110,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
static { static {
final String additionalZipExt = Settings.getString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS); final String additionalZipExt = Settings.getString(Settings.KEYS.ADDITIONAL_ZIP_EXTENSIONS);
if (additionalZipExt != null) { if (additionalZipExt != null) {
final HashSet<String> ext = new HashSet<String>(Arrays.asList(additionalZipExt)); final Set<String> ext = new HashSet<String>(Arrays.asList(additionalZipExt));
ZIPPABLES.addAll(ext); ZIPPABLES.addAll(ext);
} }
EXTENSIONS.addAll(ZIPPABLES); EXTENSIONS.addAll(ZIPPABLES);
@@ -382,7 +382,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
fos = new FileOutputStream(file); fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos, BUFFER_SIZE); bos = new BufferedOutputStream(fos, BUFFER_SIZE);
int count; int count;
final byte data[] = new byte[BUFFER_SIZE]; final byte[] data = new byte[BUFFER_SIZE];
while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) { while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) {
bos.write(data, 0, count); bos.write(data, 0, count);
} }

View File

@@ -255,7 +255,7 @@ public class CPEAnalyzer implements Analyzer {
protected List<IndexEntry> searchCPE(String vendor, String product, protected List<IndexEntry> searchCPE(String vendor, String product,
Set<String> vendorWeightings, Set<String> productWeightings) { Set<String> vendorWeightings, Set<String> productWeightings) {
final ArrayList<IndexEntry> ret = new ArrayList<IndexEntry>(MAX_QUERY_RESULTS); final List<IndexEntry> ret = new ArrayList<IndexEntry>(MAX_QUERY_RESULTS);
final String searchString = buildSearch(vendor, product, vendorWeightings, productWeightings); final String searchString = buildSearch(vendor, product, vendorWeightings, productWeightings);
if (searchString == null) { if (searchString == null) {

View File

@@ -19,6 +19,7 @@ package org.owasp.dependencycheck.analyzer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.owasp.dependencycheck.Engine; import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.exception.AnalysisException; import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
@@ -101,7 +102,7 @@ public class HintAnalyzer extends AbstractAnalyzer implements Analyzer {
dependency.getVendorEvidence().addEvidence("hint analyzer", "vendor", "vmware", Confidence.HIGH); dependency.getVendorEvidence().addEvidence("hint analyzer", "vendor", "vmware", Confidence.HIGH);
} }
final Iterator<Evidence> itr = dependency.getVendorEvidence().iterator(); final Iterator<Evidence> itr = dependency.getVendorEvidence().iterator();
final ArrayList<Evidence> newEntries = new ArrayList<Evidence>(); final List<Evidence> newEntries = new ArrayList<Evidence>();
while (itr.hasNext()) { while (itr.hasNext()) {
final Evidence e = itr.next(); final Evidence e = itr.next();
if ("sun".equalsIgnoreCase(e.getValue(false))) { if ("sun".equalsIgnoreCase(e.getValue(false))) {

View File

@@ -227,7 +227,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
@Override @Override
public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException { public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException {
try { try {
final ArrayList<ClassNameInformation> classNames = collectClassNames(dependency); final List<ClassNameInformation> classNames = collectClassNames(dependency);
final String fileName = dependency.getFileName().toLowerCase(); final String fileName = dependency.getFileName().toLowerCase();
if (classNames.isEmpty() if (classNames.isEmpty()
&& (fileName.endsWith("-sources.jar") && (fileName.endsWith("-sources.jar")
@@ -255,7 +255,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @throws AnalysisException is thrown if there is an exception parsing the pom * @throws AnalysisException is thrown if there is an exception parsing the pom
* @return whether or not evidence was added to the dependency * @return whether or not evidence was added to the dependency
*/ */
protected boolean analyzePOM(Dependency dependency, ArrayList<ClassNameInformation> classes, Engine engine) throws AnalysisException { protected boolean analyzePOM(Dependency dependency, List<ClassNameInformation> classes, Engine engine) throws AnalysisException {
boolean foundSomething = false; boolean foundSomething = false;
final JarFile jar; final JarFile jar;
try { try {
@@ -408,7 +408,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
fos = new FileOutputStream(file); fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos, BUFFER_SIZE); bos = new BufferedOutputStream(fos, BUFFER_SIZE);
int count; int count;
final byte data[] = new byte[BUFFER_SIZE]; final byte[] data = new byte[BUFFER_SIZE];
while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) { while ((count = input.read(data, 0, BUFFER_SIZE)) != -1) {
bos.write(data, 0, count); bos.write(data, 0, count);
} }
@@ -531,7 +531,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* file being analyzed * file being analyzed
* @return true if there was evidence within the pom that we could use; otherwise false * @return true if there was evidence within the pom that we could use; otherwise false
*/ */
private boolean setPomEvidence(Dependency dependency, Model pom, Properties pomProperties, ArrayList<ClassNameInformation> classes) { private boolean setPomEvidence(Dependency dependency, Model pom, Properties pomProperties, List<ClassNameInformation> classes) {
boolean foundSomething = false; boolean foundSomething = false;
boolean addAsIdentifier = true; boolean addAsIdentifier = true;
if (pom == null) { if (pom == null) {
@@ -659,10 +659,10 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @param dependency a dependency to analyze * @param dependency a dependency to analyze
* @param addPackagesAsEvidence a flag indicating whether or not package names should be added as evidence. * @param addPackagesAsEvidence a flag indicating whether or not package names should be added as evidence.
*/ */
protected void analyzePackageNames(ArrayList<ClassNameInformation> classNames, protected void analyzePackageNames(List<ClassNameInformation> classNames,
Dependency dependency, boolean addPackagesAsEvidence) { Dependency dependency, boolean addPackagesAsEvidence) {
final HashMap<String, Integer> vendorIdentifiers = new HashMap<String, Integer>(); final Map<String, Integer> vendorIdentifiers = new HashMap<String, Integer>();
final HashMap<String, Integer> productIdentifiers = new HashMap<String, Integer>(); final Map<String, Integer> productIdentifiers = new HashMap<String, Integer>();
analyzeFullyQualifiedClassNames(classNames, vendorIdentifiers, productIdentifiers); analyzeFullyQualifiedClassNames(classNames, vendorIdentifiers, productIdentifiers);
final int classCount = classNames.size(); final int classCount = classNames.size();
@@ -704,7 +704,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @return whether evidence was identified parsing the manifest * @return whether evidence was identified parsing the manifest
* @throws IOException if there is an issue reading the JAR file * @throws IOException if there is an issue reading the JAR file
*/ */
protected boolean parseManifest(Dependency dependency, ArrayList<ClassNameInformation> classInformation) throws IOException { protected boolean parseManifest(Dependency dependency, List<ClassNameInformation> classInformation) throws IOException {
boolean foundSomething = false; boolean foundSomething = false;
JarFile jar = null; JarFile jar = null;
try { try {
@@ -1050,8 +1050,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @param dependency the dependency being analyzed * @param dependency the dependency being analyzed
* @return an list of fully qualified class names * @return an list of fully qualified class names
*/ */
private ArrayList<ClassNameInformation> collectClassNames(Dependency dependency) { private List<ClassNameInformation> collectClassNames(Dependency dependency) {
final ArrayList<ClassNameInformation> classNames = new ArrayList<ClassNameInformation>(); final List<ClassNameInformation> classNames = new ArrayList<ClassNameInformation>();
JarFile jar = null; JarFile jar = null;
try { try {
jar = new JarFile(dependency.getActualFilePath()); jar = new JarFile(dependency.getActualFilePath());
@@ -1089,10 +1089,10 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @param vendor HashMap of possible vendor names from package names (e.g. owasp) * @param vendor HashMap of possible vendor names from package names (e.g. owasp)
* @param product HashMap of possible product names from package names (e.g. dependencycheck) * @param product HashMap of possible product names from package names (e.g. dependencycheck)
*/ */
private void analyzeFullyQualifiedClassNames(ArrayList<ClassNameInformation> classNames, private void analyzeFullyQualifiedClassNames(List<ClassNameInformation> classNames,
HashMap<String, Integer> vendor, HashMap<String, Integer> product) { Map<String, Integer> vendor, Map<String, Integer> product) {
for (ClassNameInformation entry : classNames) { for (ClassNameInformation entry : classNames) {
final ArrayList<String> list = entry.getPackageStructure(); final List<String> list = entry.getPackageStructure();
addEntry(vendor, list.get(0)); addEntry(vendor, list.get(0));
if (list.size() == 2) { if (list.size() == 2) {
@@ -1120,7 +1120,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @param collection a collection of strings and their occurrence count * @param collection a collection of strings and their occurrence count
* @param key the key to add to the collection * @param key the key to add to the collection
*/ */
private void addEntry(HashMap<String, Integer> collection, String key) { private void addEntry(Map<String, Integer> collection, String key) {
if (collection.containsKey(key)) { if (collection.containsKey(key)) {
collection.put(key, collection.get(key) + 1); collection.put(key, collection.get(key) + 1);
} else { } else {
@@ -1137,7 +1137,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @param value the value to check to see if it contains a package name * @param value the value to check to see if it contains a package name
* @param evidence the evidence collection to add new entries too * @param evidence the evidence collection to add new entries too
*/ */
private void addMatchingValues(ArrayList<ClassNameInformation> classes, String value, EvidenceCollection evidence) { private void addMatchingValues(List<ClassNameInformation> classes, String value, EvidenceCollection evidence) {
if (value == null || value.isEmpty() || classes == null || classes.isEmpty()) { if (value == null || value.isEmpty() || classes == null || classes.isEmpty()) {
return; return;
} }

View File

@@ -72,7 +72,7 @@ public abstract class AbstractTokenizingFilter extends TokenFilter {
* @return whether or not a new term was added * @return whether or not a new term was added
*/ */
protected boolean addTerm() { protected boolean addTerm() {
final boolean termAdded = tokens.size() > 0; final boolean termAdded = !tokens.isEmpty();
if (termAdded) { if (termAdded) {
final String term = tokens.pop(); final String term = tokens.pop();
clearAttributes(); clearAttributes();

View File

@@ -92,7 +92,7 @@ public final class TokenPairConcatenatingFilter extends TokenFilter {
//if we have a previousTerm - write it out as its own token concatenated //if we have a previousTerm - write it out as its own token concatenated
// with the current word (if one is available). // with the current word (if one is available).
if (previousWord != null && words.size() > 0) { if (previousWord != null && !words.isEmpty()) {
final String word = words.getFirst(); final String word = words.getFirst();
clearAttributes(); clearAttributes();
termAtt.append(previousWord).append(word); termAtt.append(previousWord).append(word);
@@ -100,7 +100,7 @@ public final class TokenPairConcatenatingFilter extends TokenFilter {
return true; return true;
} }
//if we have words, write it out as a single token //if we have words, write it out as a single token
if (words.size() > 0) { if (!words.isEmpty()) {
final String word = words.removeFirst(); final String word = words.removeFirst();
clearAttributes(); clearAttributes();
termAtt.append(word); termAtt.append(word);

View File

@@ -60,7 +60,7 @@ public final class UrlTokenizingFilter extends AbstractTokenizingFilter {
public boolean incrementToken() throws IOException { public boolean incrementToken() throws IOException {
final LinkedList<String> tokens = getTokens(); final LinkedList<String> tokens = getTokens();
final CharTermAttribute termAtt = getTermAtt(); final CharTermAttribute termAtt = getTermAtt();
if (tokens.size() == 0 && input.incrementToken()) { if (tokens.isEmpty() && input.incrementToken()) {
final String text = new String(termAtt.buffer(), 0, termAtt.length()); final String text = new String(termAtt.buffer(), 0, termAtt.length());
if (UrlStringUtils.containsUrl(text)) { if (UrlStringUtils.containsUrl(text)) {
final String[] parts = text.split("\\s"); final String[] parts = text.split("\\s");

View File

@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
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.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
@@ -458,7 +459,8 @@ public class CveDB {
final List<Vulnerability> vulnerabilities = new ArrayList<Vulnerability>(); final List<Vulnerability> vulnerabilities = new ArrayList<Vulnerability>();
PreparedStatement ps; PreparedStatement ps;
final HashSet<String> cveEntries = new HashSet<String>(); //TODO(code review): Looks like things are only added to this map, but never retrieved or checked
final Set<String> cveEntries = new HashSet<String>();
try { try {
ps = getConnection().prepareStatement(SELECT_CVE_FROM_SOFTWARE); ps = getConnection().prepareStatement(SELECT_CVE_FROM_SOFTWARE);
ps.setString(1, cpe.getVendor()); ps.setString(1, cpe.getVendor());
@@ -466,7 +468,7 @@ public class CveDB {
rs = ps.executeQuery(); rs = ps.executeQuery();
String currentCVE = ""; String currentCVE = "";
final HashMap<String, Boolean> vulnSoftware = new HashMap<String, Boolean>(); final Map<String, Boolean> vulnSoftware = new HashMap<String, Boolean>();
while (rs.next()) { while (rs.next()) {
final String cveId = rs.getString(1); final String cveId = rs.getString(1);
if (!currentCVE.equals(cveId)) { //check for match and add if (!currentCVE.equals(cveId)) { //check for match and add
@@ -787,12 +789,12 @@ public class CveDB {
* @param identifiedVersion the identified version of the dependency being analyzed * @param identifiedVersion the identified version of the dependency being analyzed
* @return true if the identified version is affected, otherwise false * @return true if the identified version is affected, otherwise false
*/ */
protected Entry<String, Boolean> getMatchingSoftware(HashMap<String, Boolean> vulnerableSoftware, String vendor, String product, protected Entry<String, Boolean> getMatchingSoftware(Map<String, Boolean> vulnerableSoftware, String vendor, String product,
DependencyVersion identifiedVersion) { DependencyVersion identifiedVersion) {
final boolean isVersionTwoADifferentProduct = "apache".equals(vendor) && "struts".equals(product); final boolean isVersionTwoADifferentProduct = "apache".equals(vendor) && "struts".equals(product);
final HashSet<String> majorVersionsAffectingAllPrevious = new HashSet<String>(); final Set<String> majorVersionsAffectingAllPrevious = new HashSet<String>();
final boolean matchesAnyPrevious = identifiedVersion == null || "-".equals(identifiedVersion.toString()); final boolean matchesAnyPrevious = identifiedVersion == null || "-".equals(identifiedVersion.toString());
String majorVersionMatch = null; String majorVersionMatch = null;
for (Entry<String, Boolean> entry : vulnerableSoftware.entrySet()) { for (Entry<String, Boolean> entry : vulnerableSoftware.entrySet()) {
@@ -875,9 +877,9 @@ public class CveDB {
*/ */
private DependencyVersion parseDependencyVersion(VulnerableSoftware cpe) { private DependencyVersion parseDependencyVersion(VulnerableSoftware cpe) {
DependencyVersion cpeVersion; DependencyVersion cpeVersion;
if (cpe.getVersion() != null && cpe.getVersion().length() > 0) { if (cpe.getVersion() != null && !cpe.getVersion().isEmpty()) {
String versionText; String versionText;
if (cpe.getRevision() != null && cpe.getRevision().length() > 0) { if (cpe.getRevision() != null && !cpe.getRevision().isEmpty()) {
versionText = String.format("%s.%s", cpe.getVersion(), cpe.getRevision()); versionText = String.format("%s.%s", cpe.getVersion(), cpe.getRevision());
} else { } else {
versionText = cpe.getVersion(); versionText = cpe.getVersion();

View File

@@ -154,7 +154,7 @@ public class DatabaseProperties {
* @return a map of the database meta data * @return a map of the database meta data
*/ */
public Map<String, String> getMetaData() { public Map<String, String> getMetaData() {
final TreeMap<String, String> map = new TreeMap<String, String>(); final Map<String, String> map = new TreeMap<String, String>();
for (Entry<Object, Object> entry : properties.entrySet()) { for (Entry<Object, Object> entry : properties.entrySet()) {
final String key = (String) entry.getKey(); final String key = (String) entry.getKey();
if (!"version".equals(key)) { if (!"version".equals(key)) {

View File

@@ -27,6 +27,7 @@ import java.sql.Driver;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -75,7 +76,7 @@ public final class DriverLoader {
*/ */
public static Driver load(String className, String pathToDriver) throws DriverLoadException { public static Driver load(String className, String pathToDriver) throws DriverLoadException {
final URLClassLoader parent = (URLClassLoader) ClassLoader.getSystemClassLoader(); final URLClassLoader parent = (URLClassLoader) ClassLoader.getSystemClassLoader();
final ArrayList<URL> urls = new ArrayList<URL>(); final List<URL> urls = new ArrayList<URL>();
final String[] paths = pathToDriver.split(File.pathSeparator); final String[] paths = pathToDriver.split(File.pathSeparator);
for (String path : paths) { for (String path : paths) {
final File file = new File(path); final File file = new File(path);

View File

@@ -31,7 +31,7 @@ import javax.xml.namespace.QName;
@XmlRegistry @XmlRegistry
public class ObjectFactory { public class ObjectFactory {
private final static QName _Project_QNAME = new QName("http://maven.apache.org/POM/4.0.0", "project"); private static final QName _Project_QNAME = new QName("http://maven.apache.org/POM/4.0.0", "project");
/** /**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.owasp.dependencycheck.analyzer.pom.generated * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.owasp.dependencycheck.analyzer.pom.generated

View File

@@ -112,7 +112,7 @@ public class SuppressionRule {
* @return whether or not this suppression rule as CPE entries * @return whether or not this suppression rule as CPE entries
*/ */
public boolean hasCpe() { public boolean hasCpe() {
return cpe.size() > 0; return !cpe.isEmpty();
} }
/** /**
* The list of cvssBelow scores. * The list of cvssBelow scores.
@@ -152,7 +152,7 @@ public class SuppressionRule {
* @return whether or not this suppression rule has cvss suppressions * @return whether or not this suppression rule has cvss suppressions
*/ */
public boolean hasCvssBelow() { public boolean hasCvssBelow() {
return cvssBelow.size() > 0; return !cvssBelow.isEmpty();
} }
/** /**
* The list of cwe entries to suppress. * The list of cwe entries to suppress.
@@ -192,7 +192,7 @@ public class SuppressionRule {
* @return whether this suppression rule has CWE entries * @return whether this suppression rule has CWE entries
*/ */
public boolean hasCwe() { public boolean hasCwe() {
return cwe.size() > 0; return !cwe.isEmpty();
} }
/** /**
* The list of cve entries to suppress. * The list of cve entries to suppress.
@@ -232,7 +232,7 @@ public class SuppressionRule {
* @return whether this suppression rule has CVE entries * @return whether this suppression rule has CVE entries
*/ */
public boolean hasCve() { public boolean hasCve() {
return cve.size() > 0; return !cve.isEmpty();
} }
/** /**
* A Maven GAV to suppression. * A Maven GAV to suppression.
@@ -450,28 +450,28 @@ public class SuppressionRule {
if (gav != null) { if (gav != null) {
sb.append("gav=").append(gav).append(","); sb.append("gav=").append(gav).append(",");
} }
if (cpe != null && cpe.size() > 0) { if (cpe != null && !cpe.isEmpty()) {
sb.append("cpe={"); sb.append("cpe={");
for (PropertyType pt : cpe) { for (PropertyType pt : cpe) {
sb.append(pt).append(","); sb.append(pt).append(",");
} }
sb.append("}"); sb.append("}");
} }
if (cwe != null && cwe.size() > 0) { if (cwe != null && !cwe.isEmpty()) {
sb.append("cwe={"); sb.append("cwe={");
for (String s : cwe) { for (String s : cwe) {
sb.append(s).append(","); sb.append(s).append(",");
} }
sb.append("}"); sb.append("}");
} }
if (cve != null && cve.size() > 0) { if (cve != null && !cve.isEmpty()) {
sb.append("cve={"); sb.append("cve={");
for (String s : cve) { for (String s : cve) {
sb.append(s).append(","); sb.append(s).append(",");
} }
sb.append("}"); sb.append("}");
} }
if (cvssBelow != null && cvssBelow.size() > 0) { if (cvssBelow != null && !cvssBelow.isEmpty()) {
sb.append("cvssBelow={"); sb.append("cvssBelow={");
for (Float s : cvssBelow) { for (Float s : cvssBelow) {
sb.append(s).append(","); sb.append(s).append(",");

View File

@@ -18,6 +18,7 @@
package org.owasp.dependencycheck.utils; package org.owasp.dependencycheck.utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -62,7 +63,7 @@ public final class DependencyVersionUtil {
//'-' is a special case used within the CVE entries, just include it as the version. //'-' is a special case used within the CVE entries, just include it as the version.
if ("-".equals(text)) { if ("-".equals(text)) {
final DependencyVersion dv = new DependencyVersion(); final DependencyVersion dv = new DependencyVersion();
final ArrayList<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<String>();
list.add(text); list.add(text);
dv.setVersionParts(list); dv.setVersionParts(list);
return dv; return dv;

View File

@@ -107,7 +107,7 @@ public final class ExtractionUtil {
fos = new FileOutputStream(file); fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos, BUFFER_SIZE); bos = new BufferedOutputStream(fos, BUFFER_SIZE);
int count; int count;
final byte data[] = new byte[BUFFER_SIZE]; final byte[] data = new byte[BUFFER_SIZE];
while ((count = zis.read(data, 0, BUFFER_SIZE)) != -1) { while ((count = zis.read(data, 0, BUFFER_SIZE)) != -1) {
bos.write(data, 0, count); bos.write(data, 0, count);
} }

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
@@ -68,7 +69,7 @@ public final class UrlStringUtils {
/** /**
* A listing of domain parts that should not be used as evidence. Yes, this is an incomplete list. * A listing of domain parts that should not be used as evidence. Yes, this is an incomplete list.
*/ */
private static final HashSet<String> IGNORE_LIST = new HashSet<String>( private static final Set<String> IGNORE_LIST = new HashSet<String>(
Arrays.asList("www", "com", "org", "gov", "info", "name", "net", "pro", "tel", "mobi", "xxx")); Arrays.asList("www", "com", "org", "gov", "info", "name", "net", "pro", "tel", "mobi", "xxx"));
/** /**
@@ -86,7 +87,7 @@ public final class UrlStringUtils {
* @throws MalformedURLException thrown if the URL is malformed * @throws MalformedURLException thrown if the URL is malformed
*/ */
public static List<String> extractImportantUrlData(String text) throws MalformedURLException { public static List<String> extractImportantUrlData(String text) throws MalformedURLException {
final ArrayList<String> importantParts = new ArrayList<String>(); final List<String> importantParts = new ArrayList<String>();
final URL url = new URL(text); final URL url = new URL(text);
final String[] domain = url.getHost().split("\\."); final String[] domain = url.getHost().split("\\.");
//add the domain except www and the tld. //add the domain except www and the tld.

View File

@@ -727,7 +727,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
private Proxy getMavenProxy() { private Proxy getMavenProxy() {
if (mavenSettings != null) { if (mavenSettings != null) {
final List<Proxy> proxies = mavenSettings.getProxies(); final List<Proxy> proxies = mavenSettings.getProxies();
if (proxies != null && proxies.size() > 0) { if (proxies != null && !proxies.isEmpty()) {
if (mavenSettingsProxyId != null) { if (mavenSettingsProxyId != null) {
for (Proxy proxy : proxies) { for (Proxy proxy : proxies) {
if (mavenSettingsProxyId.equalsIgnoreCase(proxy.getId())) { if (mavenSettingsProxyId.equalsIgnoreCase(proxy.getId())) {
@@ -737,8 +737,8 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
} else if (proxies.size() == 1) { } else if (proxies.size() == 1) {
return proxies.get(0); return proxies.get(0);
} else { } else {
LOGGER.warning("Multiple proxy defentiions exist in the Maven settings. In the dependency-check " LOGGER.warning("Multiple proxy definitions exist in the Maven settings. In the dependency-check "
+ "configuration set the maveSettingsProxyId so that the correct proxy will be used."); + "configuration set the mavenSettingsProxyId so that the correct proxy will be used.");
throw new IllegalStateException("Ambiguous proxy definition"); throw new IllegalStateException("Ambiguous proxy definition");
} }
} }