mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-18 01:27:11 +01:00
major revision to patch issue #86; file type analyzers will no longer initialize if no files were detected that they can process during the scan phase.
Former-commit-id: 1d9ef39d5f7898de73ac72bbb9573af763368e95
This commit is contained in:
@@ -30,9 +30,9 @@ import org.junit.Test;
|
||||
*
|
||||
* @author Jeremy Long <jeremy.long@owasp.org>
|
||||
*/
|
||||
public class AbstractAnalyzerTest {
|
||||
public class AbstractFileTypeAnalyzerTest {
|
||||
|
||||
public AbstractAnalyzerTest() {
|
||||
public AbstractFileTypeAnalyzerTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
@@ -56,7 +56,7 @@ public class AbstractAnalyzerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testNewHashSet() {
|
||||
Set result = AbstractAnalyzer.newHashSet("one", "two");
|
||||
Set result = AbstractFileTypeAnalyzer.newHashSet("one", "two");
|
||||
assertEquals(2, result.size());
|
||||
assertTrue(result.contains("one"));
|
||||
assertTrue(result.contains("two"));
|
||||
@@ -79,18 +79,6 @@ public class AbstractSuppressionAnalyzerTest {
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of supportsExtension method, of class AbstractSuppressionAnalyzer.
|
||||
*/
|
||||
@Test
|
||||
public void testSupportsExtension() {
|
||||
String extension = "jar";
|
||||
AbstractSuppressionAnalyzer instance = new AbstractSuppressionAnalyzerImpl();
|
||||
boolean expResult = true;
|
||||
boolean result = instance.supportsExtension(extension);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of initialize method, of class AbstractSuppressionAnalyzer.
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -62,8 +61,7 @@ public class AnalyzerServiceTest {
|
||||
boolean found = false;
|
||||
while (result.hasNext()) {
|
||||
Analyzer a = result.next();
|
||||
Set<String> e = a.getSupportedExtensions();
|
||||
if (e != null && e.contains("jar")) {
|
||||
if ("Jar Analyzer".equals(a.getName())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,8 @@ public class ArchiveAnalyzerTest extends AbstractDatabaseTestCase {
|
||||
@Test
|
||||
public void testAnalyze() throws Exception {
|
||||
ArchiveAnalyzer instance = new ArchiveAnalyzer();
|
||||
//trick the analyzer into thinking it is active.
|
||||
instance.supportsExtension("ear");
|
||||
try {
|
||||
instance.initialize();
|
||||
|
||||
@@ -175,6 +177,8 @@ public class ArchiveAnalyzerTest extends AbstractDatabaseTestCase {
|
||||
@Test
|
||||
public void testAnalyzeTar() throws Exception {
|
||||
ArchiveAnalyzer instance = new ArchiveAnalyzer();
|
||||
//trick the analyzer into thinking it is active so that it will initialize
|
||||
instance.supportsExtension("tar");
|
||||
try {
|
||||
instance.initialize();
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ public class AssemblyAnalyzerTest {
|
||||
public void setUp() {
|
||||
try {
|
||||
analyzer = new AssemblyAnalyzer();
|
||||
//trick the analyzer into thinking it is active, otherwise the initialize will do nothing.
|
||||
analyzer.supportsExtension("dll");
|
||||
analyzer.initialize();
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.WARNING, "Exception setting up AssemblyAnalyzer. Tests will be incomplete", e);
|
||||
|
||||
@@ -17,11 +17,9 @@
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.util.Set;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -52,16 +50,6 @@ public class DependencyBundlingAnalyzerTest {
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getSupportedExtensions method, of class DependencyBundlingAnalyzer.
|
||||
*/
|
||||
@Test
|
||||
public void testGetSupportedExtensions() {
|
||||
DependencyBundlingAnalyzer instance = new DependencyBundlingAnalyzer();
|
||||
Set<String> result = instance.getSupportedExtensions();
|
||||
assertNull(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getName method, of class DependencyBundlingAnalyzer.
|
||||
*/
|
||||
@@ -73,18 +61,6 @@ public class DependencyBundlingAnalyzerTest {
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of supportsExtension method, of class DependencyBundlingAnalyzer.
|
||||
*/
|
||||
@Test
|
||||
public void testSupportsExtension() {
|
||||
String extension = "jar";
|
||||
DependencyBundlingAnalyzer instance = new DependencyBundlingAnalyzer();
|
||||
boolean expResult = true;
|
||||
boolean result = instance.supportsExtension(extension);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getAnalysisPhase method, of class DependencyBundlingAnalyzer.
|
||||
*/
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.util.Set;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -52,17 +50,6 @@ public class FalsePositiveAnalyzerTest {
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getSupportedExtensions method, of class FalsePositiveAnalyzer.
|
||||
*/
|
||||
@Test
|
||||
public void testGetSupportedExtensions() {
|
||||
FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
|
||||
Set<String> result = instance.getSupportedExtensions();
|
||||
assertNull(result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getName method, of class FalsePositiveAnalyzer.
|
||||
*/
|
||||
@@ -74,18 +61,6 @@ public class FalsePositiveAnalyzerTest {
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of supportsExtension method, of class FalsePositiveAnalyzer.
|
||||
*/
|
||||
@Test
|
||||
public void testSupportsExtension() {
|
||||
String extension = "any";
|
||||
FalsePositiveAnalyzer instance = new FalsePositiveAnalyzer();
|
||||
boolean expResult = true;
|
||||
boolean result = instance.supportsExtension(extension);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getAnalysisPhase method, of class FalsePositiveAnalyzer.
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -53,17 +52,6 @@ public class FileNameAnalyzerTest {
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getSupportedExtensions method, of class FileNameAnalyzer.
|
||||
*/
|
||||
@Test
|
||||
public void testGetSupportedExtensions() {
|
||||
FileNameAnalyzer instance = new FileNameAnalyzer();
|
||||
Set expResult = null;
|
||||
Set result = instance.getSupportedExtensions();
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getName method, of class FileNameAnalyzer.
|
||||
*/
|
||||
@@ -75,18 +63,6 @@ public class FileNameAnalyzerTest {
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of supportsExtension method, of class FileNameAnalyzer.
|
||||
*/
|
||||
@Test
|
||||
public void testSupportsExtension() {
|
||||
String extension = "any";
|
||||
FileNameAnalyzer instance = new FileNameAnalyzer();
|
||||
boolean expResult = true;
|
||||
boolean result = instance.supportsExtension(extension);
|
||||
assertEquals(expResult, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getAnalysisPhase method, of class FileNameAnalyzer.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user