cleanup and spelling fixes

Former-commit-id: d966f548ebccb77139f668343459210022c4deaa
This commit is contained in:
Jeremy Long
2013-02-19 21:35:24 -05:00
parent b67092c472
commit b72a7d0440
39 changed files with 188 additions and 225 deletions

View File

@@ -200,7 +200,6 @@ public class Engine {
} catch (Exception ex1) {
Logger.getLogger(Engine.class.getName()).log(Level.FINER, null, ex1);
}
continue;
}
}
}

View File

@@ -18,6 +18,7 @@
*/
package org.codesecure.dependencycheck.analyzer;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -39,10 +40,7 @@ public abstract class AbstractAnalyzer implements Analyzer {
protected static Set<String> newHashSet(String... strings) {
Set<String> set = new HashSet<String>();
//yes, in Java7 we could use Array.toList(...) - but I'm trying to keep this Java 6 compliant.
for (String s : strings) {
set.add(s);
}
Collections.addAll(set, strings);
return set;
}
}

View File

@@ -33,7 +33,7 @@ public interface Analyzer {
/**
* Analyzes the given dependency. The analysis could be anything from
* identifying an Idenifier for the dependency, to finding vulnerabilities,
* identifying an Identifier for the dependency, to finding vulnerabilities,
* etc. Additionally, if the analyzer collects enough information to add a
* description or license information for the dependency it should be added.
*
@@ -71,7 +71,7 @@ public interface Analyzer {
* Returns whether or not this analyzer can process the given extension.
*
* @param extension the file extension to test for support.
* @return whether or not the specified file extension is supported by tihs
* @return whether or not the specified file extension is supported by this
* analyzer.
*/
boolean supportsExtension(String extension);

View File

@@ -28,7 +28,7 @@ import java.util.ServiceLoader;
public class AnalyzerService {
private static AnalyzerService service;
private ServiceLoader<Analyzer> loader;
private final ServiceLoader<Analyzer> loader;
/**
* Creates a new instance of AnalyzerService

View File

@@ -66,7 +66,7 @@ public class FileNameAnalyzer implements Analyzer {
* Returns whether or not this analyzer can process the given extension.
*
* @param extension the file extension to test for support.
* @return whether or not the specified file extension is supported by tihs
* @return whether or not the specified file extension is supported by this
* analyzer.
*/
public boolean supportsExtension(String extension) {

View File

@@ -115,10 +115,6 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
* item in some manifest, should be considered medium confidence.
*/
private static final String BUNDLE_VENDOR = "Bundle-Vendor"; //: Apache Software Foundation
/**
* The JAXB Contexts used to unmarshall the pom.xml from a JAR file.
*/
private JAXBContext jaxbContext = null;
/**
* The unmarshaller used to parse the pom.xml from a JAR file.
*/
@@ -129,7 +125,7 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
*/
public JarAnalyzer() {
try {
jaxbContext = JAXBContext.newInstance("org.codesecure.dependencycheck.analyzer.pom.generated");
JAXBContext jaxbContext = JAXBContext.newInstance("org.codesecure.dependencycheck.analyzer.pom.generated");
pomUnmarshaller = jaxbContext.createUnmarshaller();
} catch (JAXBException ex) { //guess we will just have a null pointer exception later...
Logger.getLogger(JarAnalyzer.class.getName()).log(Level.SEVERE, null, ex);

View File

@@ -69,8 +69,8 @@ public class SpringCleaningAnalyzer extends AbstractAnalyzer {
/**
* Returns whether or not this analyzer can process the given extension.
*
* @param extension the file extension to test for support.
* @return whether or not the specified file extension is supported by tihs
* @param extension the file extension to test for support
* @return whether or not the specified file extension is supported by this
* analyzer.
*/
public boolean supportsExtension(String extension) {
@@ -104,7 +104,7 @@ public class SpringCleaningAnalyzer extends AbstractAnalyzer {
private List<Identifier> springVersions = null;
/**
* Determines if several "spring" libraries were scanned and trimes the
* Determines if several "spring" libraries were scanned and trims the
* cpe:/a:springsource:spring_framework:[version] from the none "core" framework
* if the core framework was part of the scan.
*

View File

@@ -17,7 +17,7 @@ import javax.xml.bind.annotation.XmlType;
/**
*
* Repository contains the information needed for deploying to the remote repoistory.
* Repository contains the information needed for deploying to the remote repository.
*
*
* <p>Java class for DeploymentRepository complex type.

View File

@@ -18,7 +18,7 @@ import javax.xml.namespace.QName;
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the org.codesecure.dependencycheck.analyzer.pom.generated package.
* <p>An ObjectFactory allows you to programatically
* <p>An ObjectFactory allows you to programmatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces

View File

@@ -17,7 +17,7 @@ import javax.xml.bind.annotation.XmlType;
/**
*
* A repository contains the information needed for establishing connections with remote repoistory.
* A repository contains the information needed for establishing connections with remote repository.
*
*
* <p>Java class for Repository complex type.

View File

@@ -28,7 +28,7 @@ import java.util.ServiceLoader;
public class UpdateService {
private static UpdateService service;
private ServiceLoader<CachedWebDataSource> loader;
private final ServiceLoader<CachedWebDataSource> loader;
/**
* Creates a new instance of UpdateService

View File

@@ -40,7 +40,7 @@ import org.codesecure.dependencycheck.dependency.EvidenceCollection;
/**
* CPEAnalyzer is a utility class that takes a project dependency and attempts
* to decern if there is an associated CPE. It uses the evidence contained
* to discern if there is an associated CPE. It uses the evidence contained
* within the dependency to search the Lucene index.
*
* @author Jeremy Long (jeremy.long@gmail.com)
@@ -78,7 +78,7 @@ public class CPEAnalyzer implements org.codesecure.dependencycheck.analyzer.Anal
/**
* Opens the data source.
*
* @throws IOException when the Lucene directory to be querried does not
* @throws IOException when the Lucene directory to be queried does not
* exist or is corrupt.
*/
public void open() throws IOException {
@@ -99,7 +99,7 @@ public class CPEAnalyzer implements org.codesecure.dependencycheck.analyzer.Anal
* @return true or false.
*/
public boolean isOpen() {
return (cpe == null) ? false : cpe.isOpen();
return (cpe != null) && cpe.isOpen();
}
/**
@@ -118,7 +118,7 @@ public class CPEAnalyzer implements org.codesecure.dependencycheck.analyzer.Anal
/**
* Searches the data store of CPE entries, trying to identify the CPE for
* the given dependency based on the evidence contained within. The
* depencency passed in is updated with any identified CPE values.
* dependency passed in is updated with any identified CPE values.
*
* @param dependency the dependency to search for CPE entries on.
* @throws CorruptIndexException is thrown when the Lucene index is corrupt.
@@ -194,7 +194,7 @@ public class CPEAnalyzer implements org.codesecure.dependencycheck.analyzer.Anal
* @param text the base text.
* @param ec an EvidenceCollection
* @param confidenceFilter a Confidence level to filter the evidence by.
* @return
* @return the new evidence text
*/
private String addEvidenceWithoutDuplicateTerms(final String text, final EvidenceCollection ec, Confidence confidenceFilter) {
String txt = (text == null) ? "" : text;
@@ -286,12 +286,12 @@ public class CPEAnalyzer implements org.codesecure.dependencycheck.analyzer.Anal
* @param version text to search the version field.
* @param vendorWeighting a list of strings to apply to the vendor to boost
* the terms weight.
* @param produdctWeightings a list of strings to apply to the product to
* @param productWeightings a list of strings to apply to the product to
* boost the terms weight.
* @return the Lucene query.
*/
protected String buildSearch(String vendor, String product, String version,
Set<String> vendorWeighting, Set<String> produdctWeightings) {
Set<String> vendorWeighting, Set<String> productWeightings) {
StringBuilder sb = new StringBuilder(vendor.length() + product.length()
+ version.length() + Fields.PRODUCT.length() + Fields.VERSION.length()
@@ -301,7 +301,7 @@ public class CPEAnalyzer implements org.codesecure.dependencycheck.analyzer.Anal
return null;
}
if (!appendWeightedSearch(sb, Fields.PRODUCT, product, produdctWeightings)) {
if (!appendWeightedSearch(sb, Fields.PRODUCT, product, productWeightings)) {
return null;
}
sb.append(" AND ");
@@ -332,7 +332,7 @@ public class CPEAnalyzer implements org.codesecure.dependencycheck.analyzer.Anal
/**
* This method constructs a Lucene query for a given field. The searchText
* is split into seperate words and if the word is within the list of
* is split into separate words and if the word is within the list of
* weighted words then an additional weighting is applied to the term as it
* is appended into the query.
*

View File

@@ -19,15 +19,15 @@
package org.codesecure.dependencycheck.data.lucene;
/**
* <p>Lucene utils is a set of utilitize written to make constructing Lucene
* queries simplier.</p>
* <p>Lucene utils is a set of utilize written to make constructing Lucene
* queries simpler.</p>
*
* @author Jeremy Long (jeremy.long@gmail.com)
*/
public final class LuceneUtils {
/**
* Provate contructor as this is a utility class.
* Private constructor as this is a utility class.
*/
private LuceneUtils() {
}

View File

@@ -39,7 +39,7 @@ public final class TokenPairConcatenatingFilter extends TokenFilter {
private LinkedList<String> words = null;
/**
* Consructs a new TokenPairConcatenatingFilter
* Constructs a new TokenPairConcatenatingFilter
* @param stream the TokenStream that this filter will process
*/
public TokenPairConcatenatingFilter(TokenStream stream) {
@@ -48,8 +48,8 @@ public final class TokenPairConcatenatingFilter extends TokenFilter {
}
/**
* Increments the underlying TokenStream and sets CharTermAtttributes to
* construct an expanded set of tokens by concatenting tokens with the
* Increments the underlying TokenStream and sets CharTermAttributes to
* construct an expanded set of tokens by concatenating tokens with the
* previous token.
*
* @return whether or not we have hit the end of the TokenStream

View File

@@ -39,7 +39,7 @@ public final class VersionTokenizingFilter extends TokenFilter {
protected LinkedList<String> tokens = null;
/**
* Consructs a new VersionTokenizingFilter
* Constructs a new VersionTokenizingFilter
* @param stream the TokenStream that this filter will process
*/
public VersionTokenizingFilter(TokenStream stream) {
@@ -48,8 +48,8 @@ public final class VersionTokenizingFilter extends TokenFilter {
}
/**
* Increments the underlying TokenStream and sets CharTermAtttributes to
* construct an expanded set of tokens by concatenting tokens with the
* Increments the underlying TokenStream and sets CharTermAttributes to
* construct an expanded set of tokens by concatenating tokens with the
* previous token.
*
* @return whether or not we have hit the end of the TokenStream
@@ -65,8 +65,8 @@ public final class VersionTokenizingFilter extends TokenFilter {
}
/**
* Adds a term, if one exists, from the tokens collection..
* @return
* Adds a term, if one exists, from the tokens collection.
* @return whether or not a new term was added
*/
private boolean addTerm() {
boolean termAdded = tokens.size() > 0;
@@ -84,8 +84,7 @@ public final class VersionTokenizingFilter extends TokenFilter {
// to incorporate the dash or underscore back in...
String[] versionParts = version.split("\\.");
String dottedVersion = null;
for (int x = 0; x < versionParts.length; x++) {
String current = versionParts[x];
for (String current : versionParts) {
if (!current.matches("^/d+$")) {
tokens.add(current);
}

View File

@@ -31,7 +31,7 @@ import org.codesecure.dependencycheck.dependency.Identifier;
/**
* NvdCveAnalyzer is a utility class that takes a project dependency and
* attempts to decern if there is an associated CVEs. It uses the the
* attempts to discern if there is an associated CVEs. It uses the the
* identifiers found by other analyzers to lookup the CVE data.
*
* @author Jeremy Long (jeremy.long@gmail.com)
@@ -50,7 +50,7 @@ public class NvdCveAnalyzer implements org.codesecure.dependencycheck.analyzer.A
/**
* Opens the data source.
*
* @throws SQLException thrown wwhen there is a SQL Exception
* @throws SQLException thrown when there is a SQL Exception
* @throws IOException thrown when there is an IO Exception
* @throws DatabaseException thrown when there is a database exceptions
*/

View File

@@ -209,7 +209,7 @@ public class DatabaseUpdater implements CachedWebDataSource {
* Writes a properties file containing the last updated date to the
* VULNERABLE_CPE directory.
*
* @param timeStamp the timestamp to write.
* @param updated a map of the updated nvdcve.
*/
private void writeLastUpdatedPropertyFile(Map<String, NvdCveUrl> updated) throws UpdateException {
String dir;
@@ -321,8 +321,8 @@ public class DatabaseUpdater implements CachedWebDataSource {
FileUtils.delete(f);
//this importer also updates the CPE index and it is also using an old version
org.codesecure.dependencycheck.data.cpe.Index cpeidx = new org.codesecure.dependencycheck.data.cpe.Index();
File cpeDir = cpeidx.getDataDirectory();
org.codesecure.dependencycheck.data.cpe.Index cpeid = new org.codesecure.dependencycheck.data.cpe.Index();
File cpeDir = cpeid.getDataDirectory();
FileUtils.delete(cpeDir);
return currentlyPublished;
}

View File

@@ -19,7 +19,7 @@
package org.codesecure.dependencycheck.data.nvdcve.xml;
/**
* An InvalidataDataException is a generic exception used when trying to load
* An InvalidDataDataException is a generic exception used when trying to load
* the nvd cve meta data.
*
* @author Jeremy

View File

@@ -248,7 +248,7 @@ public class NvdCve20Handler extends DefaultHandler {
/**
* A node type in the NVD CVE Schema 2.0
*/
public static final String VULN_REFERNCES = "vuln:references";
public static final String VULN_REFERENCES = "vuln:references";
/**
* A node type in the NVD CVE Schema 2.0
*/
@@ -256,7 +256,7 @@ public class NvdCve20Handler extends DefaultHandler {
/**
* A node type in the NVD CVE Schema 2.0
*/
public static final String VULN_REFERNCE = "vuln:reference";
public static final String VULN_REFERENCE = "vuln:reference";
/**
* A node type in the NVD CVE Schema 2.0
*/
@@ -348,7 +348,7 @@ public class NvdCve20Handler extends DefaultHandler {
* @return true or false
*/
public boolean isVulnReferencesNode() {
return VULN_REFERNCES.equals(node);
return VULN_REFERENCES.equals(node);
}
/**
@@ -357,7 +357,7 @@ public class NvdCve20Handler extends DefaultHandler {
* @return true or false
*/
public boolean isVulnReferenceNode() {
return VULN_REFERNCE.equals(node);
return VULN_REFERENCE.equals(node);
}
/**

View File

@@ -293,7 +293,7 @@ public class Dependency {
return this.versionEvidence;
}
/**
* A list of exceptions that occured during analysis of this dependency.
* A list of exceptions that occurred during analysis of this dependency.
*/
protected List<Exception> analysisExceptions = new ArrayList<Exception>();

View File

@@ -50,7 +50,7 @@ public class Identifier {
this.description = description;
}
/**
* The value of the identifeir
* The value of the identifier
*/
protected String value;
@@ -73,7 +73,7 @@ public class Identifier {
}
/**
* The url for the identifeir
* The url for the identifier
*/
protected String url;
@@ -95,7 +95,7 @@ public class Identifier {
this.url = url;
}
/**
* The type of the identifeir
* The type of the identifier
*/
protected String type;

View File

@@ -108,7 +108,7 @@ public class Vulnerability implements Serializable, Comparable<Vulnerability> {
/**
* Adds a reference
* @param referenceSource the source of the referece
* @param referenceSource the source of the reference
* @param referenceName the referenceName of the reference
* @param referenceUrl the url of the reference
*/
@@ -378,7 +378,7 @@ public class Vulnerability implements Serializable, Comparable<Vulnerability> {
/**
* Compares two vulnerabilities
*
* @param v a vulnerabilitiy to be compared
* @param v a vulnerability to be compared
* @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified vulnerability
*/
public int compareTo(Vulnerability v) {

View File

@@ -35,7 +35,7 @@ public class VulnerableSoftware extends Entry implements Serializable {
private static final long serialVersionUID = 307319490326651052L;
/**
* Parse a CPE entry from the cpe string repesentation
* Parse a CPE entry from the cpe string representation
*
* @param cpe a cpe entry (e.g. cpe:/a:vendor:software:version)
*/

View File

@@ -88,7 +88,7 @@ public class ReportGenerator {
/**
* Creates a new Velocity Context initialized with escape and date tools.
* @return a Velcotiy Context.
* @return a Velocity Context.
*/
private Context createContext() {
ToolManager manager = new ToolManager();
@@ -106,7 +106,7 @@ public class ReportGenerator {
* @param outputDir the path where the reports should be written.
* @param outputFormat the format the report should be written in.
* @throws IOException is thrown when the template file does not exist.
* @throws Exception is thrown if there is an error writting out the
* @throws Exception is thrown if there is an error writing out the
* reports.
*/
public void generateReports(String outputDir, String outputFormat) throws IOException, Exception {

View File

@@ -23,7 +23,7 @@ public class Checksum {
/**
* <p>Creates the cryptographic checksum of a given file using the specified
* alogirhtm.</p> <p>This algorithm was copied and heavily modified from
* algorithm.</p> <p>This algorithm was copied and heavily modified from
* Real's How To: http://www.rgagnon.com/javadetails/java-0416.html</p>
*
* @param algorithm the algorithm to use to calculate the checksum

View File

@@ -209,7 +209,7 @@ public final class CliParser {
* @return whether or not the 'version' command line argument was passed in
*/
public boolean isGetVersion() {
return (line != null) ? line.hasOption(ArgumentName.VERSION) : false;
return (line != null) && line.hasOption(ArgumentName.VERSION);
}
/**
@@ -218,7 +218,7 @@ public final class CliParser {
* @return whether or not the 'help' command line argument was passed in
*/
public boolean isGetHelp() {
return (line != null) ? line.hasOption(ArgumentName.HELP) : false;
return (line != null) && line.hasOption(ArgumentName.HELP);
}
/**
@@ -227,7 +227,7 @@ public final class CliParser {
* @return whether or not the 'scan' command line argument was passed in
*/
public boolean isRunScan() {
return (line != null) ? isValid && line.hasOption(ArgumentName.SCAN) : false;
return (line != null) && isValid && line.hasOption(ArgumentName.SCAN);
}
/**
@@ -319,7 +319,7 @@ public final class CliParser {
* @return if auto-update is allowed.
*/
public boolean isAutoUpdate() {
return (line != null) ? !line.hasOption(ArgumentName.DISABLE_AUTO_UPDATE) : true;
return (line == null) || !line.hasOption(ArgumentName.DISABLE_AUTO_UPDATE);
}
/**
@@ -329,50 +329,50 @@ public final class CliParser {
public static class ArgumentName {
/**
* The long CLI argument name specifing the directory/file to scan
* The long CLI argument name specifying the directory/file to scan
*/
public static final String SCAN = "scan";
/**
* The short CLI argument name specifing the directory/file to scan
* The short CLI argument name specifying the directory/file to scan
*/
public static final String SCAN_SHORT = "s";
/**
* The long CLI argument name specifing that the CPE/CVE/etc. data
* The long CLI argument name specifying that the CPE/CVE/etc. data
* should not be automatically updated.
*/
public static final String DISABLE_AUTO_UPDATE = "noupdate";
/**
* The short CLI argument name specifing that the CPE/CVE/etc. data
* The short CLI argument name specifying that the CPE/CVE/etc. data
* should not be automatically updated.
*/
public static final String DISABLE_AUTO_UPDATE_SHORT = "n";
/**
* The long CLI argument name specifing the directory to write the
* The long CLI argument name specifying the directory to write the
* reports to.
*/
public static final String OUT = "out";
/**
* The short CLI argument name specifing the directory to write the
* The short CLI argument name specifying the directory to write the
* reports to.
*/
public static final String OUT_SHORT = "o";
/**
* The long CLI argument name specifing the output format to write the
* The long CLI argument name specifying the output format to write the
* reports to.
*/
public static final String OUTPUT_FORMAT = "format";
/**
* The short CLI argument name specifing the output format to write the
* The short CLI argument name specifying the output format to write the
* reports to.
*/
public static final String OUTPUT_FORMAT_SHORT = "f";
/**
* The long CLI argument name specifing the name of the application to
* The long CLI argument name specifying the name of the application to
* be scanned.
*/
public static final String APPNAME = "app";
/**
* The short CLI argument name specifing the name of the application to
* The short CLI argument name specifying the name of the application to
* be scanned.
*/
public static final String APPNAME_SHORT = "a";

View File

@@ -64,7 +64,7 @@ public class Downloader {
* @param url the URL of the file to download.
* @param outputPath the path to the save the file to.
* @param unzip true/false indicating that the file being retrieved is
* gzipped and if true, should be uncompressed before writting to the file.
* gzipped and if true, should be uncompressed before writing to the file.
* @throws DownloadFailedException is thrown if there is an error
* downloading the file.
*/
@@ -91,7 +91,7 @@ public class Downloader {
* @param url the URL of the file to download.
* @param outputPath the path to the save the file to.
* @param unzip true/false indicating that the file being retrieved is
* gzipped and if true, should be uncompressed before writting to the file.
* gzipped and if true, should be uncompressed before writing to the file.
* @throws DownloadFailedException is thrown if there is an error
* downloading the file.
*/
@@ -190,7 +190,7 @@ public class Downloader {
}
/**
* Utility method to get an HttpURLConnectoin. If the app is configured to
* Utility method to get an HttpURLConnection. If the app is configured to
* use a proxy this method will retrieve the proxy settings and use them
* when setting up the connection.
*

View File

@@ -24,7 +24,7 @@ import java.io.InputStream;
/**
* NonClosingStream is a stream filter which prevents
* another class that processes the stream from closing
* it. This is necassary when dealing with things like
* it. This is necessary when dealing with things like
* JAXB and zipInputStreams.
*
* @author Jeremy Long (jeremy.long@gmail.com)

View File

@@ -39,7 +39,7 @@ public class Settings {
public static class KEYS {
/**
* private contructor because this is a "utility" class containing constants
* private constructor because this is a "utility" class containing constants
*/
private KEYS() {
//do nothing