checkstyle updates

This commit is contained in:
Jeremy Long
2017-07-22 18:20:11 -04:00
parent db2a0abcb6
commit 176363492e
9 changed files with 61 additions and 35 deletions

View File

@@ -62,8 +62,8 @@ public class Engine implements FileFilter, AutoCloseable {
*/ */
public enum Mode { public enum Mode {
/** /**
* In evidence collection mode the {@link Engine} only collects evidence from the scan targets, * In evidence collection mode the {@link Engine} only collects evidence
* and doesn't require a database. * from the scan targets, and doesn't require a database.
*/ */
EVIDENCE_COLLECTION( EVIDENCE_COLLECTION(
false, false,
@@ -73,9 +73,10 @@ public class Engine implements FileFilter, AutoCloseable {
POST_INFORMATION_COLLECTION POST_INFORMATION_COLLECTION
), ),
/** /**
* In evidence processing mode the {@link Engine} processes the evidence collected using the * In evidence processing mode the {@link Engine} processes the evidence
* {@link #EVIDENCE_COLLECTION} mode. Dependencies should be injected into the {@link Engine} * collected using the {@link #EVIDENCE_COLLECTION} mode. Dependencies
* using {@link Engine#setDependencies(List)}. * should be injected into the {@link Engine} using
* {@link Engine#setDependencies(List)}.
*/ */
EVIDENCE_PROCESSING( EVIDENCE_PROCESSING(
true, true,
@@ -88,13 +89,26 @@ public class Engine implements FileFilter, AutoCloseable {
FINAL FINAL
), ),
/** /**
* In standalone mode the {@link Engine} will collect and process evidence in a single execution. * In standalone mode the {@link Engine} will collect and process
* evidence in a single execution.
*/ */
STANDALONE(true, AnalysisPhase.values()); STANDALONE(true, AnalysisPhase.values());
/**
* Whether the database is required in this mode.
*/
public final boolean requiresDatabase; public final boolean requiresDatabase;
/**
* The analysis phases included in the mode.
*/
public final AnalysisPhase[] phases; public final AnalysisPhase[] phases;
/**
* Constructs a new mode.
*
* @param requiresDatabase if the database is required for the mode
* @param phases the analysis phases to include in the mode
*/
Mode(boolean requiresDatabase, AnalysisPhase... phases) { Mode(boolean requiresDatabase, AnalysisPhase... phases) {
this.requiresDatabase = requiresDatabase; this.requiresDatabase = requiresDatabase;
this.phases = phases; this.phases = phases;
@@ -116,7 +130,8 @@ public class Engine implements FileFilter, AutoCloseable {
private final Set<FileTypeAnalyzer> fileTypeAnalyzers = new HashSet<>(); private final Set<FileTypeAnalyzer> fileTypeAnalyzers = new HashSet<>();
/** /**
* The engine execution mode indicating it will either collect evidence or process evidence or both. * The engine execution mode indicating it will either collect evidence or
* process evidence or both.
*/ */
private final Mode mode; private final Mode mode;
@@ -143,6 +158,8 @@ public class Engine implements FileFilter, AutoCloseable {
/** /**
* Creates a new Engine. * Creates a new Engine.
*
* @param mode the mode of operation
*/ */
public Engine(Mode mode) { public Engine(Mode mode) {
this(Thread.currentThread().getContextClassLoader(), mode); this(Thread.currentThread().getContextClassLoader(), mode);

View File

@@ -32,6 +32,7 @@ import static java.util.Arrays.asList;
* @author Jeremy Long * @author Jeremy Long
*/ */
public class AnalyzerService { public class AnalyzerService {
/** /**
* The Logger for use throughout the class. * The Logger for use throughout the class.
*/ */
@@ -45,7 +46,8 @@ public class AnalyzerService {
/** /**
* Creates a new instance of AnalyzerService. * Creates a new instance of AnalyzerService.
* *
* @param classLoader the ClassLoader to use when dynamically loading Analyzer and Update services * @param classLoader the ClassLoader to use when dynamically loading
* Analyzer and Update services
*/ */
public AnalyzerService(ClassLoader classLoader) { public AnalyzerService(ClassLoader classLoader) {
service = ServiceLoader.load(Analyzer.class, classLoader); service = ServiceLoader.load(Analyzer.class, classLoader);
@@ -61,8 +63,10 @@ public class AnalyzerService {
} }
/** /**
* Returns a list of all instances of the Analyzer interface that are bound to one of the given phases. * Returns a list of all instances of the Analyzer interface that are bound
* to one of the given phases.
* *
* @param phases the phases to obtain analyzers for
* @return a list of Analyzers. * @return a list of Analyzers.
*/ */
public List<Analyzer> getAnalyzers(AnalysisPhase... phases) { public List<Analyzer> getAnalyzers(AnalysisPhase... phases) {
@@ -70,9 +74,11 @@ public class AnalyzerService {
} }
/** /**
* Returns a list of all instances of the Analyzer interface that are bound to one of the given phases. * Returns a list of all instances of the Analyzer interface that are bound
* to one of the given phases.
* *
* @return a list of Analyzers. * @param phases the phases to obtain analyzers for
* @return a list of Analyzers
*/ */
private List<Analyzer> getAnalyzers(List<AnalysisPhase> phases) { private List<Analyzer> getAnalyzers(List<AnalysisPhase> phases) {
final List<Analyzer> analyzers = new ArrayList<>(); final List<Analyzer> analyzers = new ArrayList<>();

View File

@@ -114,7 +114,7 @@ public class AssemblyAnalyzer extends AbstractFileTypeAnalyzer {
public void analyzeDependency(Dependency dependency, Engine engine) public void analyzeDependency(Dependency dependency, Engine engine)
throws AnalysisException { throws AnalysisException {
File test = new File(dependency.getActualFilePath()); final File test = new File(dependency.getActualFilePath());
if (!test.isFile()) { if (!test.isFile()) {
throw new AnalysisException(String.format("%s does not exist and cannot be analyzed by dependency-check", throw new AnalysisException(String.format("%s does not exist and cannot be analyzed by dependency-check",
dependency.getActualFilePath())); dependency.getActualFilePath()));

View File

@@ -300,6 +300,9 @@ public final class CveDB implements AutoCloseable {
} }
} }
/**
* Releases the resources used by CveDB.
*/
private synchronized void releaseResources() { private synchronized void releaseResources() {
instance.statementBundle = null; instance.statementBundle = null;
instance.preparedStatements.clear(); instance.preparedStatements.clear();

View File

@@ -261,7 +261,7 @@ public class EvidenceCollection implements Serializable, Iterable<Evidence> {
for (Evidence e : EvidenceCollection.EVIDENCE_USED.filter(this)) { for (Evidence e : EvidenceCollection.EVIDENCE_USED.filter(this)) {
//TODO consider changing the regex to only compare alpha-numeric (i.e. strip everything else) //TODO consider changing the regex to only compare alpha-numeric (i.e. strip everything else)
String item = e.getValue(); final String item = e.getValue();
if (item != null) { if (item != null) {
final String uc = urlCorrection(item.toLowerCase()); final String uc = urlCorrection(item.toLowerCase());
if (uc != null) { if (uc != null) {