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

This commit is contained in:
Jeremy Long
2015-10-13 21:24:22 -04:00
9 changed files with 17 additions and 63 deletions

View File

@@ -214,7 +214,7 @@ public abstract class AbstractFileTypeAnalyzer extends AbstractAnalyzer implemen
* @return a Set of strings. * @return a Set of strings.
*/ */
protected static Set<String> newHashSet(String... strings) { protected static Set<String> newHashSet(String... strings) {
final Set<String> set = new HashSet<String>(); final Set<String> set = new HashSet<String>(strings.length);
Collections.addAll(set, strings); Collections.addAll(set, strings);
return set; return set;
} }

View File

@@ -24,6 +24,11 @@ package org.owasp.dependencycheck.data.composer;
*/ */
public class ComposerException extends RuntimeException { public class ComposerException extends RuntimeException {
/**
* The serial version UID for serialization.
*/
private static final long serialVersionUID = 1L;
/** /**
* Creates a ComposerException with default message. * Creates a ComposerException with default message.
*/ */

View File

@@ -1,47 +0,0 @@
/*
* This file is part of dependency-check-core.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright (c) 2012 Jeremy Long. All Rights Reserved.
*/
package org.owasp.dependencycheck.utils;
import java.io.FilterInputStream;
import java.io.InputStream;
/**
* NonClosingStream is a stream filter which prevents another class that processes the stream from closing it. This is
* necessary when dealing with things like JAXB and zipInputStreams.
*
* @author Jeremy Long
*/
public class NonClosingStream extends FilterInputStream {
/**
* Constructs a new NonClosingStream.
*
* @param in an input stream.
*/
public NonClosingStream(InputStream in) {
super(in);
}
/**
* Prevents closing of the stream.
*/
@Override
public void close() {
// don't close the stream.
}
}

View File

@@ -34,7 +34,7 @@ public class AbstractFileTypeAnalyzerTest extends BaseTest {
*/ */
@Test @Test
public void testNewHashSet() { public void testNewHashSet() {
Set result = AbstractFileTypeAnalyzer.newHashSet("one", "two"); Set<String> result = AbstractFileTypeAnalyzer.newHashSet("one", "two");
assertEquals(2, result.size()); assertEquals(2, result.size());
assertTrue(result.contains("one")); assertTrue(result.contains("one"));
assertTrue(result.contains("two")); assertTrue(result.contains("two"));

View File

@@ -19,7 +19,7 @@ package org.owasp.dependencycheck.analyzer;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.CorruptIndexException;
@@ -49,11 +49,9 @@ public class CPEAnalyzerIntegrationTest extends AbstractDatabaseTestCase {
*/ */
@Test @Test
public void testBuildSearch() throws IOException, CorruptIndexException, ParseException { public void testBuildSearch() throws IOException, CorruptIndexException, ParseException {
Set<String> productWeightings = new HashSet<String>(1); Set<String> productWeightings = Collections.singleton("struts2");
productWeightings.add("struts2");
Set<String> vendorWeightings = new HashSet<String>(1); Set<String> vendorWeightings = Collections.singleton("apache");
vendorWeightings.add("apache");
String vendor = "apache software foundation"; String vendor = "apache software foundation";
String product = "struts 2 core"; String product = "struts 2 core";
@@ -238,11 +236,9 @@ public class CPEAnalyzerIntegrationTest extends AbstractDatabaseTestCase {
CPEAnalyzer instance = new CPEAnalyzer(); CPEAnalyzer instance = new CPEAnalyzer();
instance.open(); instance.open();
Set<String> productWeightings = new HashSet<String>(1); Set<String> productWeightings = Collections.singleton("struts2");
productWeightings.add("struts2");
Set<String> vendorWeightings = new HashSet<String>(1); Set<String> vendorWeightings = Collections.singleton("apache");
vendorWeightings.add("apache");
List<IndexEntry> result = instance.searchCPE(vendor, product, productWeightings, vendorWeightings); List<IndexEntry> result = instance.searchCPE(vendor, product, productWeightings, vendorWeightings);
instance.close(); instance.close();

View File

@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.owasp.dependencycheck.dependency.Vulnerability;
import org.owasp.dependencycheck.dependency.VulnerableSoftware; import org.owasp.dependencycheck.dependency.VulnerableSoftware;
import org.owasp.dependencycheck.utils.Settings; import org.owasp.dependencycheck.utils.Settings;
@@ -96,7 +97,7 @@ public class CveDBMySQLTest {
CveDB instance = new CveDB(); CveDB instance = new CveDB();
try { try {
instance.open(); instance.open();
List result = instance.getVulnerabilities(cpeStr); List<Vulnerability> result = instance.getVulnerabilities(cpeStr);
assertTrue(result.size() > 5); assertTrue(result.size() > 5);
} catch (Exception ex) { } catch (Exception ex) {
System.out.println("Unable to access the My SQL database; verify that the db server is running and that the schema has been generated"); System.out.println("Unable to access the My SQL database; verify that the db server is running and that the schema has been generated");

View File

@@ -185,7 +185,6 @@ public class DependencyTest {
@Test @Test
public void testGetIdentifiers() { public void testGetIdentifiers() {
Dependency instance = new Dependency(); Dependency instance = new Dependency();
List expResult = null;
Set<Identifier> result = instance.getIdentifiers(); Set<Identifier> result = instance.getIdentifiers();
assertTrue(true); //this is just a getter setter pair. assertTrue(true); //this is just a getter setter pair.

View File

@@ -61,7 +61,7 @@ public class SuppressionParserTest {
//File file = new File(this.getClass().getClassLoader().getResource("suppressions.xml").getPath()); //File file = new File(this.getClass().getClassLoader().getResource("suppressions.xml").getPath());
File file = BaseTest.getResourceAsFile(this, "suppressions.xml"); File file = BaseTest.getResourceAsFile(this, "suppressions.xml");
SuppressionParser instance = new SuppressionParser(); SuppressionParser instance = new SuppressionParser();
List result = instance.parseSuppressionRules(file); List<SuppressionRule> result = instance.parseSuppressionRules(file);
assertTrue(result.size() > 3); assertTrue(result.size() > 3);
} }
} }

View File

@@ -61,11 +61,11 @@ public class DependencyVersionTest {
@Test @Test
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<String> result = instance.iterator();
assertTrue(result.hasNext()); assertTrue(result.hasNext());
int count = 1; int count = 1;
while (result.hasNext()) { while (result.hasNext()) {
String v = (String) result.next(); String v = result.next();
assertTrue(String.valueOf(count++).equals(v)); assertTrue(String.valueOf(count++).equals(v));
} }
} }