/**
@@ -103,7 +103,7 @@ public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer {
try {
rules = parser.parseSuppressionRules(this.getClass().getClassLoader().getResourceAsStream("dependencycheck-base-suppression.xml"));
} catch (SuppressionParseException ex) {
- LOGGER.log(Level.FINE, "Unable to parse the base suppression data file", ex);
+ LOGGER.debug("Unable to parse the base suppression data file", ex);
}
final String suppressionFilePath = Settings.getString(Settings.KEYS.SUPPRESSION_FILE);
if (suppressionFilePath == null) {
@@ -141,12 +141,11 @@ public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer {
try {
//rules = parser.parseSuppressionRules(file);
rules.addAll(parser.parseSuppressionRules(file));
- LOGGER.log(Level.FINE, rules.size() + " suppression rules were loaded.");
+ LOGGER.debug("{} suppression rules were loaded.", rules.size());
} catch (SuppressionParseException ex) {
- final String msg = String.format("Unable to parse suppression xml file '%s'", file.getPath());
- LOGGER.log(Level.WARNING, msg);
- LOGGER.log(Level.WARNING, ex.getMessage());
- LOGGER.log(Level.FINE, "", ex);
+ LOGGER.warn("Unable to parse suppression xml file '{}'", file.getPath());
+ LOGGER.warn(ex.getMessage());
+ LOGGER.debug("", ex);
throw ex;
}
}
@@ -171,8 +170,8 @@ public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer {
* @throws SuppressionParseException throws the generated SuppressionParseException
*/
private void throwSuppressionParseException(String message, Exception exception) throws SuppressionParseException {
- LOGGER.log(Level.WARNING, message);
- LOGGER.log(Level.FINE, "", exception);
+ LOGGER.warn(message);
+ LOGGER.debug("", exception);
throw new SuppressionParseException(message, exception);
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java
index f874cceae..28cd78a2a 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ArchiveAnalyzer.java
@@ -31,8 +31,6 @@ import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
@@ -48,6 +46,8 @@ import org.owasp.dependencycheck.analyzer.exception.ArchiveExtractionException;
import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.utils.FileUtils;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -61,7 +61,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(ArchiveAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(ArchiveAnalyzer.class);
/**
* The buffer size to use when extracting files from the archive.
*/
@@ -184,10 +184,10 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
@Override
public void close() throws Exception {
if (tempFileLocation != null && tempFileLocation.exists()) {
- LOGGER.log(Level.FINE, "Attempting to delete temporary files");
+ LOGGER.debug("Attempting to delete temporary files");
final boolean success = FileUtils.delete(tempFileLocation);
if (!success && tempFileLocation != null && tempFileLocation.exists() && tempFileLocation.list().length > 0) {
- LOGGER.log(Level.WARNING, "Failed to delete some temporary files, see the log for more details");
+ LOGGER.warn("Failed to delete some temporary files, see the log for more details");
}
}
}
@@ -264,8 +264,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
}
}
} catch (IOException ex) {
- final String msg = String.format("Unable to perform deep copy on '%s'", dependency.getActualFile().getPath());
- LOGGER.log(Level.FINE, msg, ex);
+ LOGGER.debug("Unable to perform deep copy on '{}'", dependency.getActualFile().getPath(), ex);
}
}
engine.getDependencies().remove(dependency);
@@ -310,7 +309,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
try {
fis = new FileInputStream(archive);
} catch (FileNotFoundException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
throw new AnalysisException("Archive file was not found.", ex);
}
final String archiveExt = FileUtils.getFileExtension(archive.getName()).toLowerCase();
@@ -327,18 +326,16 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
}
}
} catch (ArchiveExtractionException ex) {
- final String msg = String.format("Exception extracting archive '%s'.", archive.getName());
- LOGGER.log(Level.WARNING, msg);
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.warn("Exception extracting archive '{}'.", archive.getName());
+ LOGGER.debug("", ex);
} catch (IOException ex) {
- final String msg = String.format("Exception reading archive '%s'.", archive.getName());
- LOGGER.log(Level.WARNING, msg);
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.warn("Exception reading archive '{}'.", archive.getName());
+ LOGGER.debug("", ex);
} finally {
try {
fis.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
}
}
}
@@ -367,8 +364,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
final File file = new File(destination, entry.getName());
final String ext = FileUtils.getFileExtension(file.getName());
if (engine.supportsExtension(ext)) {
- final String extracting = String.format("Extracting '%s'", file.getPath());
- LOGGER.fine(extracting);
+ LOGGER.debug("Extracting '{}'", file.getPath());
BufferedOutputStream bos = null;
FileOutputStream fos = null;
try {
@@ -388,11 +384,11 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
}
bos.flush();
} catch (FileNotFoundException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
final String msg = String.format("Unable to find file '%s'.", file.getName());
throw new AnalysisException(msg, ex);
} catch (IOException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
final String msg = String.format("IO Exception while parsing file '%s'.", file.getName());
throw new AnalysisException(msg, ex);
} finally {
@@ -400,14 +396,14 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
try {
bos.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
if (fos != null) {
try {
fos.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
@@ -423,7 +419,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
try {
input.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
@@ -437,8 +433,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
* @throws ArchiveExtractionException thrown if there is an exception decompressing the file
*/
private void decompressFile(CompressorInputStream inputStream, File outputFile) throws ArchiveExtractionException {
- final String msg = String.format("Decompressing '%s'", outputFile.getPath());
- LOGGER.fine(msg);
+ LOGGER.debug("Decompressing '{}'", outputFile.getPath());
FileOutputStream out = null;
try {
out = new FileOutputStream(outputFile);
@@ -448,17 +443,17 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
out.write(buffer, 0, n);
}
} catch (FileNotFoundException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
throw new ArchiveExtractionException(ex);
} catch (IOException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
throw new ArchiveExtractionException(ex);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
@@ -490,7 +485,7 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
}
}
} catch (IOException ex) {
- LOGGER.log(Level.FINE, String.format("Unable to unzip zip file '%s'", dependency.getFilePath()), ex);
+ LOGGER.debug("Unable to unzip zip file '{}'", dependency.getFilePath(), ex);
} finally {
ZipFile.closeQuietly(zip);
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java
index f8417d0d7..054adde34 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AssemblyAnalyzer.java
@@ -25,20 +25,26 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+
+import ch.qos.cal10n.IMessageConveyor;
+import ch.qos.cal10n.MessageConveyor;
import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
import org.owasp.dependencycheck.dependency.Confidence;
import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.dependency.Evidence;
+import org.owasp.dependencycheck.utils.DCResources;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.cal10n.LocLogger;
+import org.slf4j.cal10n.LocLoggerFactory;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
@@ -70,10 +76,18 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
* The DocumentBuilder for parsing the XML
*/
private DocumentBuilder builder;
+ /**
+ * Message Conveyer
+ */
+ private IMessageConveyor messageConveyer = new MessageConveyor(Locale.getDefault());
+ /**
+ * LocLoggerFactory for localized logger
+ */
+ private LocLoggerFactory llFactory = new LocLoggerFactory(messageConveyer);
/**
* Logger
*/
- private static final Logger LOGGER = Logger.getLogger(AssemblyAnalyzer.class.getName(), "dependencycheck-resources");
+ private LocLogger LOGGER = llFactory.getLocLogger(AssemblyAnalyzer.class);
/**
* Builds the beginnings of a List for ProcessBuilder
@@ -106,7 +120,7 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
public void analyzeFileType(Dependency dependency, Engine engine)
throws AnalysisException {
if (grokAssemblyExe == null) {
- LOGGER.warning("analyzer.AssemblyAnalyzer.notdeployed");
+ LOGGER.warn(DCResources.NOTDEPLOYED);
return;
}
@@ -122,7 +136,7 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
String line = null;
// CHECKSTYLE:OFF
while (rdr.ready() && (line = rdr.readLine()) != null) {
- LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.stderr", line);
+ LOGGER.warn(DCResources.GROKERROR, line);
}
// CHECKSTYLE:ON
int rc = 0;
@@ -134,10 +148,10 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
return;
}
if (rc == 3) {
- LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.notassembly", dependency.getActualFilePath());
+ LOGGER.debug(DCResources.NOTASSEMBLY, dependency.getActualFilePath());
return;
} else if (rc != 0) {
- LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.rc", rc);
+ LOGGER.warn(DCResources.GROKRC, rc);
}
final XPath xpath = XPathFactory.newInstance().newXPath();
@@ -178,7 +192,7 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
try {
rdr.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, "ignore", ex);
+ LOGGER.debug("ignore", ex);
}
}
}
@@ -205,24 +219,24 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
grokAssemblyExe = tempFile;
// Set the temp file to get deleted when we're done
grokAssemblyExe.deleteOnExit();
- LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.grokassembly.deployed", grokAssemblyExe.getPath());
+ LOGGER.debug(DCResources.GROKDEPLOYED, grokAssemblyExe.getPath());
} catch (IOException ioe) {
this.setEnabled(false);
- LOGGER.log(Level.WARNING, "analyzer.AssemblyAnalyzer.grokassembly.notdeployed", ioe.getMessage());
+ LOGGER.warn(DCResources.GROKNOTDEPLOYED, ioe.getMessage());
throw new AnalysisException("Could not extract GrokAssembly.exe", ioe);
} finally {
if (fos != null) {
try {
fos.close();
} catch (Throwable e) {
- LOGGER.fine("Error closing output stream");
+ LOGGER.debug("Error closing output stream");
}
}
if (is != null) {
try {
is.close();
} catch (Throwable e) {
- LOGGER.fine("Error closing input stream");
+ LOGGER.debug("Error closing input stream");
}
}
}
@@ -244,8 +258,8 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
final XPath xpath = XPathFactory.newInstance().newXPath();
final String error = xpath.evaluate("/assembly/error", doc);
if (p.waitFor() != 1 || error == null || "".equals(error)) {
- LOGGER.warning("An error occurred with the .NET AssemblyAnalyzer, please see the log for more details.");
- LOGGER.fine("GrokAssembly.exe is not working properly");
+ LOGGER.warn("An error occurred with the .NET AssemblyAnalyzer, please see the log for more details.");
+ LOGGER.debug("GrokAssembly.exe is not working properly");
grokAssemblyExe = null;
this.setEnabled(false);
throw new AnalysisException("Could not execute .NET AssemblyAnalyzer");
@@ -254,8 +268,8 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
if (e instanceof AnalysisException) {
throw (AnalysisException) e;
} else {
- LOGGER.warning("analyzer.AssemblyAnalyzer.grokassembly.initialization.failed");
- LOGGER.log(Level.FINE, "analyzer.AssemblyAnalyzer.grokassembly.initialization.message", e.getMessage());
+ LOGGER.warn(DCResources.GROKINITFAIL);
+ LOGGER.debug(DCResources.GROKINITMSG, e.getMessage());
this.setEnabled(false);
throw new AnalysisException("An error occured with the .NET AssemblyAnalyzer", e);
}
@@ -264,7 +278,7 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
try {
rdr.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, "ignore", ex);
+ LOGGER.trace("ignore", ex);
}
}
}
@@ -279,7 +293,7 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
grokAssemblyExe.deleteOnExit();
}
} catch (SecurityException se) {
- LOGGER.fine("analyzer.AssemblyAnalyzer.grokassembly.notdeleted");
+ LOGGER.debug(DCResources.GROKNOTDELETED);
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java
index 0b78ab908..4d0470f8e 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CPEAnalyzer.java
@@ -25,8 +25,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.queryparser.classic.ParseException;
@@ -49,6 +47,8 @@ import org.owasp.dependencycheck.dependency.Identifier;
import org.owasp.dependencycheck.dependency.VulnerableSoftware;
import org.owasp.dependencycheck.utils.DependencyVersion;
import org.owasp.dependencycheck.utils.DependencyVersionUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* CPEAnalyzer is a utility class that takes a project dependency and attempts to discern if there is an associated CPE. It uses
@@ -61,7 +61,7 @@ public class CPEAnalyzer implements Analyzer {
/**
* The Logger.
*/
- private static final Logger LOGGER = Logger.getLogger(CPEAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(CPEAnalyzer.class);
/**
* The maximum number of query results to return.
*/
@@ -134,15 +134,15 @@ public class CPEAnalyzer implements Analyzer {
* process.
*/
public void open() throws IOException, DatabaseException {
- LOGGER.log(Level.FINE, "Opening the CVE Database");
+ LOGGER.debug("Opening the CVE Database");
cve = new CveDB();
cve.open();
- LOGGER.log(Level.FINE, "Creating the Lucene CPE Index");
+ LOGGER.debug("Creating the Lucene CPE Index");
cpe = CpeMemoryIndex.getInstance();
try {
cpe.open(cve);
} catch (IndexException ex) {
- LOGGER.log(Level.FINE, "IndexException", ex);
+ LOGGER.debug("IndexException", ex);
throw new DatabaseException(ex);
}
}
@@ -180,11 +180,11 @@ public class CPEAnalyzer implements Analyzer {
for (Confidence confidence : Confidence.values()) {
if (dependency.getVendorEvidence().contains(confidence)) {
vendors = addEvidenceWithoutDuplicateTerms(vendors, dependency.getVendorEvidence(), confidence);
- LOGGER.fine(String.format("vendor search: %s", vendors));
+ LOGGER.debug("vendor search: {}", vendors);
}
if (dependency.getProductEvidence().contains(confidence)) {
products = addEvidenceWithoutDuplicateTerms(products, dependency.getProductEvidence(), confidence);
- LOGGER.fine(String.format("product search: %s", products));
+ LOGGER.debug("product search: {}", products);
}
if (!vendors.isEmpty() && !products.isEmpty()) {
final List entries = searchCPE(vendors, products, dependency.getProductEvidence().getWeighting(),
@@ -194,11 +194,11 @@ public class CPEAnalyzer implements Analyzer {
}
boolean identifierAdded = false;
for (IndexEntry e : entries) {
- LOGGER.fine(String.format("Verifying entry: %s", e.toString()));
+ LOGGER.debug("Verifying entry: {}", e);
if (verifyEntry(e, dependency)) {
final String vendor = e.getVendor();
final String product = e.getProduct();
- LOGGER.fine(String.format("identified vendor/product: %s/%s", vendor, product));
+ LOGGER.debug("identified vendor/product: {}/{}", vendor, product);
identifierAdded |= determineIdentifiers(dependency, vendor, product, confidence);
}
}
@@ -281,13 +281,11 @@ public class CPEAnalyzer implements Analyzer {
}
return ret;
} catch (ParseException ex) {
- final String msg = String.format("Unable to parse: %s", searchString);
- LOGGER.log(Level.WARNING, "An error occured querying the CPE data. See the log for more details.");
- LOGGER.log(Level.INFO, msg, ex);
+ LOGGER.warn("An error occured querying the CPE data. See the log for more details.");
+ LOGGER.info("Unable to parse: {}", searchString, ex);
} catch (IOException ex) {
- final String msg = String.format("IO Error with search string: %s", searchString);
- LOGGER.log(Level.WARNING, "An error occured reading CPE data. See the log for more details.");
- LOGGER.log(Level.INFO, msg, ex);
+ LOGGER.warn("An error occured reading CPE data. See the log for more details.");
+ LOGGER.info("IO Error with search string: {}", searchString, ex);
}
return null;
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java
index 4654145f2..94074deb7 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java
@@ -23,8 +23,6 @@ import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
@@ -38,6 +36,8 @@ import org.owasp.dependencycheck.utils.DownloadFailedException;
import org.owasp.dependencycheck.utils.Downloader;
import org.owasp.dependencycheck.utils.InvalidSettingException;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Analyzer which will attempt to locate a dependency, and the GAV information, by querying Central for the dependency's SHA-1
@@ -50,7 +50,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(CentralAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(CentralAnalyzer.class);
/**
* The name of the analyzer.
@@ -103,7 +103,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
if (Settings.getBoolean(Settings.KEYS.ANALYZER_CENTRAL_ENABLED)) {
if (!Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED)
|| NexusAnalyzer.DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL))) {
- LOGGER.fine("Enabling the Central analyzer");
+ LOGGER.debug("Enabling the Central analyzer");
retval = true;
} else {
LOGGER.info("Nexus analyzer is enabled, disabling the Central Analyzer");
@@ -112,7 +112,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
LOGGER.info("Central analyzer disabled");
}
} catch (InvalidSettingException ise) {
- LOGGER.warning("Invalid setting. Disabling the Central analyzer");
+ LOGGER.warn("Invalid setting. Disabling the Central analyzer");
}
return retval;
}
@@ -124,11 +124,11 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
*/
@Override
public void initializeFileTypeAnalyzer() throws Exception {
- LOGGER.fine("Initializing Central analyzer");
- LOGGER.fine(String.format("Central analyzer enabled: %s", isEnabled()));
+ LOGGER.debug("Initializing Central analyzer");
+ LOGGER.debug("Central analyzer enabled: {}", isEnabled());
if (isEnabled()) {
final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_CENTRAL_URL);
- LOGGER.fine(String.format("Central Analyzer URL: %s", searchUrl));
+ LOGGER.debug("Central Analyzer URL: {}", searchUrl);
searcher = new CentralSearch(new URL(searchUrl));
}
}
@@ -190,7 +190,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
final List mas = searcher.searchSha1(dependency.getSha1sum());
final Confidence confidence = mas.size() > 1 ? Confidence.HIGH : Confidence.HIGHEST;
for (MavenArtifact ma : mas) {
- LOGGER.fine(String.format("Central analyzer found artifact (%s) for dependency (%s)", ma.toString(), dependency.getFileName()));
+ LOGGER.debug("Central analyzer found artifact ({}) for dependency ({})", ma.toString(), dependency.getFileName());
dependency.addAsEvidence("central", ma, confidence);
boolean pomAnalyzed = false;
for (Evidence e : dependency.getVendorEvidence()) {
@@ -205,19 +205,17 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
final File baseDir = Settings.getTempDirectory();
pomFile = File.createTempFile("pom", ".xml", baseDir);
if (!pomFile.delete()) {
- final String msg = String.format("Unable to fetch pom.xml for %s from Central; "
- + "this could result in undetected CPE/CVEs.", dependency.getFileName());
- LOGGER.warning(msg);
- LOGGER.fine("Unable to delete temp file");
+ LOGGER.warn("Unable to fetch pom.xml for {} from Central; "
+ + "this could result in undetected CPE/CVEs.", dependency.getFileName());
+ LOGGER.debug("Unable to delete temp file");
}
- LOGGER.fine(String.format("Downloading %s", ma.getPomUrl()));
+ LOGGER.debug("Downloading {}", ma.getPomUrl());
Downloader.fetchFile(new URL(ma.getPomUrl()), pomFile);
PomUtils.analyzePOM(dependency, pomFile);
} catch (DownloadFailedException ex) {
- final String msg = String.format("Unable to download pom.xml for %s from Central; "
- + "this could result in undetected CPE/CVEs.", dependency.getFileName());
- LOGGER.warning(msg);
+ LOGGER.warn("Unable to download pom.xml for {} from Central; "
+ + "this could result in undetected CPE/CVEs.", dependency.getFileName());
} finally {
if (pomFile != null && !FileUtils.deleteQuietly(pomFile)) {
pomFile.deleteOnExit();
@@ -227,11 +225,11 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer {
}
} catch (IllegalArgumentException iae) {
- LOGGER.info(String.format("invalid sha1-hash on %s", dependency.getFileName()));
+ LOGGER.info("invalid sha1-hash on {}", dependency.getFileName());
} catch (FileNotFoundException fnfe) {
- LOGGER.fine(String.format("Artifact not found in repository: '%s", dependency.getFileName()));
+ LOGGER.debug("Artifact not found in repository: '{}", dependency.getFileName());
} catch (IOException ioe) {
- LOGGER.log(Level.FINE, "Could not connect to Central search", ioe);
+ LOGGER.debug("Could not connect to Central search", ioe);
errorFlag = true;
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
index 835547220..9517df123 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/DependencyBundlingAnalyzer.java
@@ -22,8 +22,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.owasp.dependencycheck.Engine;
@@ -33,6 +31,8 @@ import org.owasp.dependencycheck.dependency.Identifier;
import org.owasp.dependencycheck.utils.DependencyVersion;
import org.owasp.dependencycheck.utils.DependencyVersionUtil;
import org.owasp.dependencycheck.utils.LogUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -49,7 +49,7 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
/**
* The Logger.
*/
- private static final Logger LOGGER = Logger.getLogger(DependencyBundlingAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(DependencyBundlingAnalyzer.class);
//
/**
@@ -264,8 +264,7 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
}
if (LogUtils.isVerboseLoggingEnabled()) {
- final String msg = String.format("IdentifiersMatch=%s (%s, %s)", matches, dependency1.getFileName(), dependency2.getFileName());
- LOGGER.log(Level.FINE, msg);
+ LOGGER.debug("IdentifiersMatch={} ({}, {})", matches, dependency1.getFileName(), dependency2.getFileName());
}
return matches;
}
@@ -345,8 +344,7 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
returnVal = leftName.length() <= rightName.length();
}
if (LogUtils.isVerboseLoggingEnabled()) {
- final String msg = String.format("IsCore=%s (%s, %s)", returnVal, left.getFileName(), right.getFileName());
- LOGGER.log(Level.FINE, msg);
+ LOGGER.debug("IsCore={} ({}, {})", returnVal, left.getFileName(), right.getFileName());
}
return returnVal;
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java
index 0cf9004ac..b4d41ae37 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FalsePositiveAnalyzer.java
@@ -25,8 +25,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.owasp.dependencycheck.Engine;
@@ -34,6 +32,8 @@ import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.dependency.Identifier;
import org.owasp.dependencycheck.dependency.VulnerableSoftware;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This analyzer attempts to remove some well known false positives - specifically regarding the java runtime.
@@ -45,7 +45,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
/**
* The Logger.
*/
- private static final Logger LOGGER = Logger.getLogger(FalsePositiveAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(FalsePositiveAnalyzer.class);
//
/**
* The name of the analyzer.
@@ -171,7 +171,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
final String nextVersion = nextCpe.getVersion();
if (currentVersion == null && nextVersion == null) {
//how did we get here?
- LOGGER.log(Level.FINE, "currentVersion and nextVersion are both null?");
+ LOGGER.debug("currentVersion and nextVersion are both null?");
} else if (currentVersion == null && nextVersion != null) {
dependency.getIdentifiers().remove(currentId);
} else if (nextVersion == null && currentVersion != null) {
@@ -248,7 +248,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
try {
cpe.parseName(value);
} catch (UnsupportedEncodingException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
return null;
}
return cpe;
@@ -397,7 +397,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
newCpe4,
String.format(CPEAnalyzer.NVD_SEARCH_URL, URLEncoder.encode(newCpe4, "UTF-8")));
} catch (UnsupportedEncodingException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
}
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JarAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JarAnalyzer.java
index a424d1d79..f22b52fda 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JarAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JarAnalyzer.java
@@ -39,8 +39,6 @@ import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import org.jsoup.Jsoup;
@@ -54,6 +52,8 @@ import org.owasp.dependencycheck.xml.pom.PomUtils;
import org.owasp.dependencycheck.xml.pom.Model;
import org.owasp.dependencycheck.utils.FileUtils;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Used to load a JAR file and collect information that can be used to determine the associated CPE.
@@ -66,7 +66,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(JarAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(JarAnalyzer.class);
/**
* The buffer size to use when extracting files from the archive.
*/
@@ -249,20 +249,16 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
try {
jar = new JarFile(dependency.getActualFilePath());
} catch (IOException ex) {
- final String msg = String.format("Unable to read JarFile '%s'.", dependency.getActualFilePath());
- //final AnalysisException ax = new AnalysisException(msg, ex);
- LOGGER.log(Level.WARNING, msg);
- LOGGER.log(Level.FINE, "", ex);
+ LOGGER.warn("Unable to read JarFile '{}'.", dependency.getActualFilePath());
+ LOGGER.trace("", ex);
return false;
}
List pomEntries;
try {
pomEntries = retrievePomListing(jar);
} catch (IOException ex) {
- final String msg = String.format("Unable to read Jar file entries in '%s'.", dependency.getActualFilePath());
- //final AnalysisException ax = new AnalysisException(msg, ex);
- LOGGER.log(Level.WARNING, msg);
- LOGGER.log(Level.FINE, msg, ex);
+ LOGGER.warn("Unable to read Jar file entries in '{}'.", dependency.getActualFilePath());
+ LOGGER.trace("", ex);
return false;
}
File externalPom = null;
@@ -277,14 +273,14 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
}
}
for (String path : pomEntries) {
- LOGGER.fine(String.format("Reading pom entry: %s", path));
+ LOGGER.debug("Reading pom entry: {}", path);
Properties pomProperties = null;
try {
if (externalPom == null) {
pomProperties = retrievePomProperties(path, jar);
}
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, "ignore this, failed reading a non-existent pom.properties", ex);
+ LOGGER.trace("ignore this, failed reading a non-existent pom.properties", ex);
}
Model pom = null;
try {
@@ -318,9 +314,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
foundSomething |= setPomEvidence(dependency, pom, classes);
}
} catch (AnalysisException ex) {
- final String msg = String.format("An error occured while analyzing '%s'.", dependency.getActualFilePath());
- LOGGER.log(Level.WARNING, msg);
- LOGGER.log(Level.FINE, "", ex);
+ LOGGER.warn("An error occured while analyzing '{}'.", dependency.getActualFilePath());
+ LOGGER.trace("", ex);
}
}
return foundSomething;
@@ -344,13 +339,13 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
reader = new InputStreamReader(jar.getInputStream(propEntry), "UTF-8");
pomProperties = new Properties();
pomProperties.load(reader);
- LOGGER.fine(String.format("Read pom.properties: %s", propPath));
+ LOGGER.debug("Read pom.properties: {}", propPath);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, "close error", ex);
+ LOGGER.trace("close error", ex);
}
}
}
@@ -372,7 +367,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
final JarEntry entry = entries.nextElement();
final String entryName = (new File(entry.getName())).getName().toLowerCase();
if (!entry.isDirectory() && "pom.xml".equals(entryName)) {
- LOGGER.fine(String.format("POM Entry found: %s", entry.getName()));
+ LOGGER.trace("POM Entry found: {}", entry.getName());
pomEntries.add(entry.getName());
}
}
@@ -408,9 +403,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
bos.flush();
dependency.setActualFilePath(file.getAbsolutePath());
} catch (IOException ex) {
- final String msg = String.format("An error occurred reading '%s' from '%s'.", path, dependency.getFilePath());
- LOGGER.warning(msg);
- LOGGER.log(Level.SEVERE, "", ex);
+ LOGGER.warn("An error occurred reading '{}' from '{}'.", path, dependency.getFilePath());
+ LOGGER.error("", ex);
} finally {
closeStream(bos);
closeStream(fos);
@@ -429,7 +423,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
try {
stream.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
@@ -444,7 +438,7 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
try {
stream.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
@@ -644,9 +638,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
&& !dependency.getFileName().toLowerCase().endsWith("-javadoc.jar")
&& !dependency.getFileName().toLowerCase().endsWith("-src.jar")
&& !dependency.getFileName().toLowerCase().endsWith("-doc.jar")) {
- LOGGER.log(Level.FINE,
- String.format("Jar file '%s' does not contain a manifest.",
- dependency.getFileName()));
+ LOGGER.debug("Jar file '{}' does not contain a manifest.",
+ dependency.getFileName());
}
return false;
}
@@ -892,11 +885,10 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
@Override
public void close() {
if (tempFileLocation != null && tempFileLocation.exists()) {
- LOGGER.log(Level.FINE, "Attempting to delete temporary files");
+ LOGGER.debug("Attempting to delete temporary files");
final boolean success = FileUtils.delete(tempFileLocation);
if (!success) {
- LOGGER.log(Level.WARNING,
- "Failed to delete some temporary files, see the log for more details");
+ LOGGER.warn("Failed to delete some temporary files, see the log for more details");
}
}
}
@@ -937,15 +929,14 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
}
}
} catch (IOException ex) {
- final String msg = String.format("Unable to open jar file '%s'.", dependency.getFileName());
- LOGGER.log(Level.WARNING, msg);
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.warn("Unable to open jar file '{}'.", dependency.getFileName());
+ LOGGER.debug("", ex);
} finally {
if (jar != null) {
try {
jar.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzer.java
index 5b72fff84..077a6d667 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/JavaScriptAnalyzer.java
@@ -23,13 +23,13 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -42,7 +42,7 @@ public class JavaScriptAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(JavaScriptAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(JavaScriptAnalyzer.class);
//
/**
@@ -122,13 +122,13 @@ public class JavaScriptAnalyzer extends AbstractFileTypeAnalyzer {
final String msg = String.format("Dependency file not found: '%s'", dependency.getActualFilePath());
throw new AnalysisException(msg, ex);
} catch (IOException ex) {
- LOGGER.log(Level.SEVERE, null, ex);
+ LOGGER.error("", ex);
} finally {
if (fin != null) {
try {
fin.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java
index e2f2fa107..101163745 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java
@@ -23,8 +23,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
@@ -38,6 +36,8 @@ import org.owasp.dependencycheck.utils.InvalidSettingException;
import org.owasp.dependencycheck.utils.DownloadFailedException;
import org.owasp.dependencycheck.utils.Downloader;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Analyzer which will attempt to locate a dependency on a Nexus service by SHA-1 digest of the dependency.
@@ -63,7 +63,7 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(NexusAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(NexusAnalyzer.class);
/**
* The name of the analyzer.
@@ -107,10 +107,10 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
LOGGER.info("Enabling Nexus analyzer");
retval = true;
} else {
- LOGGER.fine("Nexus analyzer disabled, using Central instead");
+ LOGGER.debug("Nexus analyzer disabled, using Central instead");
}
} catch (InvalidSettingException ise) {
- LOGGER.warning("Invalid setting. Disabling Nexus analyzer");
+ LOGGER.warn("Invalid setting. Disabling Nexus analyzer");
}
return retval;
@@ -133,21 +133,21 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
*/
@Override
public void initializeFileTypeAnalyzer() throws Exception {
- LOGGER.fine("Initializing Nexus Analyzer");
- LOGGER.fine(String.format("Nexus Analyzer enabled: %s", isEnabled()));
+ LOGGER.debug("Initializing Nexus Analyzer");
+ LOGGER.debug("Nexus Analyzer enabled: {}", isEnabled());
if (isEnabled()) {
final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL);
- LOGGER.fine(String.format("Nexus Analyzer URL: %s", searchUrl));
+ LOGGER.debug("Nexus Analyzer URL: {}", searchUrl);
try {
searcher = new NexusSearch(new URL(searchUrl));
if (!searcher.preflightRequest()) {
- LOGGER.warning("There was an issue getting Nexus status. Disabling analyzer.");
+ LOGGER.warn("There was an issue getting Nexus status. Disabling analyzer.");
setEnabled(false);
}
} catch (MalformedURLException mue) {
// I know that initialize can throw an exception, but we'll
// just disable the analyzer if the URL isn't valid
- LOGGER.warning(String.format("Property %s not a valid URL. Nexus Analyzer disabled", searchUrl));
+ LOGGER.warn("Property {} not a valid URL. Nexus Analyzer disabled", searchUrl);
setEnabled(false);
}
}
@@ -209,7 +209,7 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
final MavenArtifact ma = searcher.searchSha1(dependency.getSha1sum());
dependency.addAsEvidence("nexus", ma, Confidence.HIGH);
boolean pomAnalyzed = false;
- LOGGER.fine("POM URL " + ma.getPomUrl());
+ LOGGER.debug("POM URL {}", ma.getPomUrl());
for (Evidence e : dependency.getVendorEvidence()) {
if ("pom".equals(e.getSource())) {
pomAnalyzed = true;
@@ -222,18 +222,16 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
final File baseDir = Settings.getTempDirectory();
pomFile = File.createTempFile("pom", ".xml", baseDir);
if (!pomFile.delete()) {
- final String msg = String.format("Unable to fetch pom.xml for %s from Nexus repository; "
- + "this could result in undetected CPE/CVEs.", dependency.getFileName());
- LOGGER.warning(msg);
- LOGGER.fine("Unable to delete temp file");
+ LOGGER.warn("Unable to fetch pom.xml for {} from Nexus repository; "
+ + "this could result in undetected CPE/CVEs.", dependency.getFileName());
+ LOGGER.debug("Unable to delete temp file");
}
- LOGGER.fine(String.format("Downloading %s", ma.getPomUrl()));
+ LOGGER.debug("Downloading {}", ma.getPomUrl());
Downloader.fetchFile(new URL(ma.getPomUrl()), pomFile);
PomUtils.analyzePOM(dependency, pomFile);
} catch (DownloadFailedException ex) {
- final String msg = String.format("Unable to download pom.xml for %s from Nexus repository; "
- + "this could result in undetected CPE/CVEs.", dependency.getFileName());
- LOGGER.warning(msg);
+ LOGGER.warn("Unable to download pom.xml for {} from Nexus repository; "
+ + "this could result in undetected CPE/CVEs.", dependency.getFileName());
} finally {
if (pomFile != null && !FileUtils.deleteQuietly(pomFile)) {
pomFile.deleteOnExit();
@@ -245,11 +243,11 @@ public class NexusAnalyzer extends AbstractFileTypeAnalyzer {
LOGGER.info(String.format("invalid sha-1 hash on %s", dependency.getFileName()));
} catch (FileNotFoundException fnfe) {
//dependency.addAnalysisException(new AnalysisException("Artifact not found on repository"));
- LOGGER.fine(String.format("Artifact not found in repository '%s'", dependency.getFileName()));
- LOGGER.log(Level.FINE, fnfe.getMessage(), fnfe);
+ LOGGER.debug("Artifact not found in repository '{}'", dependency.getFileName());
+ LOGGER.debug(fnfe.getMessage(), fnfe);
} catch (IOException ioe) {
//dependency.addAnalysisException(new AnalysisException("Could not connect to repository", ioe));
- LOGGER.log(Level.FINE, "Could not connect to nexus repository", ioe);
+ LOGGER.debug("Could not connect to nexus repository", ioe);
}
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NuspecAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NuspecAnalyzer.java
index 14109dede..237b349ae 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NuspecAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NuspecAnalyzer.java
@@ -21,8 +21,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.exception.AnalysisException;
import org.owasp.dependencycheck.data.nuget.NugetPackage;
@@ -32,6 +30,8 @@ import org.owasp.dependencycheck.data.nuget.XPathNuspecParser;
import org.owasp.dependencycheck.dependency.Confidence;
import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Analyzer which will parse a Nuspec file to gather module information.
@@ -43,7 +43,7 @@ public class NuspecAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(NuspecAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(NuspecAnalyzer.class);
/**
* The name of the analyzer.
@@ -118,7 +118,7 @@ public class NuspecAnalyzer extends AbstractFileTypeAnalyzer {
*/
@Override
public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException {
- LOGGER.log(Level.FINE, "Checking Nuspec file {0}", dependency.toString());
+ LOGGER.debug("Checking Nuspec file {}", dependency.toString());
try {
final NuspecParser parser = new XPathNuspecParser();
NugetPackage np = null;
@@ -135,7 +135,7 @@ public class NuspecAnalyzer extends AbstractFileTypeAnalyzer {
try {
fis.close();
} catch (IOException e) {
- LOGGER.fine("Error closing input stream");
+ LOGGER.debug("Error closing input stream");
}
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java
index aa0628e81..6b31c6973 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonDistributionAnalyzer.java
@@ -23,8 +23,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.mail.MessagingException;
@@ -44,6 +42,8 @@ import org.owasp.dependencycheck.utils.ExtractionUtil;
import org.owasp.dependencycheck.utils.FileUtils;
import org.owasp.dependencycheck.utils.Settings;
import org.owasp.dependencycheck.utils.UrlStringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Used to analyze a Wheel or egg distribution files, or their contents in unzipped form, and collect information that can be used
@@ -66,8 +66,8 @@ public class PythonDistributionAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger
- .getLogger(PythonDistributionAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(PythonDistributionAnalyzer.class);
/**
* The count of directories created during analysis. This is used for creating temporary directories.
@@ -203,7 +203,7 @@ public class PythonDistributionAnalyzer extends AbstractFileTypeAnalyzer {
FilenameFilter folderFilter, FilenameFilter metadataFilter)
throws AnalysisException {
final File temp = getNextTempDirectory();
- LOGGER.fine(String.format("%s exists? %b", temp, temp.exists()));
+ LOGGER.debug("{} exists? {}", temp, temp.exists());
try {
ExtractionUtil.extractFilesUsingFilter(
new File(dependency.getActualFilePath()), temp,
@@ -247,10 +247,10 @@ public class PythonDistributionAnalyzer extends AbstractFileTypeAnalyzer {
@Override
public void close() {
if (tempFileLocation != null && tempFileLocation.exists()) {
- LOGGER.log(Level.FINE, "Attempting to delete temporary files");
+ LOGGER.debug("Attempting to delete temporary files");
final boolean success = FileUtils.delete(tempFileLocation);
if (!success) {
- LOGGER.log(Level.WARNING,
+ LOGGER.warn(
"Failed to delete some temporary files, see the log for more details");
}
}
@@ -298,7 +298,7 @@ public class PythonDistributionAnalyzer extends AbstractFileTypeAnalyzer {
private static void addPropertyToEvidence(InternetHeaders headers,
EvidenceCollection evidence, String property, Confidence confidence) {
final String value = headers.getHeader(property, null);
- LOGGER.fine(String.format("Property: %s, Value: %s", property, value));
+ LOGGER.debug("Property: {}, Value: {}", property, value);
if (StringUtils.isNotBlank(value)) {
evidence.addEvidence(METADATA, property, value, confidence);
}
@@ -329,15 +329,15 @@ public class PythonDistributionAnalyzer extends AbstractFileTypeAnalyzer {
private static InternetHeaders getManifestProperties(File manifest) {
final InternetHeaders result = new InternetHeaders();
if (null == manifest) {
- LOGGER.fine("Manifest file not found.");
+ LOGGER.debug("Manifest file not found.");
} else {
try {
result.load(new AutoCloseInputStream(new BufferedInputStream(
new FileInputStream(manifest))));
} catch (MessagingException e) {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
+ LOGGER.warn(e.getMessage(), e);
} catch (FileNotFoundException e) {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
+ LOGGER.warn(e.getMessage(), e);
}
}
return result;
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonPackageAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonPackageAnalyzer.java
index 4895a8134..a2080792f 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonPackageAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/PythonPackageAnalyzer.java
@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -39,6 +38,8 @@ import org.owasp.dependencycheck.dependency.Dependency;
import org.owasp.dependencycheck.dependency.EvidenceCollection;
import org.owasp.dependencycheck.utils.Settings;
import org.owasp.dependencycheck.utils.UrlStringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Used to analyze a Python package, and collect information that can be used to determine the associated CPE.
@@ -56,8 +57,8 @@ public class PythonPackageAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger
- .getLogger(PythonPackageAnalyzer.class.getName());
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(PythonPackageAnalyzer.class);
/**
* Filename extensions for files to be analyzed.
@@ -240,7 +241,7 @@ public class PythonPackageAnalyzer extends AbstractFileTypeAnalyzer {
found |= gatherHomePageEvidence(HOMEPAGE_PATTERN,
vendorEvidence, source, "HomePage", contents);
} catch (MalformedURLException e) {
- LOGGER.warning(e.getMessage());
+ LOGGER.warn(e.getMessage());
}
}
return found;
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java
index 2905990ce..53bdd37d5 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java
@@ -23,7 +23,6 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
@@ -32,6 +31,8 @@ import javax.xml.xpath.XPathFactory;
import org.owasp.dependencycheck.data.nexus.MavenArtifact;
import org.owasp.dependencycheck.utils.Settings;
import org.owasp.dependencycheck.utils.URLConnectionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -55,7 +56,7 @@ public class CentralSearch {
/**
* Used for logging.
*/
- private static final Logger LOGGER = Logger.getLogger(CentralSearch.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(CentralSearch.class);
/**
* Creates a NexusSearch for the given repository URL.
@@ -67,10 +68,10 @@ public class CentralSearch {
this.rootURL = rootURL;
if (null != Settings.getString(Settings.KEYS.PROXY_SERVER)) {
useProxy = true;
- LOGGER.fine("Using proxy");
+ LOGGER.debug("Using proxy");
} else {
useProxy = false;
- LOGGER.fine("Not using proxy");
+ LOGGER.debug("Not using proxy");
}
}
@@ -89,7 +90,7 @@ public class CentralSearch {
final URL url = new URL(rootURL + String.format("?q=1:\"%s\"&wt=xml", sha1));
- LOGGER.fine(String.format("Searching Central url %s", url.toString()));
+ LOGGER.debug("Searching Central url {}", url.toString());
// Determine if we need to use a proxy. The rules:
// 1) If the proxy is set, AND the setting is set to true, use the proxy
@@ -119,9 +120,9 @@ public class CentralSearch {
final NodeList docs = (NodeList) xpath.evaluate("/response/result/doc", doc, XPathConstants.NODESET);
for (int i = 0; i < docs.getLength(); i++) {
final String g = xpath.evaluate("./str[@name='g']", docs.item(i));
- LOGGER.finest(String.format("GroupId: %s", g));
+ LOGGER.trace("GroupId: {}", g);
final String a = xpath.evaluate("./str[@name='a']", docs.item(i));
- LOGGER.finest(String.format("ArtifactId: %s", a));
+ LOGGER.trace("ArtifactId: {}", a);
final String v = xpath.evaluate("./str[@name='v']", docs.item(i));
NodeList atts = (NodeList) xpath.evaluate("./arr[@name='ec']/str", docs.item(i), XPathConstants.NODESET);
boolean pomAvailable = false;
@@ -144,7 +145,7 @@ public class CentralSearch {
}
}
- LOGGER.finest(String.format("Version: %s", v));
+ LOGGER.trace("Version: {}", v);
result.add(new MavenArtifact(g, a, v, jarAvailable, pomAvailable, useHTTPS));
}
@@ -160,10 +161,9 @@ public class CentralSearch {
throw new FileNotFoundException("Artifact not found in Central");
}
} else {
- final String msg = String.format("Could not connect to Central received response code: %d %s",
- conn.getResponseCode(), conn.getResponseMessage());
- LOGGER.fine(msg);
- throw new IOException(msg);
+ LOGGER.debug("Could not connect to Central received response code: {} {}",
+ conn.getResponseCode(), conn.getResponseMessage());
+ throw new IOException("Could not connect to Central");
}
return null;
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java
index e0389c99d..3f80b2d8f 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cpe/CpeMemoryIndex.java
@@ -21,8 +21,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordAnalyzer;
import org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper;
@@ -46,6 +44,8 @@ import org.owasp.dependencycheck.data.lucene.SearchFieldAnalyzer;
import org.owasp.dependencycheck.data.nvdcve.CveDB;
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
import org.owasp.dependencycheck.utils.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An in memory lucene index that contains the vendor/product combinations from the CPE (application) identifiers within the NVD
@@ -58,7 +58,7 @@ public final class CpeMemoryIndex {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(CpeMemoryIndex.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(CpeMemoryIndex.class);
/**
* singleton instance.
*/
@@ -203,7 +203,7 @@ public final class CpeMemoryIndex {
try {
indexReader.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
indexReader = null;
}
@@ -235,7 +235,7 @@ public final class CpeMemoryIndex {
saveEntry(pair.getLeft(), pair.getRight(), indexWriter);
}
} catch (DatabaseException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
throw new IndexException("Error reading CPE data", ex);
}
} catch (CorruptIndexException ex) {
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cwe/CweDB.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cwe/CweDB.java
index 106de1a50..b17e3ca7d 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cwe/CweDB.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/cwe/CweDB.java
@@ -17,12 +17,13 @@
*/
package org.owasp.dependencycheck.data.cwe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.util.HashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
*
@@ -33,7 +34,7 @@ public final class CweDB {
/**
* The Logger.
*/
- private static final Logger LOGGER = Logger.getLogger(CweDB.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(CweDB.class);
/**
* Empty private constructor as this is a utility class.
@@ -61,17 +62,17 @@ public final class CweDB {
final HashMap ret = (HashMap) oin.readObject();
return ret;
} catch (ClassNotFoundException ex) {
- LOGGER.log(Level.WARNING, "Unable to load CWE data. This should not be an issue.");
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.warn("Unable to load CWE data. This should not be an issue.");
+ LOGGER.debug("", ex);
} catch (IOException ex) {
- LOGGER.log(Level.WARNING, "Unable to load CWE data due to an IO Error. This should not be an issue.");
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.warn("Unable to load CWE data due to an IO Error. This should not be an issue.");
+ LOGGER.debug("", ex);
} finally {
if (oin != null) {
try {
oin.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/UrlTokenizingFilter.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/UrlTokenizingFilter.java
index 41cd19f09..dd310f05e 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/UrlTokenizingFilter.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/lucene/UrlTokenizingFilter.java
@@ -21,11 +21,11 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.util.LinkedList;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.owasp.dependencycheck.utils.UrlStringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -39,7 +39,7 @@ public final class UrlTokenizingFilter extends AbstractTokenizingFilter {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(UrlTokenizingFilter.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(UrlTokenizingFilter.class);
/**
* Constructs a new VersionTokenizingFilter.
*
@@ -70,7 +70,7 @@ public final class UrlTokenizingFilter extends AbstractTokenizingFilter {
final List data = UrlStringUtils.extractImportantUrlData(part);
tokens.addAll(data);
} catch (MalformedURLException ex) {
- LOGGER.log(Level.FINE, "error parsing " + part, ex);
+ LOGGER.debug("error parsing {}", part, ex);
tokens.add(part);
}
} else {
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nexus/NexusSearch.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nexus/NexusSearch.java
index 21ade08c3..996826ba5 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nexus/NexusSearch.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nexus/NexusSearch.java
@@ -21,8 +21,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
@@ -30,6 +28,8 @@ import javax.xml.xpath.XPathFactory;
import org.owasp.dependencycheck.utils.InvalidSettingException;
import org.owasp.dependencycheck.utils.Settings;
import org.owasp.dependencycheck.utils.URLConnectionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
/**
@@ -59,7 +59,7 @@ public class NexusSearch {
/**
* Used for logging.
*/
- private static final Logger LOGGER = Logger.getLogger(NexusSearch.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(NexusSearch.class);
/**
* Creates a NexusSearch for the given repository URL.
@@ -73,10 +73,10 @@ public class NexusSearch {
if (null != Settings.getString(Settings.KEYS.PROXY_SERVER)
&& Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY)) {
useProxy = true;
- LOGGER.fine("Using proxy");
+ LOGGER.debug("Using proxy");
} else {
useProxy = false;
- LOGGER.fine("Not using proxy");
+ LOGGER.debug("Not using proxy");
}
} catch (InvalidSettingException ise) {
useProxy = false;
@@ -99,7 +99,7 @@ public class NexusSearch {
final URL url = new URL(rootURL, String.format("identify/sha1/%s",
sha1.toLowerCase()));
- LOGGER.fine(String.format("Searching Nexus url %s", url.toString()));
+ LOGGER.debug("Searching Nexus url {}", url);
// Determine if we need to use a proxy. The rules:
// 1) If the proxy is set, AND the setting is set to true, use the proxy
@@ -155,10 +155,9 @@ public class NexusSearch {
} else if (conn.getResponseCode() == 404) {
throw new FileNotFoundException("Artifact not found in Nexus");
} else {
- final String msg = String.format("Could not connect to Nexus received response code: %d %s",
- conn.getResponseCode(), conn.getResponseMessage());
- LOGGER.fine(msg);
- throw new IOException(msg);
+ LOGGER.debug("Could not connect to Nexus received response code: {} {}",
+ conn.getResponseCode(), conn.getResponseMessage());
+ throw new IOException("Could not connect to Nexus");
}
}
@@ -175,13 +174,13 @@ public class NexusSearch {
conn.addRequestProperty("Accept", "application/xml");
conn.connect();
if (conn.getResponseCode() != 200) {
- LOGGER.log(Level.WARNING, "Expected 200 result from Nexus, got {0}", conn.getResponseCode());
+ LOGGER.warn("Expected 200 result from Nexus, got {}", conn.getResponseCode());
return false;
}
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
final Document doc = builder.parse(conn.getInputStream());
if (!"status".equals(doc.getDocumentElement().getNodeName())) {
- LOGGER.log(Level.WARNING, "Expected root node name of status, got {0}", doc.getDocumentElement().getNodeName());
+ LOGGER.warn("Expected root node name of status, got {}", doc.getDocumentElement().getNodeName());
return false;
}
} catch (Throwable e) {
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java
index e29c28e55..a2c05f2b2 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/ConnectionFactory.java
@@ -29,10 +29,10 @@ import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.owasp.dependencycheck.utils.DBUtils;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Loads the configured database driver and returns the database connection. If the embedded H2 database is used
@@ -46,7 +46,7 @@ public final class ConnectionFactory {
/**
* The Logger.
*/
- private static final Logger LOGGER = Logger.getLogger(ConnectionFactory.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionFactory.class);
/**
* The version of the current DB Schema.
*/
@@ -94,17 +94,17 @@ public final class ConnectionFactory {
//load the driver if necessary
final String driverName = Settings.getString(Settings.KEYS.DB_DRIVER_NAME, "");
if (!driverName.isEmpty()) { //likely need to load the correct driver
- LOGGER.log(Level.FINE, "Loading driver: {0}", driverName);
+ LOGGER.debug("Loading driver: {}", driverName);
final String driverPath = Settings.getString(Settings.KEYS.DB_DRIVER_PATH, "");
try {
if (!driverPath.isEmpty()) {
- LOGGER.log(Level.FINE, "Loading driver from: {0}", driverPath);
+ LOGGER.debug("Loading driver from: {}", driverPath);
driver = DriverLoader.load(driverName, driverPath);
} else {
driver = DriverLoader.load(driverName);
}
} catch (DriverLoadException ex) {
- LOGGER.log(Level.FINE, "Unable to load database driver", ex);
+ LOGGER.debug("Unable to load database driver", ex);
throw new DatabaseException("Unable to load database driver");
}
}
@@ -117,7 +117,7 @@ public final class ConnectionFactory {
Settings.KEYS.DB_FILE_NAME,
Settings.KEYS.DB_VERSION);
} catch (IOException ex) {
- LOGGER.log(Level.FINE,
+ LOGGER.debug(
"Unable to retrieve the database connection string", ex);
throw new DatabaseException("Unable to retrieve the database connection string");
}
@@ -125,15 +125,15 @@ public final class ConnectionFactory {
try {
if (connectionString.startsWith("jdbc:h2:file:")) { //H2
shouldCreateSchema = !h2DataFileExists();
- LOGGER.log(Level.FINE, "Need to create DB Structure: {0}", shouldCreateSchema);
+ LOGGER.debug("Need to create DB Structure: {}", shouldCreateSchema);
}
} catch (IOException ioex) {
- LOGGER.log(Level.FINE, "Unable to verify database exists", ioex);
+ LOGGER.debug("Unable to verify database exists", ioex);
throw new DatabaseException("Unable to verify database exists");
}
- LOGGER.log(Level.FINE, "Loading database connection");
- LOGGER.log(Level.FINE, "Connection String: {0}", connectionString);
- LOGGER.log(Level.FINE, "Database User: {0}", userName);
+ LOGGER.debug("Loading database connection");
+ LOGGER.debug("Connection String: {}", connectionString);
+ LOGGER.debug("Database User: {}", userName);
try {
conn = DriverManager.getConnection(connectionString, userName, password);
@@ -143,14 +143,14 @@ public final class ConnectionFactory {
try {
conn = DriverManager.getConnection(connectionString, userName, password);
Settings.setString(Settings.KEYS.DB_CONNECTION_STRING, connectionString);
- LOGGER.log(Level.FINE,
+ LOGGER.debug(
"Unable to start the database in server mode; reverting to single user mode");
} catch (SQLException sqlex) {
- LOGGER.log(Level.FINE, "Unable to connect to the database", ex);
+ LOGGER.debug("Unable to connect to the database", ex);
throw new DatabaseException("Unable to connect to the database");
}
} else {
- LOGGER.log(Level.FINE, "Unable to connect to the database", ex);
+ LOGGER.debug("Unable to connect to the database", ex);
throw new DatabaseException("Unable to connect to the database");
}
}
@@ -159,14 +159,14 @@ public final class ConnectionFactory {
try {
createTables(conn);
} catch (DatabaseException dex) {
- LOGGER.log(Level.FINE, null, dex);
+ LOGGER.debug("", dex);
throw new DatabaseException("Unable to create the database structure");
}
} else {
try {
ensureSchemaVersion(conn);
} catch (DatabaseException dex) {
- LOGGER.log(Level.FINE, null, dex);
+ LOGGER.debug("", dex);
throw new DatabaseException("Database schema does not match this version of dependency-check");
}
}
@@ -175,7 +175,7 @@ public final class ConnectionFactory {
try {
conn.close();
} catch (SQLException ex) {
- LOGGER.log(Level.FINE, "An error occurred closing the connection", ex);
+ LOGGER.debug("An error occurred closing the connection", ex);
}
}
}
@@ -191,9 +191,9 @@ public final class ConnectionFactory {
try {
DriverManager.deregisterDriver(driver);
} catch (SQLException ex) {
- LOGGER.log(Level.FINE, "An error occurred unloading the database driver", ex);
+ LOGGER.debug("An error occurred unloading the database driver", ex);
} catch (Throwable unexpected) {
- LOGGER.log(Level.FINE,
+ LOGGER.debug(
"An unexpected throwable occurred unloading the database driver", unexpected);
}
driver = null;
@@ -215,7 +215,7 @@ public final class ConnectionFactory {
try {
conn = DriverManager.getConnection(connectionString, userName, password);
} catch (SQLException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
throw new DatabaseException("Unable to connect to the database");
}
return conn;
@@ -242,7 +242,7 @@ public final class ConnectionFactory {
* @throws DatabaseException thrown if there is a Database Exception
*/
private static void createTables(Connection conn) throws DatabaseException {
- LOGGER.log(Level.FINE, "Creating database structure");
+ LOGGER.debug("Creating database structure");
InputStream is;
InputStreamReader reader;
BufferedReader in = null;
@@ -260,7 +260,7 @@ public final class ConnectionFactory {
statement = conn.createStatement();
statement.execute(sb.toString());
} catch (SQLException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
throw new DatabaseException("Unable to create database statement", ex);
} finally {
DBUtils.closeStatement(statement);
@@ -272,7 +272,7 @@ public final class ConnectionFactory {
try {
in.close();
} catch (IOException ex) {
- LOGGER.log(Level.FINEST, null, ex);
+ LOGGER.trace("", ex);
}
}
}
@@ -299,7 +299,7 @@ public final class ConnectionFactory {
throw new DatabaseException("Database schema is missing");
}
} catch (SQLException ex) {
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.debug("", ex);
throw new DatabaseException("Unable to check the database schema version");
} finally {
DBUtils.closeResultSet(rs);
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java
index 23a8c06d7..cdb522378 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/CveDB.java
@@ -33,8 +33,6 @@ import java.util.Map.Entry;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.owasp.dependencycheck.data.cwe.CweDB;
import org.owasp.dependencycheck.dependency.Reference;
import org.owasp.dependencycheck.dependency.Vulnerability;
@@ -44,6 +42,8 @@ import org.owasp.dependencycheck.utils.DependencyVersion;
import org.owasp.dependencycheck.utils.DependencyVersionUtil;
import org.owasp.dependencycheck.utils.Pair;
import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The database holding information about the NVD CVE data.
@@ -55,7 +55,7 @@ public class CveDB {
/**
* The logger.
*/
- private static final Logger LOGGER = Logger.getLogger(CveDB.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(CveDB.class);
/**
* Database connection
*/
@@ -110,13 +110,11 @@ public class CveDB {
try {
conn.close();
} catch (SQLException ex) {
- final String msg = "There was an error attempting to close the CveDB, see the log for more details.";
- LOGGER.log(Level.SEVERE, msg);
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.error("There was an error attempting to close the CveDB, see the log for more details.");
+ LOGGER.debug("", ex);
} catch (Throwable ex) {
- final String msg = "There was an exception attempting to close the CveDB, see the log for more details.";
- LOGGER.log(Level.SEVERE, msg);
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.error("There was an exception attempting to close the CveDB, see the log for more details.");
+ LOGGER.debug("", ex);
}
conn = null;
}
@@ -151,7 +149,7 @@ public class CveDB {
@Override
@SuppressWarnings("FinalizeDeclaration")
protected void finalize() throws Throwable {
- LOGGER.log(Level.FINE, "Entering finalize");
+ LOGGER.debug("Entering finalize");
close();
super.finalize();
}
@@ -193,9 +191,8 @@ public class CveDB {
cpe.add(vs);
}
} catch (SQLException ex) {
- final String msg = "An unexpected SQL Exception occurred; please see the verbose log for more details.";
- LOGGER.log(Level.SEVERE, msg);
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.error("An unexpected SQL Exception occurred; please see the verbose log for more details.");
+ LOGGER.debug("", ex);
} finally {
DBUtils.closeResultSet(rs);
DBUtils.closeStatement(ps);
@@ -245,9 +242,8 @@ public class CveDB {
prop.setProperty(rs.getString(1), rs.getString(2));
}
} catch (SQLException ex) {
- final String msg = "An unexpected SQL Exception occurred; please see the verbose log for more details.";
- LOGGER.log(Level.SEVERE, msg);
- LOGGER.log(Level.FINE, null, ex);
+ LOGGER.error("An unexpected SQL Exception occurred; please see the verbose log for more details.");
+ LOGGER.debug("", ex);
} finally {
DBUtils.closeStatement(ps);
DBUtils.closeResultSet(rs);
@@ -268,8 +264,8 @@ public class CveDB {
updateProperty = getConnection().prepareStatement(statementBundle.getString("UPDATE_PROPERTY"));
insertProperty = getConnection().prepareStatement(statementBundle.getString("INSERT_PROPERTY"));
} catch (SQLException ex) {
- LOGGER.log(Level.WARNING, "Unable to save properties to the database");
- LOGGER.log(Level.FINE, "Unable to save properties to the database", ex);
+ LOGGER.warn("Unable to save properties to the database");
+ LOGGER.debug("Unable to save properties to the database", ex);
return;
}
for (Entry