mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-20 16:24:11 +01:00
findbugs/checkstyle corrections
This commit is contained in:
@@ -27,7 +27,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
||||||
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
|
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
|
||||||
import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties;
|
import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties;
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ public final class CliParser {
|
|||||||
final Option pathToMono = Option.builder().argName("path").hasArg().longOpt(ARGUMENT.PATH_TO_MONO)
|
final Option pathToMono = Option.builder().argName("path").hasArg().longOpt(ARGUMENT.PATH_TO_MONO)
|
||||||
.desc("The path to Mono for .NET Assembly analysis on non-windows systems.")
|
.desc("The path to Mono for .NET Assembly analysis on non-windows systems.")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final Option pathToBundleAudit = Option.builder().argName("path").hasArg()
|
final Option pathToBundleAudit = Option.builder().argName("path").hasArg()
|
||||||
.longOpt(ARGUMENT.PATH_TO_BUNDLE_AUDIT)
|
.longOpt(ARGUMENT.PATH_TO_BUNDLE_AUDIT)
|
||||||
.desc("The path to bundle-audit for Gem bundle analysis.").build();
|
.desc("The path to bundle-audit for Gem bundle analysis.").build();
|
||||||
@@ -576,7 +576,6 @@ public final class CliParser {
|
|||||||
return (line != null) && line.hasOption(ARGUMENT.DISABLE_BUNDLE_AUDIT);
|
return (line != null) && line.hasOption(ARGUMENT.DISABLE_BUNDLE_AUDIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the disablePyDist command line argument was specified.
|
* Returns true if the disablePyDist command line argument was specified.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public enum AnalysisPhase {
|
|||||||
*/
|
*/
|
||||||
INITIAL,
|
INITIAL,
|
||||||
/**
|
/**
|
||||||
* Pre information collection phase
|
* Pre information collection phase.
|
||||||
*/
|
*/
|
||||||
PRE_INFORMATION_COLLECTION,
|
PRE_INFORMATION_COLLECTION,
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -212,8 +214,13 @@ public class CMakeAnalyzer extends AbstractFileTypeAnalyzer {
|
|||||||
final String filePath = String.format("%s:%s", dependency.getFilePath(), product);
|
final String filePath = String.format("%s:%s", dependency.getFilePath(), product);
|
||||||
currentDep.setFilePath(filePath);
|
currentDep.setFilePath(filePath);
|
||||||
|
|
||||||
// prevents coalescing into the dependency provided by engine
|
byte[] path;
|
||||||
currentDep.setSha1sum(Checksum.getHex(sha1.digest(filePath.getBytes())));
|
try {
|
||||||
|
path = filePath.getBytes("UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException ex) {
|
||||||
|
path = filePath.getBytes();
|
||||||
|
}
|
||||||
|
currentDep.setSha1sum(Checksum.getHex(sha1.digest(path)));
|
||||||
engine.getDependencies().add(currentDep);
|
engine.getDependencies().add(currentDep);
|
||||||
}
|
}
|
||||||
final String source = currentDep.getDisplayFileName();
|
final String source = currentDep.getDisplayFileName();
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ public class RubyBundleAuditAnalyzer extends AbstractFileTypeAnalyzer {
|
|||||||
*/
|
*/
|
||||||
private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.PRE_INFORMATION_COLLECTION;
|
private static final AnalysisPhase ANALYSIS_PHASE = AnalysisPhase.PRE_INFORMATION_COLLECTION;
|
||||||
|
|
||||||
private static final FileFilter FILTER =
|
private static final FileFilter FILTER
|
||||||
FileFilterBuilder.newInstance().addFilenames("Gemfile.lock").build();
|
= FileFilterBuilder.newInstance().addFilenames("Gemfile.lock").build();
|
||||||
public static final String NAME = "Name: ";
|
public static final String NAME = "Name: ";
|
||||||
public static final String VERSION = "Version: ";
|
public static final String VERSION = "Version: ";
|
||||||
public static final String ADVISORY = "Advisory: ";
|
public static final String ADVISORY = "Advisory: ";
|
||||||
@@ -113,7 +113,7 @@ public class RubyBundleAuditAnalyzer extends AbstractFileTypeAnalyzer {
|
|||||||
throw new AnalysisException("Bundle-audit error stream unexpectedly not ready.");
|
throw new AnalysisException("Bundle-audit error stream unexpectedly not ready.");
|
||||||
} else {
|
} else {
|
||||||
final String line = reader.readLine();
|
final String line = reader.readLine();
|
||||||
if (!line.contains("Errno::ENOENT")) {
|
if (line == null || !line.contains("Errno::ENOENT")) {
|
||||||
LOGGER.warn("Unexpected bundle-audit output. Disabling {}: {}", ANALYZER_NAME, line);
|
LOGGER.warn("Unexpected bundle-audit output. Disabling {}: {}", ANALYZER_NAME, line);
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
throw new AnalysisException("Unexpected bundle-audit output.");
|
throw new AnalysisException("Unexpected bundle-audit output.");
|
||||||
@@ -126,8 +126,8 @@ public class RubyBundleAuditAnalyzer extends AbstractFileTypeAnalyzer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
LOGGER.info(ANALYZER_NAME + " is enabled. It is necessary to manually run \"bundle-audit update\" " +
|
LOGGER.info(ANALYZER_NAME + " is enabled. It is necessary to manually run \"bundle-audit update\" "
|
||||||
"occasionally to keep its database up to date.");
|
+ "occasionally to keep its database up to date.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +162,8 @@ public class RubyBundleAuditAnalyzer extends AbstractFileTypeAnalyzer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If {@link #analyzeFileType(Dependency, Engine)} is called, then we have successfully initialized, and it will
|
* If {@link #analyzeFileType(Dependency, Engine)} is called, then we have successfully initialized, and it will be necessary
|
||||||
* be necessary to disable {@link RubyGemspecAnalyzer}.
|
* to disable {@link RubyGemspecAnalyzer}.
|
||||||
*/
|
*/
|
||||||
private boolean needToDisableGemspecAnalyzer = true;
|
private boolean needToDisableGemspecAnalyzer = true;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.io.IOException;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.logging.Level;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
||||||
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
|
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
|
||||||
@@ -128,7 +127,7 @@ public class EngineVersionCheck implements CachedWebDataSource {
|
|||||||
protected boolean shouldUpdate(final long lastChecked, final long now, final DatabaseProperties properties,
|
protected boolean shouldUpdate(final long lastChecked, final long now, final DatabaseProperties properties,
|
||||||
String currentVersion) throws UpdateException {
|
String currentVersion) throws UpdateException {
|
||||||
//check every 30 days if we know there is an update, otherwise check every 7 days
|
//check every 30 days if we know there is an update, otherwise check every 7 days
|
||||||
int checkRange = 30;
|
final int checkRange = 30;
|
||||||
if (!DateUtil.withinDateRange(lastChecked, now, checkRange)) {
|
if (!DateUtil.withinDateRange(lastChecked, now, checkRange)) {
|
||||||
LOGGER.debug("Checking web for new version.");
|
LOGGER.debug("Checking web for new version.");
|
||||||
final String currentRelease = getCurrentReleaseVersion();
|
final String currentRelease = getCurrentReleaseVersion();
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.doxia.sink.Sink;
|
import org.apache.maven.doxia.sink.Sink;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
@@ -282,7 +280,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
|
|||||||
/**
|
/**
|
||||||
* The security dispatcher that can decrypt passwords in the settings.xml.
|
* The security dispatcher that can decrypt passwords in the settings.xml.
|
||||||
*/
|
*/
|
||||||
@Component(role = org.sonatype.plexus.components.sec.dispatcher.SecDispatcher.class, hint = "default")
|
@Component(role = SecDispatcher.class, hint = "default")
|
||||||
private SecDispatcher securityDispatcher;
|
private SecDispatcher securityDispatcher;
|
||||||
/**
|
/**
|
||||||
* The database user name.
|
* The database user name.
|
||||||
@@ -701,7 +699,7 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
|
|||||||
Settings.setStringIfNotEmpty(Settings.KEYS.DB_CONNECTION_STRING, connectionString);
|
Settings.setStringIfNotEmpty(Settings.KEYS.DB_CONNECTION_STRING, connectionString);
|
||||||
|
|
||||||
if (databaseUser == null && databasePassword == null && serverId != null) {
|
if (databaseUser == null && databasePassword == null && serverId != null) {
|
||||||
Server server = settingsXml.getServer(serverId);
|
final Server server = settingsXml.getServer(serverId);
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
databaseUser = server.getUsername();
|
databaseUser = server.getUsername();
|
||||||
try {
|
try {
|
||||||
@@ -718,17 +716,21 @@ public abstract class BaseDependencyCheckMojo extends AbstractMojo implements Ma
|
|||||||
|
|
||||||
databasePassword = securityDispatcher.decrypt(server.getPassword());
|
databasePassword = securityDispatcher.decrypt(server.getPassword());
|
||||||
} catch (SecDispatcherException ex) {
|
} catch (SecDispatcherException ex) {
|
||||||
if (ex.getCause() instanceof java.io.FileNotFoundException
|
if (ex.getCause() instanceof FileNotFoundException
|
||||||
|| (ex.getCause() != null && ex.getCause().getCause() instanceof java.io.FileNotFoundException)) {
|
|| (ex.getCause() != null && ex.getCause().getCause() instanceof FileNotFoundException)) {
|
||||||
//maybe its not encrypted?
|
//maybe its not encrypted?
|
||||||
final String tmp = server.getPassword();
|
final String tmp = server.getPassword();
|
||||||
if (tmp.startsWith("{") && tmp.endsWith("}")) {
|
if (tmp.startsWith("{") && tmp.endsWith("}")) {
|
||||||
getLog().error(String.format("Unable to decrypt the server password for server id '%s' in settings.xml%n\tCause: %s", serverId, ex.getMessage()));
|
getLog().error(String.format(
|
||||||
|
"Unable to decrypt the server password for server id '%s' in settings.xml%n\tCause: %s",
|
||||||
|
serverId, ex.getMessage()));
|
||||||
} else {
|
} else {
|
||||||
databasePassword = tmp;
|
databasePassword = tmp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getLog().error(String.format("Unable to decrypt the server password for server id '%s' in settings.xml%n\tCause: %s", serverId, ex.getMessage()));
|
getLog().error(String.format(
|
||||||
|
"Unable to decrypt the server password for server id '%s' in settings.xml%n\tCause: %s",
|
||||||
|
serverId, ex.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user