mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-12 05:11:56 +01:00
Merge branch 'catch_ioexception_parsing_manifest' of https://github.com/mealingr/DependencyCheck into mealingr-catch_ioexception_parsing_manifest
This commit is contained in:
@@ -17,24 +17,23 @@
|
||||
*/
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
import org.owasp.dependencycheck.Engine;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.dependency.Evidence;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Jeremy Long
|
||||
*/
|
||||
@@ -176,4 +175,31 @@ public class JarAnalyzerTest extends BaseTest {
|
||||
List<String> results = instance.getPackageStructure();
|
||||
assertEquals(expected, results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnalyzeDependency_SkipsMacOSMetaDataFile() throws Exception {
|
||||
JarAnalyzer instance = new JarAnalyzer();
|
||||
Dependency macOSMetaDataFile = new Dependency();
|
||||
macOSMetaDataFile
|
||||
.setActualFilePath(FileUtils.getFile("src", "test", "resources", "._avro-ipc-1.5.0.jar").getAbsolutePath());
|
||||
macOSMetaDataFile.setFileName("._avro-ipc-1.5.0.jar");
|
||||
Dependency actualJarFile = new Dependency();
|
||||
actualJarFile.setActualFilePath(BaseTest.getResourceAsFile(this, "avro-ipc-1.5.0.jar").getAbsolutePath());
|
||||
actualJarFile.setFileName("avro-ipc-1.5.0.jar");
|
||||
Engine engine = new Engine();
|
||||
engine.setDependencies(Arrays.asList(macOSMetaDataFile, actualJarFile));
|
||||
instance.analyzeDependency(macOSMetaDataFile, engine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnalyseDependency_SkipsNonZipFile() throws Exception {
|
||||
JarAnalyzer instance = new JarAnalyzer();
|
||||
Dependency textFileWithJarExtension = new Dependency();
|
||||
textFileWithJarExtension
|
||||
.setActualFilePath(BaseTest.getResourceAsFile(this, "textFileWithJarExtension.jar").getAbsolutePath());
|
||||
textFileWithJarExtension.setFileName("textFileWithJarExtension.jar");
|
||||
Engine engine = new Engine();
|
||||
engine.setDependencies(Collections.singletonList(textFileWithJarExtension));
|
||||
instance.analyzeDependency(textFileWithJarExtension, engine);
|
||||
}
|
||||
}
|
||||
|
||||
BIN
dependency-check-core/src/test/resources/._avro-ipc-1.5.0.jar
Normal file
BIN
dependency-check-core/src/test/resources/._avro-ipc-1.5.0.jar
Normal file
Binary file not shown.
BIN
dependency-check-core/src/test/resources/avro-ipc-1.5.0.jar
Normal file
BIN
dependency-check-core/src/test/resources/avro-ipc-1.5.0.jar
Normal file
Binary file not shown.
@@ -0,0 +1 @@
|
||||
text file with jar extension
|
||||
Reference in New Issue
Block a user