mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-04-30 04:04:30 +02:00
Merge branch 'master' of github.com:jeremylong/DependencyCheck
Former-commit-id: 0050abb5911eb52058d7e43a65d7f3df5dda6f24
This commit is contained in:
@@ -26,13 +26,12 @@ import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.suppression.SuppressionParseException;
|
||||
import org.owasp.dependencycheck.suppression.SuppressionRule;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -93,9 +92,9 @@ public class AbstractSuppressionAnalyzerTest extends BaseTest {
|
||||
final String uri = this.getClass().getClassLoader().getResource("suppressions.xml").toURI().toURL().toString();
|
||||
Settings.setString(Settings.KEYS.SUPPRESSION_FILE, uri);
|
||||
} catch (URISyntaxException ex) {
|
||||
Logger.getLogger(AbstractSuppressionAnalyzerTest.class.getName()).log(Level.SEVERE, null, ex);
|
||||
LoggerFactory.getLogger(AbstractSuppressionAnalyzerTest.class).error("", ex);
|
||||
} catch (MalformedURLException ex) {
|
||||
Logger.getLogger(AbstractSuppressionAnalyzerTest.class.getName()).log(Level.SEVERE, null, ex);
|
||||
LoggerFactory.getLogger(AbstractSuppressionAnalyzerTest.class).error("", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
package org.owasp.dependencycheck.analyzer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -34,6 +32,10 @@ import org.owasp.dependencycheck.dependency.Confidence;
|
||||
import org.owasp.dependencycheck.dependency.Dependency;
|
||||
import org.owasp.dependencycheck.dependency.Evidence;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.impl.SimpleLogger;
|
||||
import org.slf4j.impl.SimpleLoggerFactory;
|
||||
|
||||
/**
|
||||
* Tests for the AssemblyAnalyzer.
|
||||
@@ -43,7 +45,9 @@ import org.owasp.dependencycheck.utils.Settings;
|
||||
*/
|
||||
public class AssemblyAnalyzerTest extends BaseTest {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(AssemblyAnalyzerTest.class.getName());
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AssemblyAnalyzerTest.class);
|
||||
|
||||
private static final String LOG_KEY = "org.slf4j.simpleLogger.org.owasp.dependencycheck.analyzer.AssemblyAnalyzer";
|
||||
|
||||
AssemblyAnalyzer analyzer;
|
||||
|
||||
@@ -60,9 +64,9 @@ public class AssemblyAnalyzerTest extends BaseTest {
|
||||
analyzer.initialize();
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().contains("Could not execute .NET AssemblyAnalyzer")) {
|
||||
LOGGER.log(Level.WARNING, "Exception setting up AssemblyAnalyzer. Tests will be incomplete");
|
||||
LOGGER.warn("Exception setting up AssemblyAnalyzer. Tests will be incomplete");
|
||||
} else {
|
||||
LOGGER.log(Level.WARNING, "Exception setting up AssemblyAnalyzer. Tests will be incomplete", e);
|
||||
LOGGER.warn("Exception setting up AssemblyAnalyzer. Tests will be incomplete", e);
|
||||
}
|
||||
Assume.assumeNoException("Is mono installed? TESTS WILL BE INCOMPLETE", e);
|
||||
}
|
||||
@@ -113,11 +117,8 @@ public class AssemblyAnalyzerTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testNonexistent() {
|
||||
Level oldLevel = Logger.getLogger(AssemblyAnalyzer.class.getName()).getLevel();
|
||||
Level oldDependency = Logger.getLogger(Dependency.class.getName()).getLevel();
|
||||
// Tweak the log level so the warning doesn't show in the console
|
||||
Logger.getLogger(AssemblyAnalyzer.class.getName()).setLevel(Level.OFF);
|
||||
Logger.getLogger(Dependency.class.getName()).setLevel(Level.OFF);
|
||||
String oldProp = System.getProperty(LOG_KEY, "info");
|
||||
//File f = new File(AssemblyAnalyzerTest.class.getClassLoader().getResource("log4net.dll").getPath());
|
||||
File f = BaseTest.getResourceAsFile(this, "log4net.dll");
|
||||
File test = new File(f.getParent(), "nonexistent.dll");
|
||||
@@ -129,8 +130,7 @@ public class AssemblyAnalyzerTest extends BaseTest {
|
||||
} catch (AnalysisException ae) {
|
||||
assertEquals("File does not exist", ae.getMessage());
|
||||
} finally {
|
||||
Logger.getLogger(AssemblyAnalyzer.class.getName()).setLevel(oldLevel);
|
||||
Logger.getLogger(Dependency.class.getName()).setLevel(oldDependency);
|
||||
System.setProperty(LOG_KEY, oldProp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,10 +151,10 @@ public class AssemblyAnalyzerTest extends BaseTest {
|
||||
Settings.setString(Settings.KEYS.ANALYZER_ASSEMBLY_MONO_PATH, "/yooser/bine/mono");
|
||||
}
|
||||
|
||||
Level oldLevel = Logger.getLogger(AssemblyAnalyzer.class.getName()).getLevel();
|
||||
String oldProp = System.getProperty(LOG_KEY, "info");
|
||||
try {
|
||||
// Tweak the logging to swallow the warning when testing
|
||||
Logger.getLogger(AssemblyAnalyzer.class.getName()).setLevel(Level.OFF);
|
||||
System.setProperty(LOG_KEY, "error");
|
||||
// Have to make a NEW analyzer because during setUp, it would have gotten the correct one
|
||||
AssemblyAnalyzer aanalyzer = new AssemblyAnalyzer();
|
||||
aanalyzer.supportsExtension("dll");
|
||||
@@ -163,8 +163,8 @@ public class AssemblyAnalyzerTest extends BaseTest {
|
||||
} catch (AnalysisException ae) {
|
||||
assertEquals("An error occured with the .NET AssemblyAnalyzer", ae.getMessage());
|
||||
} finally {
|
||||
System.setProperty(LOG_KEY, oldProp);
|
||||
// Recover the logger
|
||||
Logger.getLogger(AssemblyAnalyzer.class.getName()).setLevel(oldLevel);
|
||||
// Now recover the way we came in. If we had to set a System property, delete it. Otherwise,
|
||||
// reset the old value
|
||||
if (oldValue == null) {
|
||||
|
||||
@@ -5,11 +5,12 @@ import org.junit.Test;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
import org.owasp.dependencycheck.data.nexus.MavenArtifact;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -17,13 +18,13 @@ import static org.junit.Assert.*;
|
||||
* Created by colezlaw on 10/13/14.
|
||||
*/
|
||||
public class CentralSearchTest extends BaseTest {
|
||||
private static final Logger LOGGER = Logger.getLogger(CentralSearchTest.class.getName());
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CentralSearchTest.class);
|
||||
private CentralSearch searcher;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
String centralUrl = Settings.getString(Settings.KEYS.ANALYZER_CENTRAL_URL);
|
||||
LOGGER.fine(centralUrl);
|
||||
LOGGER.debug(centralUrl);
|
||||
searcher = new CentralSearch(new URL(centralUrl));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.owasp.dependencycheck.data.nexus;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Logger;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Assume;
|
||||
@@ -28,16 +27,18 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class NexusSearchTest extends BaseTest {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(NexusSearchTest.class.getName());
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NexusSearchTest.class);
|
||||
private NexusSearch searcher;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
String nexusUrl = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL);
|
||||
LOGGER.fine(nexusUrl);
|
||||
LOGGER.debug(nexusUrl);
|
||||
searcher = new NexusSearch(new URL(nexusUrl));
|
||||
Assume.assumeTrue(searcher.preflightRequest());
|
||||
}
|
||||
|
||||
@@ -22,13 +22,12 @@ import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import org.junit.Before;
|
||||
import org.owasp.dependencycheck.BaseTest;
|
||||
import org.owasp.dependencycheck.utils.Settings;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -76,7 +75,7 @@ public abstract class BaseDBTestCase extends BaseTest {
|
||||
dest.write(data, 0, count);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(BaseDBTestCase.class.getName()).log(Level.SEVERE, null, ex);
|
||||
LoggerFactory.getLogger(BaseDBTestCase.class).error("", ex);
|
||||
} finally {
|
||||
try {
|
||||
if (dest != null) {
|
||||
@@ -84,14 +83,14 @@ public abstract class BaseDBTestCase extends BaseTest {
|
||||
dest.close();
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(BaseDBTestCase.class.getName()).log(Level.FINEST, null, ex);
|
||||
LoggerFactory.getLogger(BaseDBTestCase.class).trace("", ex);
|
||||
}
|
||||
try {
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(BaseDBTestCase.class.getName()).log(Level.FINEST, null, ex);
|
||||
LoggerFactory.getLogger(BaseDBTestCase.class).trace("", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,14 +100,14 @@ public abstract class BaseDBTestCase extends BaseTest {
|
||||
zin.close();
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(BaseDBTestCase.class.getName()).log(Level.FINEST, null, ex);
|
||||
LoggerFactory.getLogger(BaseDBTestCase.class).trace("", ex);
|
||||
}
|
||||
try {
|
||||
if (fis != null) {
|
||||
fis.close();
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger(BaseDBTestCase.class.getName()).log(Level.FINEST, null, ex);
|
||||
LoggerFactory.getLogger(BaseDBTestCase.class).trace("", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user