diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..230cb83e0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,2 @@
+language: java
+jdk: oraclejdk7
diff --git a/README.md b/README.md
index d80df5c5f..33d31804b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[](https://dependency-check.ci.cloudbees.com/job/dependency-check/)
+[](https://travis-ci.org/jeremylong/DependencyCheck) [](https://www.apache.org/licenses/LICENSE-2.0.txt)
Dependency-Check
================
@@ -22,18 +22,18 @@ The latest CLI can be downloaded from bintray's
On *nix
```
$ ./bin/dependency-check.sh -h
-$ ./bin/dependency-check.sh --app Testing --out . --scan [path to jar files to be scanned]
+$ ./bin/dependency-check.sh --project Testing --out . --scan [path to jar files to be scanned]
```
On Windows
```
> bin/dependency-check.bat -h
-> bin/dependency-check.bat --app Testing --out . --scan [path to jar files to be scanned]
+> bin/dependency-check.bat --project Testing --out . --scan [path to jar files to be scanned]
```
On Mac with [Homebrew](http://brew.sh)
```
$ brew update && brew install dependency-check
$ dependency-check -h
-$ dependency-check --app Testing --out . --scan [path to jar files to be scanned]
+$ dependency-check --project Testing --out . --scan [path to jar files to be scanned]
```
### Maven Plugin
@@ -85,13 +85,13 @@ On *nix
```
$ mvn install
$ ./dependency-check-cli/target/release/bin/dependency-check.sh -h
-$ ./dependency-check-cli/target/release/bin/dependency-check.sh --app Testing --out . --scan ./src/test/resources
+$ ./dependency-check-cli/target/release/bin/dependency-check.sh --project Testing --out . --scan ./src/test/resources
```
On Windows
```
> mvn install
> dependency-check-cli/target/release/bin/dependency-check.bat -h
-> dependency-check-cli/target/release/bin/dependency-check.bat --app Testing --out . --scan ./src/test/resources
+> dependency-check-cli/target/release/bin/dependency-check.bat --project Testing --out . --scan ./src/test/resources
```
Then load the resulting 'DependencyCheck-Report.html' into your favorite browser.
diff --git a/dependency-check-ant/pom.xml b/dependency-check-ant/pom.xml
index 74cd4e634..03b758834 100644
--- a/dependency-check-ant/pom.xml
+++ b/dependency-check-ant/pom.xml
@@ -20,7 +20,7 @@ Copyright (c) 2013 - Jeremy Long. All Rights Reserved.
org.owaspdependency-check-parent
- 1.3.7-SNAPSHOT
+ 1.4.0-SNAPSHOTdependency-check-ant
diff --git a/dependency-check-ant/src/main/java/org/owasp/dependencycheck/taskdefs/Check.java b/dependency-check-ant/src/main/java/org/owasp/dependencycheck/taskdefs/Check.java
index cfefeb27c..78f6e823a 100644
--- a/dependency-check-ant/src/main/java/org/owasp/dependencycheck/taskdefs/Check.java
+++ b/dependency-check-ant/src/main/java/org/owasp/dependencycheck/taskdefs/Check.java
@@ -86,8 +86,8 @@ public class Check extends Update {
}
/**
- * Returns the path. If the path has not been initialized yet, this class is synchronized, and will instantiate the path
- * object.
+ * Returns the path. If the path has not been initialized yet, this class is
+ * synchronized, and will instantiate the path object.
*
* @return the path
*/
@@ -109,7 +109,8 @@ public class Check extends Update {
}
/**
- * Add a reference to a Path, FileSet, DirSet, or FileList defined elsewhere.
+ * Add a reference to a Path, FileSet, DirSet, or FileList defined
+ * elsewhere.
*
* @param r the reference to a path, fileset, dirset or filelist.
*/
@@ -121,7 +122,8 @@ public class Check extends Update {
}
/**
- * If this is a reference, this method will add the referenced resource collection to the collection of paths.
+ * If this is a reference, this method will add the referenced resource
+ * collection to the collection of paths.
*
* @throws BuildException if the reference is not to a resource collection
*/
@@ -196,7 +198,8 @@ public class Check extends Update {
}
/**
- * Specifies the destination directory for the generated Dependency-Check report.
+ * Specifies the destination directory for the generated Dependency-Check
+ * report.
*/
private String reportOutputDirectory = ".";
@@ -218,9 +221,11 @@ public class Check extends Update {
this.reportOutputDirectory = reportOutputDirectory;
}
/**
- * Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11 which
- * means since the CVSS scores are 0-10, by default the build will never fail and the CVSS score is set to 11. The valid range
- * for the fail build on CVSS is 0 to 11, where anything above 10 will not cause the build to fail.
+ * Specifies if the build should be failed if a CVSS score above a specified
+ * level is identified. The default is 11 which means since the CVSS scores
+ * are 0-10, by default the build will never fail and the CVSS score is set
+ * to 11. The valid range for the fail build on CVSS is 0 to 11, where
+ * anything above 10 will not cause the build to fail.
*/
private float failBuildOnCVSS = 11;
@@ -242,8 +247,8 @@ public class Check extends Update {
this.failBuildOnCVSS = failBuildOnCVSS;
}
/**
- * Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to false. Default
- * is true.
+ * Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not
+ * recommended that this be turned to false. Default is true.
*/
private Boolean autoUpdate;
@@ -295,7 +300,8 @@ public class Check extends Update {
}
/**
- * The report format to be generated (HTML, XML, VULN, ALL). Default is HTML.
+ * The report format to be generated (HTML, XML, VULN, ALL). Default is
+ * HTML.
*/
private String reportFormat = "HTML";
@@ -361,6 +367,29 @@ public class Check extends Update {
this.showSummary = showSummary;
}
+ /**
+ * Whether experimental analyzers are enabled.
+ */
+ private Boolean enableExperimental;
+
+ /**
+ * Get the value of enableExperimental.
+ *
+ * @return the value of enableExperimental
+ */
+ public Boolean isEnableExperimental() {
+ return enableExperimental;
+ }
+
+ /**
+ * Set the value of enableExperimental.
+ *
+ * @param enableExperimental new value of enableExperimental
+ */
+ public void setEnableExperimental(Boolean enableExperimental) {
+ this.enableExperimental = enableExperimental;
+ }
+
/**
* Whether or not the Jar Analyzer is enabled.
*/
@@ -621,7 +650,8 @@ public class Check extends Update {
/**
* Set the value of pyDistributionAnalyzerEnabled.
*
- * @param pyDistributionAnalyzerEnabled new value of pyDistributionAnalyzerEnabled
+ * @param pyDistributionAnalyzerEnabled new value of
+ * pyDistributionAnalyzerEnabled
*/
public void setPyDistributionAnalyzerEnabled(Boolean pyDistributionAnalyzerEnabled) {
this.pyDistributionAnalyzerEnabled = pyDistributionAnalyzerEnabled;
@@ -674,7 +704,8 @@ public class Check extends Update {
}
/**
- * The URL of a Nexus server's REST API end point (http://domain/nexus/service/local).
+ * The URL of a Nexus server's REST API end point
+ * (http://domain/nexus/service/local).
*/
private String nexusUrl;
@@ -719,8 +750,8 @@ public class Check extends Update {
}
/**
- * Additional ZIP File extensions to add analyze. This should be a comma-separated list of file extensions to treat like ZIP
- * files.
+ * Additional ZIP File extensions to add analyze. This should be a
+ * comma-separated list of file extensions to treat like ZIP files.
*/
private String zipExtensions;
@@ -830,7 +861,8 @@ public class Check extends Update {
}
/**
- * Validate the configuration to ensure the parameters have been properly configured/initialized.
+ * Validate the configuration to ensure the parameters have been properly
+ * configured/initialized.
*
* @throws BuildException if the task was not configured correctly.
*/
@@ -844,8 +876,9 @@ public class Check extends Update {
}
/**
- * Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system properties
- * required to change the proxy server, port, and connection timeout.
+ * Takes the properties supplied and updates the dependency-check settings.
+ * Additionally, this sets the system properties required to change the
+ * proxy server, port, and connection timeout.
*
* @throws BuildException thrown when an invalid setting is configured.
*/
@@ -854,6 +887,7 @@ public class Check extends Update {
super.populateSettings();
Settings.setBooleanIfNotNull(Settings.KEYS.AUTO_UPDATE, autoUpdate);
Settings.setStringIfNotEmpty(Settings.KEYS.SUPPRESSION_FILE, suppressionFile);
+ Settings.setBooleanIfNotNull(Settings.KEYS.ANALYZER_EXPERIMENTAL_ENABLED, enableExperimental);
Settings.setBooleanIfNotNull(Settings.KEYS.ANALYZER_JAR_ENABLED, jarAnalyzerEnabled);
Settings.setBooleanIfNotNull(Settings.KEYS.ANALYZER_PYTHON_DISTRIBUTION_ENABLED, pyDistributionAnalyzerEnabled);
Settings.setBooleanIfNotNull(Settings.KEYS.ANALYZER_PYTHON_PACKAGE_ENABLED, pyPackageAnalyzerEnabled);
@@ -875,11 +909,12 @@ public class Check extends Update {
}
/**
- * Checks to see if a vulnerability has been identified with a CVSS score that is above the threshold set in the
- * configuration.
+ * Checks to see if a vulnerability has been identified with a CVSS score
+ * that is above the threshold set in the configuration.
*
* @param dependencies the list of dependency objects
- * @throws BuildException thrown if a CVSS score is found that is higher then the threshold set
+ * @throws BuildException thrown if a CVSS score is found that is higher
+ * then the threshold set
*/
private void checkForFailure(List dependencies) throws BuildException {
final StringBuilder ids = new StringBuilder();
@@ -903,7 +938,8 @@ public class Check extends Update {
}
/**
- * Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.
+ * Generates a warning message listing a summary of dependencies and their
+ * associated CPE and CVE entries.
*
* @param dependencies a list of dependency objects
*/
@@ -943,7 +979,8 @@ public class Check extends Update {
}
/**
- * An enumeration of supported report formats: "ALL", "HTML", "XML", "VULN", etc..
+ * An enumeration of supported report formats: "ALL", "HTML", "XML", "VULN",
+ * etc..
*/
public static class ReportFormats extends EnumeratedAttribute {
diff --git a/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
index c7d3bd93b..3c96bb5b4 100644
--- a/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
+++ b/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -23,16 +23,18 @@ import org.slf4j.ILoggerFactory;
import org.slf4j.spi.LoggerFactoryBinder;
/**
- * The binding of org.slf4j.LoggerFactory class with an actual instance of org.slf4j.ILoggerFactory is performed using information
- * returned by this class.
+ * The binding of org.slf4j.LoggerFactory class with an actual instance of
+ * org.slf4j.ILoggerFactory is performed using information returned by this
+ * class.
*
* @author colezlaw
*/
+//CSOFF: FinalClass
public class StaticLoggerBinder implements LoggerFactoryBinder {
+//CSON: FinalClass
/**
* The unique instance of this class
- *
*/
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
@@ -46,7 +48,8 @@ public class StaticLoggerBinder implements LoggerFactoryBinder {
}
/**
- * Ant tasks have the log method we actually want to call. So we hang onto the task as a delegate
+ * Ant tasks have the log method we actually want to call. So we hang onto
+ * the task as a delegate
*/
private Task task = null;
@@ -61,16 +64,24 @@ public class StaticLoggerBinder implements LoggerFactoryBinder {
}
/**
- * Declare the version of the SLF4J API this implementation is compiled against. The value of this filed is usually modified
- * with each release.
+ * Declare the version of the SLF4J API this implementation is compiled
+ * against. The value of this filed is usually modified with each release.
*/
// to avoid constant folding by the compiler, this field must *not* be final
+ //CSOFF: StaticVariableName
+ //CSOFF: VisibilityModifier
public static String REQUESTED_API_VERSION = "1.7.12"; // final
+ //CSON: VisibilityModifier
+ //CSON: StaticVariableName
+ /**
+ * The logger factory class string.
+ */
private static final String LOGGER_FACTORY_CLASS = AntLoggerFactory.class.getName();
/**
- * The ILoggerFactory instance returned by the {@link #getLoggerFactory} method should always be the smae object
+ * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
+ * method should always be the smae object
*/
private ILoggerFactory loggerFactory;
diff --git a/dependency-check-ant/src/site/markdown/configuration.md b/dependency-check-ant/src/site/markdown/configuration.md
index dafc18355..e2bf57a24 100644
--- a/dependency-check-ant/src/site/markdown/configuration.md
+++ b/dependency-check-ant/src/site/markdown/configuration.md
@@ -27,7 +27,7 @@ the project's dependencies.
Configuration: dependency-check Task
--------------------
-The following properties can be set on the dependency-check-update task.
+The following properties can be set on the dependency-check task.
Property | Description | Default Value
----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------
@@ -38,11 +38,12 @@ projectName | The name of the project being scanned.
reportFormat | The report format to be generated (HTML, XML, VULN, ALL). This configuration option has no affect if using this within the Site plugin unless the externalReport is set to true. | HTML
reportOutputDirectory | The location to write the report(s). Note, this is not used if generating the report as part of a `mvn site` build | 'target'
suppressionFile | The file path to the XML suppression file \- used to suppress [false positives](../general/suppression.html) |
-proxyServer | The Proxy Server. |
+proxyServer | The Proxy Server; see the [proxy configuration](../data/proxy.html) page for more information. |
proxyPort | The Proxy Port. |
proxyUsername | Defines the proxy user name. |
proxyPassword | Defines the proxy password. |
connectionTimeout | The URL Connection Timeout. |
+enableExperimental | Enable the [experimental analyzers](../analyzers/index.html). If not enabled the experimental analyzers (see below) will not be loaded or used. | false
Analyzer Configuration
====================
@@ -52,26 +53,26 @@ Note, that specific analyzers will automatically disable themselves if no file
types that they support are detected - so specifically disabling them may not
be needed.
-Property | Description | Default Value
-------------------------------|---------------------------------------------------------------------------|------------------
-archiveAnalyzerEnabled | Sets whether the Archive Analyzer will be used. | true
+Property | Description | Default Value
+------------------------------|-----------------------------------------------------------------------------------|------------------
+archiveAnalyzerEnabled | Sets whether the Archive Analyzer will be used. | true
zipExtensions | A comma-separated list of additional file extensions to be treated like a ZIP file, the contents will be extracted and analyzed. |
-jarAnalyzer | Sets whether the Jar Analyzer will be used. | true
+jarAnalyzer | Sets whether the Jar Analyzer will be used. | true
centralAnalyzerEnabled | Sets whether the Central Analyzer will be used. **Disabling this analyzer is not recommended as it could lead to false negatives (e.g. libraries that have vulnerabilities may not be reported correctly).** If this analyzer is being disabled there is a good chance you also want to disable the Nexus Analyzer (see below). | true
nexusAnalyzerEnabled | Sets whether Nexus Analyzer will be used. This analyzer is superceded by the Central Analyzer; however, you can configure this to run against a Nexus Pro installation. | true
nexusUrl | Defines the Nexus web service endpoint (example http://domain.enterprise/nexus/service/local/). If not set the Nexus Analyzer will be disabled. |
-nexusUsesProxy | Whether or not the defined proxy should be used when connecting to Nexus. | true
-pyDistributionAnalyzerEnabled | Sets whether the Python Distribution Analyzer will be used. | true
-pyPackageAnalyzerEnabled | Sets whether the Python Package Analyzer will be used. | true
-rubygemsAnalyzerEnabled | Sets whether the Ruby Gemspec Analyzer will be used. | true
-opensslAnalyzerEnabled | Sets whether or not the openssl Analyzer should be used. | true
-cmakeAnalyzerEnabled | Sets whether or not the CMake Analyzer should be used. | true
-autoconfAnalyzerEnabled | Sets whether or not the autoconf Analyzer should be used. | true
-composerAnalyzerEnabled | Sets whether or not the PHP Composer Lock File Analyzer should be used. | true
-nodeAnalyzerEnabled | Sets whether or not the Node.js Analyzer should be used. | true
-nuspecAnalyzerEnabled | Sets whether or not the .NET Nuget Nuspec Analyzer will be used. | true
-assemblyAnalyzerEnabled | Sets whether or not the .NET Assembly Analyzer should be used. | true
-pathToMono | The path to Mono for .NET assembly analysis on non-windows systems. |
+nexusUsesProxy | Whether or not the defined proxy should be used when connecting to Nexus. | true
+pyDistributionAnalyzerEnabled | Sets whether the [experimental](../analyzers/index.html) Python Distribution Analyzer will be used. | true
+pyPackageAnalyzerEnabled | Sets whether the [experimental](../analyzers/index.html) Python Package Analyzer will be used. | true
+rubygemsAnalyzerEnabled | Sets whether the [experimental](../analyzers/index.html) Ruby Gemspec Analyzer will be used. | true
+opensslAnalyzerEnabled | Sets whether the openssl Analyzer should be used. | true
+cmakeAnalyzerEnabled | Sets whether the [experimental](../analyzers/index.html) CMake Analyzer should be used. | true
+autoconfAnalyzerEnabled | Sets whether the [experimental](../analyzers/index.html) autoconf Analyzer should be used. | true
+composerAnalyzerEnabled | Sets whether the [experimental](../analyzers/index.html) PHP Composer Lock File Analyzer should be used. | true
+nodeAnalyzerEnabled | Sets whether the [experimental](../analyzers/index.html) Node.js Analyzer should be used. | true
+nuspecAnalyzerEnabled | Sets whether the .NET Nuget Nuspec Analyzer will be used. | true
+assemblyAnalyzerEnabled | Sets whether the .NET Assembly Analyzer should be used. | true
+pathToMono | The path to Mono for .NET assembly analysis on non-windows systems. |
Advanced Configuration
====================
diff --git a/dependency-check-cli/pom.xml b/dependency-check-cli/pom.xml
index 33b10ec80..aa2e2faef 100644
--- a/dependency-check-cli/pom.xml
+++ b/dependency-check-cli/pom.xml
@@ -20,7 +20,7 @@ Copyright (c) 2012 - Jeremy Long. All Rights Reserved.
org.owaspdependency-check-parent
- 1.3.7-SNAPSHOT
+ 1.4.0-SNAPSHOTdependency-check-cli
diff --git a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/App.java b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/App.java
index f34108383..c8bc71cd6 100644
--- a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/App.java
+++ b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/App.java
@@ -280,6 +280,7 @@ public class App {
final String cveBase12 = cli.getBaseCve12Url();
final String cveBase20 = cli.getBaseCve20Url();
final Integer cveValidForHours = cli.getCveValidForHours();
+ final boolean experimentalEnabled = cli.isExperimentalEnabled();
if (propertiesFile != null) {
try {
@@ -318,6 +319,7 @@ public class App {
Settings.setIntIfNotNull(Settings.KEYS.CVE_CHECK_VALID_FOR_HOURS, cveValidForHours);
//File Type Analyzer Settings
+ Settings.setBoolean(Settings.KEYS.ANALYZER_EXPERIMENTAL_ENABLED, experimentalEnabled);
Settings.setBoolean(Settings.KEYS.ANALYZER_JAR_ENABLED, !cli.isJarDisabled());
Settings.setBoolean(Settings.KEYS.ANALYZER_ARCHIVE_ENABLED, !cli.isArchiveDisabled());
Settings.setBoolean(Settings.KEYS.ANALYZER_PYTHON_DISTRIBUTION_ENABLED, !cli.isPythonDistributionDisabled());
diff --git a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java
index 33ffc841b..d2e522834 100644
--- a/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java
+++ b/dependency-check-cli/src/main/java/org/owasp/dependencycheck/CliParser.java
@@ -58,7 +58,8 @@ public final class CliParser {
* Parses the arguments passed in and captures the results for later use.
*
* @param args the command line arguments
- * @throws FileNotFoundException is thrown when a 'file' argument does not point to a file that exists.
+ * @throws FileNotFoundException is thrown when a 'file' argument does not
+ * point to a file that exists.
* @throws ParseException is thrown when a Parse Exception occurs.
*/
public void parse(String[] args) throws FileNotFoundException, ParseException {
@@ -85,9 +86,10 @@ public final class CliParser {
/**
* Validates that the command line arguments are valid.
*
- * @throws FileNotFoundException if there is a file specified by either the SCAN or CPE command line arguments that does not
- * exist.
- * @throws ParseException is thrown if there is an exception parsing the command line.
+ * @throws FileNotFoundException if there is a file specified by either the
+ * SCAN or CPE command line arguments that does not exist.
+ * @throws ParseException is thrown if there is an exception parsing the
+ * command line.
*/
private void validateArgs() throws FileNotFoundException, ParseException {
if (isUpdateOnly() || isRunScan()) {
@@ -141,12 +143,14 @@ public final class CliParser {
}
/**
- * Validates whether or not the path(s) points at a file that exists; if the path(s) does not point to an existing file a
- * FileNotFoundException is thrown.
+ * Validates whether or not the path(s) points at a file that exists; if the
+ * path(s) does not point to an existing file a FileNotFoundException is
+ * thrown.
*
* @param paths the paths to validate if they exists
* @param optType the option being validated (e.g. scan, out, etc.)
- * @throws FileNotFoundException is thrown if one of the paths being validated does not exist.
+ * @throws FileNotFoundException is thrown if one of the paths being
+ * validated does not exist.
*/
private void validatePathExists(String[] paths, String optType) throws FileNotFoundException {
for (String path : paths) {
@@ -155,12 +159,14 @@ public final class CliParser {
}
/**
- * Validates whether or not the path points at a file that exists; if the path does not point to an existing file a
- * FileNotFoundException is thrown.
+ * Validates whether or not the path points at a file that exists; if the
+ * path does not point to an existing file a FileNotFoundException is
+ * thrown.
*
* @param path the paths to validate if they exists
* @param argumentName the argument being validated (e.g. scan, out, etc.)
- * @throws FileNotFoundException is thrown if the path being validated does not exist.
+ * @throws FileNotFoundException is thrown if the path being validated does
+ * not exist.
*/
private void validatePathExists(String path, String argumentName) throws FileNotFoundException {
if (path == null) {
@@ -181,12 +187,10 @@ public final class CliParser {
throw new FileNotFoundException(msg);
}
}
- } else {
- if (!f.exists()) {
- isValid = false;
- final String msg = String.format("Invalid '%s' argument: '%s'", argumentName, path);
- throw new FileNotFoundException(msg);
- }
+ } else if (!f.exists()) {
+ isValid = false;
+ final String msg = String.format("Invalid '%s' argument: '%s'", argumentName, path);
+ throw new FileNotFoundException(msg);
}
} else if (path.startsWith("//") || path.startsWith("\\\\")) {
isValid = false;
@@ -196,7 +200,8 @@ public final class CliParser {
}
/**
- * Generates an Options collection that is used to parse the command line and to display the help message.
+ * Generates an Options collection that is used to parse the command line
+ * and to display the help message.
*
* @return the command line options used for parsing the command line
*/
@@ -272,6 +277,10 @@ public final class CliParser {
.desc("The number of hours to wait before checking for new updates from the NVD.")
.build();
+ final Option experimentalEnabled = Option.builder().longOpt(ARGUMENT.EXPERIMENTAL)
+ .desc("Enables the experimental analzers.")
+ .build();
+
//This is an option group because it can be specified more then once.
final OptionGroup og = new OptionGroup();
og.addOption(path);
@@ -292,12 +301,14 @@ public final class CliParser {
.addOption(props)
.addOption(verboseLog)
.addOption(suppressionFile)
- .addOption(cveValidForHours);
+ .addOption(cveValidForHours)
+ .addOption(experimentalEnabled);
}
/**
- * Adds the advanced command line options to the given options collection. These are split out for purposes of being able to
- * display two different help messages.
+ * Adds the advanced command line options to the given options collection.
+ * These are split out for purposes of being able to display two different
+ * help messages.
*
* @param options a collection of command line arguments
* @throws IllegalArgumentException thrown if there is an exception
@@ -466,8 +477,10 @@ public final class CliParser {
}
/**
- * Adds the deprecated command line options to the given options collection. These are split out for purposes of not including
- * them in the help message. We need to add the deprecated options so as not to break existing scripts.
+ * Adds the deprecated command line options to the given options collection.
+ * These are split out for purposes of not including them in the help
+ * message. We need to add the deprecated options so as not to break
+ * existing scripts.
*
* @param options a collection of command line arguments
* @throws IllegalArgumentException thrown if there is an exception
@@ -514,7 +527,8 @@ public final class CliParser {
}
/**
- * Returns the symbolic link depth (how deeply symbolic links will be followed).
+ * Returns the symbolic link depth (how deeply symbolic links will be
+ * followed).
*
* @return the symbolic link depth
*/
@@ -534,7 +548,8 @@ public final class CliParser {
/**
* Returns true if the disableJar command line argument was specified.
*
- * @return true if the disableJar command line argument was specified; otherwise false
+ * @return true if the disableJar command line argument was specified;
+ * otherwise false
*/
public boolean isJarDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_JAR);
@@ -543,7 +558,8 @@ public final class CliParser {
/**
* Returns true if the disableArchive command line argument was specified.
*
- * @return true if the disableArchive command line argument was specified; otherwise false
+ * @return true if the disableArchive command line argument was specified;
+ * otherwise false
*/
public boolean isArchiveDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_ARCHIVE);
@@ -552,7 +568,8 @@ public final class CliParser {
/**
* Returns true if the disableNuspec command line argument was specified.
*
- * @return true if the disableNuspec command line argument was specified; otherwise false
+ * @return true if the disableNuspec command line argument was specified;
+ * otherwise false
*/
public boolean isNuspecDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_NUSPEC);
@@ -561,16 +578,19 @@ public final class CliParser {
/**
* Returns true if the disableAssembly command line argument was specified.
*
- * @return true if the disableAssembly command line argument was specified; otherwise false
+ * @return true if the disableAssembly command line argument was specified;
+ * otherwise false
*/
public boolean isAssemblyDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_ASSEMBLY);
}
/**
- * Returns true if the disableBundleAudit command line argument was specified.
+ * Returns true if the disableBundleAudit command line argument was
+ * specified.
*
- * @return true if the disableBundleAudit command line argument was specified; otherwise false
+ * @return true if the disableBundleAudit command line argument was
+ * specified; otherwise false
*/
public boolean isBundleAuditDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_BUNDLE_AUDIT);
@@ -579,7 +599,8 @@ public final class CliParser {
/**
* Returns true if the disablePyDist command line argument was specified.
*
- * @return true if the disablePyDist command line argument was specified; otherwise false
+ * @return true if the disablePyDist command line argument was specified;
+ * otherwise false
*/
public boolean isPythonDistributionDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_PY_DIST);
@@ -588,7 +609,8 @@ public final class CliParser {
/**
* Returns true if the disablePyPkg command line argument was specified.
*
- * @return true if the disablePyPkg command line argument was specified; otherwise false
+ * @return true if the disablePyPkg command line argument was specified;
+ * otherwise false
*/
public boolean isPythonPackageDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_PY_PKG);
@@ -597,7 +619,8 @@ public final class CliParser {
/**
* Returns whether the Ruby gemspec analyzer is disabled.
*
- * @return true if the {@link ARGUMENT#DISABLE_RUBYGEMS} command line argument was specified; otherwise false
+ * @return true if the {@link ARGUMENT#DISABLE_RUBYGEMS} command line
+ * argument was specified; otherwise false
*/
public boolean isRubyGemspecDisabled() {
return (null != line) && line.hasOption(ARGUMENT.DISABLE_RUBYGEMS);
@@ -606,7 +629,8 @@ public final class CliParser {
/**
* Returns true if the disableCmake command line argument was specified.
*
- * @return true if the disableCmake command line argument was specified; otherwise false
+ * @return true if the disableCmake command line argument was specified;
+ * otherwise false
*/
public boolean isCmakeDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_CMAKE);
@@ -615,7 +639,8 @@ public final class CliParser {
/**
* Returns true if the disableAutoconf command line argument was specified.
*
- * @return true if the disableAutoconf command line argument was specified; otherwise false
+ * @return true if the disableAutoconf command line argument was specified;
+ * otherwise false
*/
public boolean isAutoconfDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_AUTOCONF);
@@ -624,7 +649,8 @@ public final class CliParser {
/**
* Returns true if the disableComposer command line argument was specified.
*
- * @return true if the disableComposer command line argument was specified; otherwise false
+ * @return true if the disableComposer command line argument was specified;
+ * otherwise false
*/
public boolean isComposerDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_COMPOSER);
@@ -633,7 +659,8 @@ public final class CliParser {
/**
* Returns true if the disableNexus command line argument was specified.
*
- * @return true if the disableNexus command line argument was specified; otherwise false
+ * @return true if the disableNexus command line argument was specified;
+ * otherwise false
*/
public boolean isNexusDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_NEXUS);
@@ -642,7 +669,8 @@ public final class CliParser {
/**
* Returns true if the disableOpenSSL command line argument was specified.
*
- * @return true if the disableOpenSSL command line argument was specified; otherwise false
+ * @return true if the disableOpenSSL command line argument was specified;
+ * otherwise false
*/
public boolean isOpenSSLDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_OPENSSL);
@@ -651,7 +679,8 @@ public final class CliParser {
/**
* Returns true if the disableNodeJS command line argument was specified.
*
- * @return true if the disableNodeJS command line argument was specified; otherwise false
+ * @return true if the disableNodeJS command line argument was specified;
+ * otherwise false
*/
public boolean isNodeJsDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_NODE_JS);
@@ -660,7 +689,8 @@ public final class CliParser {
/**
* Returns true if the disableCentral command line argument was specified.
*
- * @return true if the disableCentral command line argument was specified; otherwise false
+ * @return true if the disableCentral command line argument was specified;
+ * otherwise false
*/
public boolean isCentralDisabled() {
return (line != null) && line.hasOption(ARGUMENT.DISABLE_CENTRAL);
@@ -669,7 +699,8 @@ public final class CliParser {
/**
* Returns the url to the nexus server if one was specified.
*
- * @return the url to the nexus server; if none was specified this will return null;
+ * @return the url to the nexus server; if none was specified this will
+ * return null;
*/
public String getNexusUrl() {
if (line == null || !line.hasOption(ARGUMENT.NEXUS_URL)) {
@@ -680,9 +711,11 @@ public final class CliParser {
}
/**
- * Returns true if the Nexus Analyzer should use the configured proxy to connect to Nexus; otherwise false is returned.
+ * Returns true if the Nexus Analyzer should use the configured proxy to
+ * connect to Nexus; otherwise false is returned.
*
- * @return true if the Nexus Analyzer should use the configured proxy to connect to Nexus; otherwise false
+ * @return true if the Nexus Analyzer should use the configured proxy to
+ * connect to Nexus; otherwise false
*/
public boolean isNexusUsesProxy() {
// If they didn't specify whether Nexus needs to use the proxy, we should
@@ -722,7 +755,8 @@ public final class CliParser {
}
/**
- * Retrieves the file command line parameter(s) specified for the 'scan' argument.
+ * Retrieves the file command line parameter(s) specified for the 'scan'
+ * argument.
*
* @return the file paths specified on the command line for scan
*/
@@ -731,7 +765,8 @@ public final class CliParser {
}
/**
- * Retrieves the list of excluded file patterns specified by the 'exclude' argument.
+ * Retrieves the list of excluded file patterns specified by the 'exclude'
+ * argument.
*
* @return the excluded file patterns
*/
@@ -740,7 +775,8 @@ public final class CliParser {
}
/**
- * Returns the directory to write the reports to specified on the command line.
+ * Returns the directory to write the reports to specified on the command
+ * line.
*
* @return the path to the reports directory.
*/
@@ -749,7 +785,8 @@ public final class CliParser {
}
/**
- * Returns the path to Mono for .NET Assembly analysis on non-windows systems.
+ * Returns the path to Mono for .NET Assembly analysis on non-windows
+ * systems.
*
* @return the path to Mono
*/
@@ -767,7 +804,8 @@ public final class CliParser {
}
/**
- * Returns the output format specified on the command line. Defaults to HTML if no format was specified.
+ * Returns the output format specified on the command line. Defaults to HTML
+ * if no format was specified.
*
* @return the output format name.
*/
@@ -934,9 +972,11 @@ public final class CliParser {
}
/**
- * Checks if the auto update feature has been disabled. If it has been disabled via the command line this will return false.
+ * Checks if the auto update feature has been disabled. If it has been
+ * disabled via the command line this will return false.
*
- * @return true if auto-update is allowed; otherwise false
+ * @return true if auto-update is allowed; otherwise
+ * false
*/
public boolean isAutoUpdate() {
return line != null && !line.hasOption(ARGUMENT.DISABLE_AUTO_UPDATE);
@@ -945,7 +985,8 @@ public final class CliParser {
/**
* Checks if the update only flag has been set.
*
- * @return true if the update only flag has been set; otherwise false.
+ * @return true if the update only flag has been set; otherwise
+ * false.
*/
public boolean isUpdateOnly() {
return line != null && line.hasOption(ARGUMENT.UPDATE_ONLY);
@@ -954,14 +995,16 @@ public final class CliParser {
/**
* Checks if the purge NVD flag has been set.
*
- * @return true if the purge nvd flag has been set; otherwise false.
+ * @return true if the purge nvd flag has been set; otherwise
+ * false.
*/
public boolean isPurge() {
return line != null && line.hasOption(ARGUMENT.PURGE_NVD);
}
/**
- * Returns the database driver name if specified; otherwise null is returned.
+ * Returns the database driver name if specified; otherwise null is
+ * returned.
*
* @return the database driver name if specified; otherwise null is returned
*/
@@ -970,7 +1013,8 @@ public final class CliParser {
}
/**
- * Returns the database driver path if specified; otherwise null is returned.
+ * Returns the database driver path if specified; otherwise null is
+ * returned.
*
* @return the database driver name if specified; otherwise null is returned
*/
@@ -979,34 +1023,41 @@ public final class CliParser {
}
/**
- * Returns the database connection string if specified; otherwise null is returned.
+ * Returns the database connection string if specified; otherwise null is
+ * returned.
*
- * @return the database connection string if specified; otherwise null is returned
+ * @return the database connection string if specified; otherwise null is
+ * returned
*/
public String getConnectionString() {
return line.getOptionValue(ARGUMENT.CONNECTION_STRING);
}
/**
- * Returns the database database user name if specified; otherwise null is returned.
+ * Returns the database database user name if specified; otherwise null is
+ * returned.
*
- * @return the database database user name if specified; otherwise null is returned
+ * @return the database database user name if specified; otherwise null is
+ * returned
*/
public String getDatabaseUser() {
return line.getOptionValue(ARGUMENT.DB_NAME);
}
/**
- * Returns the database database password if specified; otherwise null is returned.
+ * Returns the database database password if specified; otherwise null is
+ * returned.
*
- * @return the database database password if specified; otherwise null is returned
+ * @return the database database password if specified; otherwise null is
+ * returned
*/
public String getDatabasePassword() {
return line.getOptionValue(ARGUMENT.DB_PASSWORD);
}
/**
- * Returns the additional Extensions if specified; otherwise null is returned.
+ * Returns the additional Extensions if specified; otherwise null is
+ * returned.
*
* @return the additional Extensions; otherwise null is returned
*/
@@ -1028,7 +1079,17 @@ public final class CliParser {
}
/**
- * A collection of static final strings that represent the possible command line arguments.
+ * Returns true if the experimental analyzers are enabled.
+ *
+ * @return true if the experimental analyzers are enabled; otherwise false
+ */
+ public boolean isExperimentalEnabled() {
+ return line.hasOption(ARGUMENT.EXPERIMENTAL);
+ }
+
+ /**
+ * A collection of static final strings that represent the possible command
+ * line arguments.
*/
public static class ARGUMENT {
@@ -1041,50 +1102,61 @@ public final class CliParser {
*/
public static final String SCAN_SHORT = "s";
/**
- * The long CLI argument name specifying that the CPE/CVE/etc. data should not be automatically updated.
+ * 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 specifying that the CPE/CVE/etc. data should not be automatically updated.
+ * 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 specifying that only the update phase should be executed; no scan should be run.
+ * The long CLI argument name specifying that only the update phase
+ * should be executed; no scan should be run.
*/
public static final String UPDATE_ONLY = "updateonly";
/**
- * The long CLI argument name specifying that only the update phase should be executed; no scan should be run.
+ * The long CLI argument name specifying that only the update phase
+ * should be executed; no scan should be run.
*/
public static final String PURGE_NVD = "purge";
/**
- * The long CLI argument name specifying the directory to write the reports to.
+ * The long CLI argument name specifying the directory to write the
+ * reports to.
*/
public static final String OUT = "out";
/**
- * The short CLI argument name specifying the directory to write the reports to.
+ * 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 specifying the output format to write the reports to.
+ * 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 specifying the output format to write the reports to.
+ * 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 specifying the name of the project to be scanned.
+ * The long CLI argument name specifying the name of the project to be
+ * scanned.
*/
public static final String PROJECT = "project";
/**
- * The long CLI argument name specifying the name of the application to be scanned.
+ * The long CLI argument name specifying the name of the application to
+ * be scanned.
*
* @deprecated project should be used instead
*/
@Deprecated
public static final String APP_NAME = "app";
/**
- * The short CLI argument name specifying the name of the application to be scanned.
+ * The short CLI argument name specifying the name of the application to
+ * be scanned.
*
* @deprecated project should be used instead
*/
@@ -1142,11 +1214,13 @@ public final class CliParser {
*/
public static final String CONNECTION_TIMEOUT = "connectiontimeout";
/**
- * The short CLI argument name for setting the location of an additional properties file.
+ * The short CLI argument name for setting the location of an additional
+ * properties file.
*/
public static final String PROP_SHORT = "P";
/**
- * The CLI argument name for setting the location of an additional properties file.
+ * The CLI argument name for setting the location of an additional
+ * properties file.
*/
public static final String PROP = "propertyfile";
/**
@@ -1170,7 +1244,8 @@ public final class CliParser {
*/
public static final String CVE_BASE_20 = "cveUrl20Base";
/**
- * The short CLI argument name for setting the location of the data directory.
+ * The short CLI argument name for setting the location of the data
+ * directory.
*/
public static final String DATA_DIRECTORY_SHORT = "d";
/**
@@ -1178,20 +1253,24 @@ public final class CliParser {
*/
public static final String VERBOSE_LOG = "log";
/**
- * The short CLI argument name for setting the location of the data directory.
+ * The short CLI argument name for setting the location of the data
+ * directory.
*/
public static final String VERBOSE_LOG_SHORT = "l";
/**
- * The CLI argument name for setting the depth of symbolic links that will be followed.
+ * The CLI argument name for setting the depth of symbolic links that
+ * will be followed.
*/
public static final String SYM_LINK_DEPTH = "symLink";
/**
- * The CLI argument name for setting the location of the suppression file.
+ * The CLI argument name for setting the location of the suppression
+ * file.
*/
public static final String SUPPRESSION_FILE = "suppression";
/**
- * The CLI argument name for setting the location of the suppression file.
+ * The CLI argument name for setting the location of the suppression
+ * file.
*/
public static final String CVE_VALID_FOR_HOURS = "cveValidForHours";
/**
@@ -1259,7 +1338,8 @@ public final class CliParser {
*/
public static final String NEXUS_URL = "nexus";
/**
- * Whether or not the defined proxy should be used when connecting to Nexus.
+ * Whether or not the defined proxy should be used when connecting to
+ * Nexus.
*/
public static final String NEXUS_USES_PROXY = "nexusUsesProxy";
/**
@@ -1279,11 +1359,13 @@ public final class CliParser {
*/
public static final String DB_DRIVER = "dbDriverName";
/**
- * The CLI argument name for setting the path to the database driver; in case it is not on the class path.
+ * The CLI argument name for setting the path to the database driver; in
+ * case it is not on the class path.
*/
public static final String DB_DRIVER_PATH = "dbDriverPath";
/**
- * The CLI argument name for setting the path to mono for .NET Assembly analysis on non-windows systems.
+ * The CLI argument name for setting the path to mono for .NET Assembly
+ * analysis on non-windows systems.
*/
public static final String PATH_TO_MONO = "mono";
/**
@@ -1295,8 +1377,13 @@ public final class CliParser {
*/
public static final String EXCLUDE = "exclude";
/**
- * The CLI argument name for setting the path to bundle-audit for Ruby bundle analysis.
+ * The CLI argument name for setting the path to bundle-audit for Ruby
+ * bundle analysis.
*/
public static final String PATH_TO_BUNDLE_AUDIT = "bundleAudit";
+ /**
+ * The CLI argument to enable the experimental analyzers.
+ */
+ private static final String EXPERIMENTAL = "enableExperimental";
}
}
diff --git a/dependency-check-cli/src/site/markdown/arguments.md b/dependency-check-cli/src/site/markdown/arguments.md
index 66f37af01..486acadfd 100644
--- a/dependency-check-cli/src/site/markdown/arguments.md
+++ b/dependency-check-cli/src/site/markdown/arguments.md
@@ -18,7 +18,7 @@ Short | Argument Name | Parameter | Description | Requir
| \-\-advancedHelp | | Print the advanced help message. | Optional
\-v | \-\-version | | Print the version information. | Optional
| \-\-cveValidForHours | \ | The number of hours to wait before checking for new updates from the NVD. The default is 4 hours. | Optional
-
+ | \-\-experimental | | Enable the [experimental analyzers](../analyzers/index.html). If not set the analyzers marked as experimental below will not be loaded or used. | Optional
Advanced Options
================
@@ -30,18 +30,18 @@ Short | Argument Name | Paramete
| \-\-cveUrl20Base | \ | Base URL for each year's CVE 2.0, the %d will be replaced with the year | https://nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-%d.xml.gz
\-P | \-\-propertyfile | \ | Specifies a file that contains properties to use instead of applicaion defaults. |
| \-\-updateonly | | If set only the update phase of dependency-check will be executed; no scan will be executed and no report will be generated. |
- | \-\-disablePyDist | | Sets whether the Python Distribution Analyzer will be used. | false
- | \-\-disablePyPkg | | Sets whether the Python Package Analyzer will be used. | false
- | \-\-disableNodeJS | | Sets whether the Node.js Package Analyzer will be used. | false
- | \-\-disableRubygems | | Sets whether the Ruby Gemspec Analyzer will be used. | false
- | \-\-disableBundleAudit | | Sets whether the Ruby Bundler Audit Analyzer will be used. | false
- | \-\-disableAutoconf | | Sets whether the Autoconf Analyzer will be used. | false
+ | \-\-disablePyDist | | Sets whether the [experimental](../analyzers/index.html) Python Distribution Analyzer will be used. | false
+ | \-\-disablePyPkg | | Sets whether the [experimental](../analyzers/index.html) Python Package Analyzer will be used. | false
+ | \-\-disableNodeJS | | Sets whether the [experimental](../analyzers/index.html) Node.js Package Analyzer will be used. | false
+ | \-\-disableRubygems | | Sets whether the [experimental](../analyzers/index.html) Ruby Gemspec Analyzer will be used. | false
+ | \-\-disableBundleAudit | | Sets whether the [experimental](../analyzers/index.html) Ruby Bundler Audit Analyzer will be used. | false
+ | \-\-disableAutoconf | | Sets whether the [experimental](../analyzers/index.html) Autoconf Analyzer will be used. | false
| \-\-disableOpenSSL | | Sets whether the OpenSSL Analyzer will be used. | false
- | \-\-disableCmake | | Sets whether the Cmake Analyzer will be disabled. | false
+ | \-\-disableCmake | | Sets whether the [experimental](../analyzers/index.html) Cmake Analyzer will be disabled. | false
| \-\-disableArchive | | Sets whether the Archive Analyzer will be disabled. | false
| \-\-zipExtensions | \ | A comma-separated list of additional file extensions to be treated like a ZIP file, the contents will be extracted and analyzed. |
| \-\-disableJar | | Sets whether the Jar Analyzer will be disabled. | false
- | \-\-disableComposer | | Sets whether the PHP Composer Lock File Analyzer will be disabled. | false
+ | \-\-disableComposer | | Sets whether the [experimental](../analyzers/index.html) PHP Composer Lock File Analyzer will be disabled. | false
| \-\-disableCentral | | Sets whether the Central Analyzer will be used. **Disabling this analyzer is not recommended as it could lead to false negatives (e.g. libraries that have vulnerabilities may not be reported correctly).** If this analyzer is being disabled there is a good chance you also want to disable the Nexus Analyzer. | false
| \-\-disableNexus | | Sets whether the Nexus Analyzer will be used. Note, this has been superceded by the Central Analyzer. However, you can configure the Nexus URL to utilize an internally hosted Nexus Pro server. | false
| \-\-nexus | \ | The url to the Nexus Server's web service end point (example: http://domain.enterprise/nexus/service/local/). If not set the Nexus Analyzer will be disabled. |
@@ -50,7 +50,7 @@ Short | Argument Name | Paramete
| \-\-disableAssembly | | Sets whether or not the .NET Assembly Analyzer should be used. | false
| \-\-mono | \ | The path to Mono for .NET Assembly analysis on non-windows systems. |
| \-\-bundleAudit | | The path to the bundle-audit executable. |
- | \-\-proxyserver | \ | The proxy server to use when downloading resources. |
+ | \-\-proxyserver | \ | The proxy server to use when downloading resources; see the [proxy configuration](../data/proxy.html) page for more information. |
| \-\-proxyport | \ | The proxy port to use when downloading resources. |
| \-\-connectiontimeout | \ | The connection timeout (in milliseconds) to use when downloading resources. |
| \-\-proxypass | \ | The proxy password to use when downloading resources. |
diff --git a/dependency-check-core/pom.xml b/dependency-check-core/pom.xml
index fcf2641d0..df94d7f5b 100644
--- a/dependency-check-core/pom.xml
+++ b/dependency-check-core/pom.xml
@@ -20,7 +20,7 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
org.owaspdependency-check-parent
- 1.3.7-SNAPSHOT
+ 1.4.0-SNAPSHOTdependency-check-core
@@ -83,9 +83,6 @@ Copyright (c) 2012 Jeremy Long. All Rights Reserved.
${basedir}/src/test/resources
-
- **/mysql-connector-java-5.1.27-bin.jar
- false
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java
index fa120a0e8..c35a796e0 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/Engine.java
@@ -126,9 +126,8 @@ public class Engine implements FileFilter {
}
final AnalyzerService service = new AnalyzerService(serviceClassLoader);
- final Iterator iterator = service.getAnalyzers();
- while (iterator.hasNext()) {
- final Analyzer a = iterator.next();
+ final List iterator = service.getAnalyzers();
+ for (Analyzer a : iterator) {
analyzers.get(a.getAnalysisPhase()).add(a);
if (a instanceof FileTypeAnalyzer) {
this.fileTypeAnalyzers.add((FileTypeAnalyzer) a);
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.java
index 97c0719d5..812f70394 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.java
@@ -24,7 +24,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Set;
-import java.util.logging.Level;
import java.util.regex.Pattern;
import org.owasp.dependencycheck.suppression.SuppressionParseException;
import org.owasp.dependencycheck.suppression.SuppressionParser;
@@ -38,7 +37,8 @@ import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
/**
- * Abstract base suppression analyzer that contains methods for parsing the suppression xml file.
+ * Abstract base suppression analyzer that contains methods for parsing the
+ * suppression xml file.
*
* @author Jeremy Long
*/
@@ -173,7 +173,8 @@ public abstract class AbstractSuppressionAnalyzer extends AbstractAnalyzer {
*
* @param message the exception message
* @param exception the cause of the exception
- * @throws SuppressionParseException throws the generated SuppressionParseException
+ * @throws SuppressionParseException throws the generated
+ * SuppressionParseException
*/
private void throwSuppressionParseException(String message, Exception exception) throws SuppressionParseException {
LOGGER.warn(message);
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AnalyzerService.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AnalyzerService.java
index a794b1030..e27f95649 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AnalyzerService.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AnalyzerService.java
@@ -17,8 +17,13 @@
*/
package org.owasp.dependencycheck.analyzer;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.ServiceLoader;
+import org.owasp.dependencycheck.utils.InvalidSettingException;
+import org.owasp.dependencycheck.utils.Settings;
+import org.slf4j.LoggerFactory;
/**
* The Analyzer Service Loader. This class loads all services that implement
@@ -27,11 +32,15 @@ import java.util.ServiceLoader;
* @author Jeremy Long
*/
public class AnalyzerService {
+ /**
+ * The Logger for use throughout the class.
+ */
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(AnalyzerService.class);
/**
* The service loader for analyzers.
*/
- private final ServiceLoader loader;
+ private final ServiceLoader service;
/**
* Creates a new instance of AnalyzerService.
@@ -39,15 +48,31 @@ public class AnalyzerService {
* @param classLoader the ClassLoader to use when dynamically loading Analyzer and Update services
*/
public AnalyzerService(ClassLoader classLoader) {
- loader = ServiceLoader.load(Analyzer.class, classLoader);
+ service = ServiceLoader.load(Analyzer.class, classLoader);
}
/**
- * Returns an Iterator for all instances of the Analyzer interface.
+ * Returns a list of all instances of the Analyzer interface.
*
- * @return an iterator of Analyzers.
+ * @return a list of Analyzers.
*/
- public Iterator getAnalyzers() {
- return loader.iterator();
+ public List getAnalyzers() {
+ final List analyzers = new ArrayList();
+ final Iterator iterator = service.iterator();
+ boolean experimentalEnabled = false;
+ try {
+ experimentalEnabled = Settings.getBoolean(Settings.KEYS.ANALYZER_EXPERIMENTAL_ENABLED, false);
+ } catch (InvalidSettingException ex) {
+ LOGGER.error("invalide experimental setting", ex);
+ }
+ while (iterator.hasNext()) {
+ final Analyzer a = iterator.next();
+ if (!experimentalEnabled && a.getClass().isAnnotationPresent(Experimental.class)) {
+ continue;
+ }
+ LOGGER.debug("Loaded Analyzer {}", a.getName());
+ analyzers.add(a);
+ }
+ return analyzers;
}
}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AutoconfAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AutoconfAnalyzer.java
index 7a865ecbf..01f9080e5 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AutoconfAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/AutoconfAnalyzer.java
@@ -43,6 +43,7 @@ import java.util.regex.Pattern;
* @author Dale Visser
* @see Autoconf - GNU Project - Free Software Foundation (FSF)
*/
+@Experimental
public class AutoconfAnalyzer extends AbstractFileTypeAnalyzer {
/**
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CMakeAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CMakeAnalyzer.java
index 6237f4777..41c66d5a5 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CMakeAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CMakeAnalyzer.java
@@ -50,6 +50,7 @@ import java.util.regex.Pattern;
*
* @author Dale Visser
*/
+@Experimental
public class CMakeAnalyzer extends AbstractFileTypeAnalyzer {
/**
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 dc53ee3cd..d2fcfb14a 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
@@ -51,8 +51,9 @@ 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
- * the evidence contained within the dependency to search the Lucene index.
+ * CPEAnalyzer is a utility class that takes a project dependency and attempts
+ * to discern if there is an associated CPE. It uses the evidence contained
+ * within the dependency to search the Lucene index.
*
* @author Jeremy Long
*/
@@ -71,15 +72,18 @@ public class CPEAnalyzer implements Analyzer {
*/
static final String WEIGHTING_BOOST = "^5";
/**
- * A string representation of a regular expression defining characters utilized within the CPE Names.
+ * A string representation of a regular expression defining characters
+ * utilized within the CPE Names.
*/
static final String CLEANSE_CHARACTER_RX = "[^A-Za-z0-9 ._-]";
/**
- * A string representation of a regular expression used to remove all but alpha characters.
+ * A string representation of a regular expression used to remove all but
+ * alpha characters.
*/
static final String CLEANSE_NONALPHA_RX = "[^A-Za-z]*";
/**
- * The additional size to add to a new StringBuilder to account for extra data that will be written into the string.
+ * The additional size to add to a new StringBuilder to account for extra
+ * data that will be written into the string.
*/
static final int STRING_BUILDER_BUFFER = 20;
/**
@@ -129,9 +133,10 @@ public class CPEAnalyzer implements Analyzer {
/**
* Opens the data source.
*
- * @throws IOException when the Lucene directory to be queried does not exist or is corrupt.
- * @throws DatabaseException when the database throws an exception. This usually occurs when the database is in use by another
- * process.
+ * @throws IOException when the Lucene directory to be queried does not
+ * exist or is corrupt.
+ * @throws DatabaseException when the database throws an exception. This
+ * usually occurs when the database is in use by another process.
*/
public void open() throws IOException, DatabaseException {
if (!isOpen()) {
@@ -170,8 +175,9 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * Searches the data store of CPE entries, trying to identify the CPE for the given dependency based on the evidence contained
- * within. The dependency passed in is updated with any identified CPE values.
+ * Searches the data store of CPE entries, trying to identify the CPE for
+ * the given dependency based on the evidence contained within. The
+ * 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.
@@ -192,8 +198,8 @@ public class CPEAnalyzer implements Analyzer {
LOGGER.debug("product search: {}", products);
}
if (!vendors.isEmpty() && !products.isEmpty()) {
- final List entries = searchCPE(vendors, products, dependency.getProductEvidence().getWeighting(),
- dependency.getVendorEvidence().getWeighting());
+ final List entries = searchCPE(vendors, products, dependency.getVendorEvidence().getWeighting(),
+ dependency.getProductEvidence().getWeighting());
if (entries == null) {
continue;
}
@@ -215,9 +221,10 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * Returns the text created by concatenating the text and the values from the EvidenceCollection (filtered for a specific
- * confidence). This attempts to prevent duplicate terms from being added. Note, if the evidence is longer then 200
- * characters it will be truncated.
+ * Returns the text created by concatenating the text and the values from
+ * the EvidenceCollection (filtered for a specific confidence). This
+ * attempts to prevent duplicate terms from being added. Note, if
+ * the evidence is longer then 200 characters it will be truncated.
*
* @param text the base text.
* @param ec an EvidenceCollection
@@ -248,17 +255,19 @@ public class CPEAnalyzer implements Analyzer {
/**
*
- * Searches the Lucene CPE index to identify possible CPE entries associated with the supplied vendor, product, and
- * version.
+ * Searches the Lucene CPE index to identify possible CPE entries associated
+ * with the supplied vendor, product, and version.
*
*
- * If either the vendorWeightings or productWeightings lists have been populated this data is used to add weighting factors to
- * the search.
+ * If either the vendorWeightings or productWeightings lists have been
+ * populated this data is used to add weighting factors to the search.
*
* @param vendor the text used to search the vendor field
* @param product the text used to search the product field
- * @param vendorWeightings a list of strings to use to add weighting factors to the vendor field
- * @param productWeightings Adds a list of strings that will be used to add weighting factors to the product search
+ * @param vendorWeightings a list of strings to use to add weighting factors
+ * to the vendor field
+ * @param productWeightings Adds a list of strings that will be used to add
+ * weighting factors to the product search
* @return a list of possible CPE values
*/
protected List searchCPE(String vendor, String product,
@@ -297,16 +306,20 @@ public class CPEAnalyzer implements Analyzer {
/**
*
- * Builds a Lucene search string by properly escaping data and constructing a valid search query.
+ * Builds a Lucene search string by properly escaping data and constructing
+ * a valid search query.
*
*
- * If either the possibleVendor or possibleProducts lists have been populated this data is used to add weighting factors to
- * the search string generated.
+ * If either the possibleVendor or possibleProducts lists have been
+ * populated this data is used to add weighting factors to the search string
+ * generated.
*
* @param vendor text to search the vendor field
* @param product text to search the product field
- * @param vendorWeighting a list of strings to apply to the vendor to boost the terms weight
- * @param productWeightings a list of strings to apply to the product to boost the terms weight
+ * @param vendorWeighting a list of strings to apply to the vendor to boost
+ * the terms weight
+ * @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,
@@ -327,13 +340,17 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * This method constructs a Lucene query for a given field. The searchText 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.
+ * This method constructs a Lucene query for a given field. The searchText
+ * 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.
*
* @param sb a StringBuilder that the query text will be appended to.
- * @param field the field within the Lucene index that the query is searching.
+ * @param field the field within the Lucene index that the query is
+ * searching.
* @param searchText text used to construct the query.
- * @param weightedText a list of terms that will be considered higher importance when searching.
+ * @param weightedText a list of terms that will be considered higher
+ * importance when searching.
* @return if the append was successful.
*/
private boolean appendWeightedSearch(StringBuilder sb, String field, String searchText, Set weightedText) {
@@ -379,7 +396,8 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * Removes characters from the input text that are not used within the CPE index.
+ * Removes characters from the input text that are not used within the CPE
+ * index.
*
* @param text is the text to remove the characters from.
* @return the text having removed some characters.
@@ -389,7 +407,8 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * Compares two strings after lower casing them and removing the non-alpha characters.
+ * Compares two strings after lower casing them and removing the non-alpha
+ * characters.
*
* @param l string one to compare.
* @param r string two to compare.
@@ -406,8 +425,9 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * Ensures that the CPE Identified matches the dependency. This validates that the product, vendor, and version information
- * for the CPE are contained within the dependencies evidence.
+ * Ensures that the CPE Identified matches the dependency. This validates
+ * that the product, vendor, and version information for the CPE are
+ * contained within the dependencies evidence.
*
* @param entry a CPE entry.
* @param dependency the dependency that the CPE entries could be for.
@@ -474,11 +494,13 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * Analyzes a dependency and attempts to determine if there are any CPE identifiers for this dependency.
+ * Analyzes a dependency and attempts to determine if there are any CPE
+ * identifiers for this dependency.
*
* @param dependency The Dependency to analyze.
* @param engine The analysis engine
- * @throws AnalysisException is thrown if there is an issue analyzing the dependency.
+ * @throws AnalysisException is thrown if there is an issue analyzing the
+ * dependency.
*/
@Override
public synchronized void analyze(Dependency dependency, Engine engine) throws AnalysisException {
@@ -494,15 +516,19 @@ public class CPEAnalyzer implements Analyzer {
}
/**
- * Retrieves a list of CPE values from the CveDB based on the vendor and product passed in. The list is then validated to find
- * only CPEs that are valid for the given dependency. It is possible that the CPE identified is a best effort "guess" based on
- * the vendor, product, and version information.
+ * Retrieves a list of CPE values from the CveDB based on the vendor and
+ * product passed in. The list is then validated to find only CPEs that are
+ * valid for the given dependency. It is possible that the CPE identified is
+ * a best effort "guess" based on the vendor, product, and version
+ * information.
*
* @param dependency the Dependency being analyzed
* @param vendor the vendor for the CPE being analyzed
* @param product the product for the CPE being analyzed
- * @param currentConfidence the current confidence being used during analysis
- * @return true if an identifier was added to the dependency; otherwise false
+ * @param currentConfidence the current confidence being used during
+ * analysis
+ * @return true if an identifier was added to the dependency;
+ * otherwise false
* @throws UnsupportedEncodingException is thrown if UTF-8 is not supported
*/
protected boolean determineIdentifiers(Dependency dependency, String vendor, String product,
@@ -512,10 +538,11 @@ public class CPEAnalyzer implements Analyzer {
Confidence bestGuessConf = null;
boolean hasBroadMatch = false;
final List collected = new ArrayList();
+
+ //TODO the following algorithm incorrectly identifies things as a lower version
+ // if there lower confidence evidence when the current (highest) version number
+ // is newer then anything in the NVD.
for (Confidence conf : Confidence.values()) {
-// if (conf.compareTo(currentConfidence) > 0) {
-// break;
-// }
for (Evidence evidence : dependency.getVersionEvidence().iterator(conf)) {
final DependencyVersion evVer = DependencyVersionUtil.parseVersion(evidence.getValue());
if (evVer == null) {
@@ -537,15 +564,13 @@ public class CPEAnalyzer implements Analyzer {
final String url = String.format(NVD_SEARCH_URL, URLEncoder.encode(vs.getName(), "UTF-8"));
final IdentifierMatch match = new IdentifierMatch("cpe", vs.getName(), url, IdentifierConfidence.EXACT_MATCH, conf);
collected.add(match);
- } else {
- //TODO the following isn't quite right is it? need to think about this guessing game a bit more.
- if (evVer.getVersionParts().size() <= dbVer.getVersionParts().size()
- && evVer.matchesAtLeastThreeLevels(dbVer)) {
- if (bestGuessConf == null || bestGuessConf.compareTo(conf) > 0) {
- if (bestGuess.getVersionParts().size() < dbVer.getVersionParts().size()) {
- bestGuess = dbVer;
- bestGuessConf = conf;
- }
+ } else //TODO the following isn't quite right is it? need to think about this guessing game a bit more.
+ if (evVer.getVersionParts().size() <= dbVer.getVersionParts().size()
+ && evVer.matchesAtLeastThreeLevels(dbVer)) {
+ if (bestGuessConf == null || bestGuessConf.compareTo(conf) > 0) {
+ if (bestGuess.getVersionParts().size() < dbVer.getVersionParts().size()) {
+ bestGuess = dbVer;
+ bestGuessConf = conf;
}
}
}
@@ -604,14 +629,16 @@ public class CPEAnalyzer implements Analyzer {
*/
BEST_GUESS,
/**
- * The entire vendor/product group must be added (without a guess at version) because there is a CVE with a VS that only
- * specifies vendor/product.
+ * The entire vendor/product group must be added (without a guess at
+ * version) because there is a CVE with a VS that only specifies
+ * vendor/product.
*/
BROAD_MATCH
}
/**
- * A simple object to hold an identifier and carry information about the confidence in the identifier.
+ * A simple object to hold an identifier and carry information about the
+ * confidence in the identifier.
*/
private static class IdentifierMatch implements Comparable {
@@ -621,8 +648,10 @@ public class CPEAnalyzer implements Analyzer {
* @param type the type of identifier (such as CPE)
* @param value the value of the identifier
* @param url the URL of the identifier
- * @param identifierConfidence the confidence in the identifier: best guess or exact match
- * @param evidenceConfidence the confidence of the evidence used to find the identifier
+ * @param identifierConfidence the confidence in the identifier: best
+ * guess or exact match
+ * @param evidenceConfidence the confidence of the evidence used to find
+ * the identifier
*/
IdentifierMatch(String type, String value, String url, IdentifierConfidence identifierConfidence, Confidence evidenceConfidence) {
this.identifier = new Identifier(type, value, url);
@@ -753,7 +782,8 @@ public class CPEAnalyzer implements Analyzer {
//
/**
- * Standard implementation of compareTo that compares identifier confidence, evidence confidence, and then the identifier.
+ * Standard implementation of compareTo that compares identifier
+ * confidence, evidence confidence, and then the identifier.
*
* @param o the IdentifierMatch to compare to
* @return the natural ordering of IdentifierMatch
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ComposerLockAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ComposerLockAnalyzer.java
index cd354b709..df68ac8d3 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ComposerLockAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/ComposerLockAnalyzer.java
@@ -41,6 +41,7 @@ import java.security.MessageDigest;
*
* @author colezlaw
*/
+@Experimental
public class ComposerLockAnalyzer extends AbstractFileTypeAnalyzer {
/**
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 8a877c87a..42b322e65 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
@@ -35,11 +35,14 @@ import org.slf4j.LoggerFactory;
/**
*
- * This analyzer ensures dependencies that should be grouped together, to remove excess noise from the report, are grouped. An
- * example would be Spring, Spring Beans, Spring MVC, etc. If they are all for the same version and have the same relative path
- * then these should be grouped into a single dependency under the core/main library.
+ * This analyzer ensures dependencies that should be grouped together, to remove
+ * excess noise from the report, are grouped. An example would be Spring, Spring
+ * Beans, Spring MVC, etc. If they are all for the same version and have the
+ * same relative path then these should be grouped into a single dependency
+ * under the core/main library.
*
- * Note, this grouping only works on dependencies with identified CVE entries
+ * Note, this grouping only works on dependencies with identified CVE
+ * entries
*
* @author Jeremy Long
*/
@@ -92,12 +95,14 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
//
/**
- * Analyzes a set of dependencies. If they have been found to have the same base path and the same set of identifiers they are
- * likely related. The related dependencies are bundled into a single reportable item.
+ * Analyzes a set of dependencies. If they have been found to have the same
+ * base path and the same set of identifiers they are likely related. The
+ * related dependencies are bundled into a single reportable item.
*
* @param ignore this analyzer ignores the dependency being analyzed
* @param engine the engine that is scanning the dependencies
- * @throws AnalysisException is thrown if there is an error reading the JAR file.
+ * @throws AnalysisException is thrown if there is an error reading the JAR
+ * file.
*/
@Override
public void analyze(Dependency ignore, Engine engine) throws AnalysisException {
@@ -167,10 +172,11 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
* Adds the relatedDependency to the dependency's related dependencies.
*
* @param dependency the main dependency
- * @param relatedDependency a collection of dependencies to be removed from the main analysis loop, this is the source of
- * dependencies to remove
- * @param dependenciesToRemove a collection of dependencies that will be removed from the main analysis loop, this function
- * adds to this collection
+ * @param relatedDependency a collection of dependencies to be removed from
+ * the main analysis loop, this is the source of dependencies to remove
+ * @param dependenciesToRemove a collection of dependencies that will be
+ * removed from the main analysis loop, this function adds to this
+ * collection
*/
private void mergeDependencies(final Dependency dependency, final Dependency relatedDependency, final Set dependenciesToRemove) {
dependency.addRelatedDependency(relatedDependency);
@@ -186,7 +192,8 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
/**
- * Attempts to trim a maven repo to a common base path. This is typically [drive]\[repo_location]\repository\[path1]\[path2].
+ * Attempts to trim a maven repo to a common base path. This is typically
+ * [drive]\[repo_location]\repository\[path1]\[path2].
*
* @param path the path to trim
* @return a string representing the base path.
@@ -211,11 +218,13 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
/**
- * Returns true if the file names (and version if it exists) of the two dependencies are sufficiently similar.
+ * Returns true if the file names (and version if it exists) of the two
+ * dependencies are sufficiently similar.
*
* @param dependency1 a dependency2 to compare
* @param dependency2 a dependency2 to compare
- * @return true if the identifiers in the two supplied dependencies are equal
+ * @return true if the identifiers in the two supplied dependencies are
+ * equal
*/
private boolean fileNameMatch(Dependency dependency1, Dependency dependency2) {
if (dependency1 == null || dependency1.getFileName() == null
@@ -243,11 +252,13 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
/**
- * Returns true if the CPE identifiers in the two supplied dependencies are equal.
+ * Returns true if the CPE identifiers in the two supplied dependencies are
+ * equal.
*
* @param dependency1 a dependency2 to compare
* @param dependency2 a dependency2 to compare
- * @return true if the identifiers in the two supplied dependencies are equal
+ * @return true if the identifiers in the two supplied dependencies are
+ * equal
*/
private boolean cpeIdentifiersMatch(Dependency dependency1, Dependency dependency2) {
if (dependency1 == null || dependency1.getIdentifiers() == null
@@ -317,37 +328,53 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
return false;
}
-
+
/**
- * Bundling Ruby gems that are identified from different .gemspec files but denote the same package path.
- * This happens when Ruby bundler installs an app's dependencies by running "bundle install".
+ * Bundling Ruby gems that are identified from different .gemspec files but
+ * denote the same package path. This happens when Ruby bundler installs an
+ * application's dependencies by running "bundle install".
+ *
+ * @param dependency1 dependency to compare
+ * @param dependency2 dependency to compare
+ * @return true if the the dependencies being analyzed appear to be the
+ * same; otherwise false
*/
private boolean isSameRubyGem(Dependency dependency1, Dependency dependency2) {
- if (dependency1 == null || dependency2 == null ||
- !dependency1.getFileName().endsWith(".gemspec") ||
- !dependency2.getFileName().endsWith(".gemspec") ||
- dependency1.getPackagePath() == null ||
- dependency2.getPackagePath() == null) {
+ if (dependency1 == null || dependency2 == null
+ || !dependency1.getFileName().endsWith(".gemspec")
+ || !dependency2.getFileName().endsWith(".gemspec")
+ || dependency1.getPackagePath() == null
+ || dependency2.getPackagePath() == null) {
return false;
}
- if (dependency1.getPackagePath().equalsIgnoreCase(dependency2.getPackagePath()))
- return true;
+ if (dependency1.getPackagePath().equalsIgnoreCase(dependency2.getPackagePath())) {
+ return true;
+ }
- return false;
+ return false;
}
-
+
/**
- * Ruby gems installed by "bundle install" can have zero or more *.gemspec files, all of which have the same packagePath and should be grouped.
- * If one of these gemspec is from /specifications/*.gemspec, because it is a stub with fully resolved gem meta-data
- * created by Ruby bundler, this dependency should be the main one. Otherwise, use dependency2 as main.
- *
- * This method returns null if any dependency is not from *.gemspec, or the two do not have the same packagePath.
- * In this case, they should not be grouped.
+ * Ruby gems installed by "bundle install" can have zero or more *.gemspec
+ * files, all of which have the same packagePath and should be grouped. If
+ * one of these gemspec is from /specifications/*.gemspec, because
+ * it is a stub with fully resolved gem meta-data created by Ruby bundler,
+ * this dependency should be the main one. Otherwise, use dependency2 as
+ * main.
+ *
+ * This method returns null if any dependency is not from *.gemspec, or the
+ * two do not have the same packagePath. In this case, they should not be
+ * grouped.
+ *
+ * @param dependency1 dependency to compare
+ * @param dependency2 dependency to compare
+ * @return the main dependency; or null if a gemspec is not included in the
+ * analysis
*/
private Dependency getMainGemspecDependency(Dependency dependency1, Dependency dependency2) {
- if (isSameRubyGem(dependency1, dependency2)) {
- final File lFile = dependency1.getActualFile();
- File left = lFile.getParentFile();
+ if (isSameRubyGem(dependency1, dependency2)) {
+ final File lFile = dependency1.getActualFile();
+ final File left = lFile.getParentFile();
if (left != null && left.getName().equalsIgnoreCase("specifications")) {
return dependency1;
}
@@ -384,12 +411,13 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
/**
- * This is likely a very broken attempt at determining if the 'left' dependency is the 'core' library in comparison to the
- * 'right' library.
+ * This is likely a very broken attempt at determining if the 'left'
+ * dependency is the 'core' library in comparison to the 'right' library.
*
* @param left the dependency to test
* @param right the dependency to test against
- * @return a boolean indicating whether or not the left dependency should be considered the "core" version.
+ * @return a boolean indicating whether or not the left dependency should be
+ * considered the "core" version.
*/
boolean isCore(Dependency left, Dependency right) {
final String leftName = left.getFileName().toLowerCase();
@@ -425,11 +453,13 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
/**
- * Compares the SHA1 hashes of two dependencies to determine if they are equal.
+ * Compares the SHA1 hashes of two dependencies to determine if they are
+ * equal.
*
* @param dependency1 a dependency object to compare
* @param dependency2 a dependency object to compare
- * @return true if the sha1 hashes of the two dependencies match; otherwise false
+ * @return true if the sha1 hashes of the two dependencies match; otherwise
+ * false
*/
private boolean hashesMatch(Dependency dependency1, Dependency dependency2) {
if (dependency1 == null || dependency2 == null || dependency1.getSha1sum() == null || dependency2.getSha1sum() == null) {
@@ -439,12 +469,13 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
/**
- * Determines if the jar is shaded and the created pom.xml identified the same CPE as the jar - if so, the pom.xml dependency
- * should be removed.
+ * Determines if the jar is shaded and the created pom.xml identified the
+ * same CPE as the jar - if so, the pom.xml dependency should be removed.
*
* @param dependency a dependency to check
* @param nextDependency another dependency to check
- * @return true if on of the dependencies is a pom.xml and the identifiers between the two collections match; otherwise false
+ * @return true if on of the dependencies is a pom.xml and the identifiers
+ * between the two collections match; otherwise false
*/
private boolean isShadedJar(Dependency dependency, Dependency nextDependency) {
final String mainName = dependency.getFileName().toLowerCase();
@@ -458,12 +489,13 @@ public class DependencyBundlingAnalyzer extends AbstractAnalyzer implements Anal
}
/**
- * Determines which path is shortest; if path lengths are equal then we use compareTo of the string method to determine if the
- * first path is smaller.
+ * Determines which path is shortest; if path lengths are equal then we use
+ * compareTo of the string method to determine if the first path is smaller.
*
* @param left the first path to compare
* @param right the second path to compare
- * @return true if the leftPath is the shortest; otherwise false
+ * @return true if the leftPath is the shortest; otherwise
+ * false
*/
protected boolean firstPathIsShortest(String left, String right) {
final String leftPath = left.replace('\\', '/');
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/Experimental.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/Experimental.java
new file mode 100644
index 000000000..8f5a3842a
--- /dev/null
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/Experimental.java
@@ -0,0 +1,34 @@
+/*
+ * This file is part of dependency-check-core.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (c) 2016 Jeremy Long. All Rights Reserved.
+ */
+package org.owasp.dependencycheck.analyzer;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to flag an analyzer as experimental.
+ *
+ * @author jeremy long
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Experimental {
+
+}
diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.java
index 570e63ff0..fcaaeb102 100644
--- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.java
+++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/FileNameAnalyzer.java
@@ -67,11 +67,13 @@ public class FileNameAnalyzer extends AbstractAnalyzer implements Analyzer {
}
//
- // Python init files
- private static final NameFileFilter IGNORED_FILES = new NameFileFilter(new String[] {
+ /**
+ * Python init files
+ */
+ private static final NameFileFilter IGNORED_FILES = new NameFileFilter(new String[]{
"__init__.py",
"__init__.pyc",
- "__init__.pyo"
+ "__init__.pyo",
});
/**
@@ -79,7 +81,8 @@ public class FileNameAnalyzer extends AbstractAnalyzer implements Analyzer {
*
* @param dependency the dependency to analyze.
* @param engine the engine that is scanning the dependencies
- * @throws AnalysisException is thrown if there is an error reading the JAR file.
+ * @throws AnalysisException is thrown if there is an error reading the JAR
+ * file.
*/
@Override
public void analyze(Dependency dependency, Engine engine) throws AnalysisException {
@@ -105,13 +108,6 @@ public class FileNameAnalyzer extends AbstractAnalyzer implements Analyzer {
fileName, Confidence.MEDIUM);
}
- //add as vendor and product evidence
-// if (fileName.contains("-")) {
-// dependency.getProductEvidence().addEvidence("file", "name",
-// fileName, Confidence.HIGHEST);
-// dependency.getVendorEvidence().addEvidence("file", "name",
-// fileName, Confidence.HIGHEST);
-// } else
if (!IGNORED_FILES.accept(f)) {
dependency.getProductEvidence().addEvidence("file", "name",
fileName, Confidence.HIGH);
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 51bf51724..da6fb6078 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
@@ -29,7 +29,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -60,7 +59,8 @@ 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.
+ * Used to load a JAR file and collect information that can be used to determine
+ * the associated CPE.
*
* @author Jeremy Long
*/
@@ -72,7 +72,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
*/
private static final Logger LOGGER = LoggerFactory.getLogger(JarAnalyzer.class);
/**
- * The count of directories created during analysis. This is used for creating temporary directories.
+ * The count of directories created during analysis. This is used for
+ * creating temporary directories.
*/
private static int dirCount = 0;
/**
@@ -80,7 +81,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
*/
private static final String NEWLINE = System.getProperty("line.separator");
/**
- * A list of values in the manifest to ignore as they only result in false positives.
+ * A list of values in the manifest to ignore as they only result in false
+ * positives.
*/
private static final Set IGNORE_VALUES = newHashSet(
"Sun Java System Application Server");
@@ -123,7 +125,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
"ipojo-extension",
"eclipse-sourcereferences");
/**
- * Deprecated Jar manifest attribute, that is, nonetheless, useful for analysis.
+ * Deprecated Jar manifest attribute, that is, nonetheless, useful for
+ * analysis.
*/
@SuppressWarnings("deprecation")
private static final String IMPLEMENTATION_VENDOR_ID = Attributes.Name.IMPLEMENTATION_VENDOR_ID
@@ -203,7 +206,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
//
/**
- * Returns the key used in the properties file to reference the analyzer's enabled property.
+ * Returns the key used in the properties file to reference the analyzer's
+ * enabled property.
*
* @return the analyzer's enabled property setting key
*/
@@ -213,12 +217,13 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
}
/**
- * Loads a specified JAR file and collects information from the manifest and checksums to identify the correct CPE
- * information.
+ * Loads a specified JAR file and collects information from the manifest and
+ * checksums to identify the correct CPE information.
*
* @param dependency the dependency to analyze.
* @param engine the engine that is scanning the dependencies
- * @throws AnalysisException is thrown if there is an error reading the JAR file.
+ * @throws AnalysisException is thrown if there is an error reading the JAR
+ * file.
*/
@Override
public void analyzeFileType(Dependency dependency, Engine engine) throws AnalysisException {
@@ -242,13 +247,15 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
}
/**
- * Attempts to find a pom.xml within the JAR file. If found it extracts information and adds it to the evidence. This will
- * attempt to interpolate the strings contained within the pom.properties if one exists.
+ * Attempts to find a pom.xml within the JAR file. If found it extracts
+ * information and adds it to the evidence. This will attempt to interpolate
+ * the strings contained within the pom.properties if one exists.
*
* @param dependency the dependency being analyzed
* @param classes a collection of class name information
* @param engine the analysis engine, used to add additional dependencies
- * @throws AnalysisException is thrown if there is an exception parsing the pom
+ * @throws AnalysisException is thrown if there is an exception parsing the
+ * pom
* @return whether or not evidence was added to the dependency
*/
protected boolean analyzePOM(Dependency dependency, List classes, Engine engine) throws AnalysisException {
@@ -329,12 +336,14 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
}
/**
- * Given a path to a pom.xml within a JarFile, this method attempts to load a sibling pom.properties if one exists.
+ * Given a path to a pom.xml within a JarFile, this method attempts to load
+ * a sibling pom.properties if one exists.
*
* @param path the path to the pom.xml within the JarFile
* @param jar the JarFile to load the pom.properties from
* @return a Properties object or null if no pom.properties was found
- * @throws IOException thrown if there is an exception reading the pom.properties
+ * @throws IOException thrown if there is an exception reading the
+ * pom.properties
*/
private Properties retrievePomProperties(String path, final JarFile jar) throws IOException {
Properties pomProperties = null;
@@ -361,7 +370,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
}
/**
- * Searches a JarFile for pom.xml entries and returns a listing of these entries.
+ * Searches a JarFile for pom.xml entries and returns a listing of these
+ * entries.
*
* @param jar the JarFile to search
* @return a list of pom.xml entries
@@ -388,8 +398,8 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @param jar the jar file to extract the pom from
* @param dependency the dependency being analyzed
* @return returns the POM object
- * @throws AnalysisException is thrown if there is an exception extracting or parsing the POM
- * {@link org.owasp.dependencycheck.xml.pom.Model} object
+ * @throws AnalysisException is thrown if there is an exception extracting
+ * or parsing the POM {@link org.owasp.dependencycheck.xml.pom.Model} object
*/
private Model extractPom(String path, JarFile jar, Dependency dependency) throws AnalysisException {
InputStream input = null;
@@ -447,9 +457,10 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
*
* @param dependency the dependency to set data on
* @param pom the information from the pom
- * @param classes a collection of ClassNameInformation - containing data about the fully qualified class names within the JAR
- * file being analyzed
- * @return true if there was evidence within the pom that we could use; otherwise false
+ * @param classes a collection of ClassNameInformation - containing data
+ * about the fully qualified class names within the JAR file being analyzed
+ * @return true if there was evidence within the pom that we could use;
+ * otherwise false
*/
public static boolean setPomEvidence(Dependency dependency, Model pom, List classes) {
boolean foundSomething = false;
@@ -565,9 +576,9 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
addMatchingValues(classes, trimmedDescription, dependency.getVendorEvidence());
addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence());
}
-
- String projectURL = pom.getProjectURL();
- if(projectURL != null && !projectURL.trim().isEmpty()) {
+
+ final String projectURL = pom.getProjectURL();
+ if (projectURL != null && !projectURL.trim().isEmpty()) {
dependency.getVendorEvidence().addEvidence("pom", "url", projectURL, Confidence.HIGHEST);
}
@@ -576,12 +587,15 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
}
/**
- * Analyzes the path information of the classes contained within the JarAnalyzer to try and determine possible vendor or
- * product names. If any are found they are stored in the packageVendor and packageProduct hashSets.
+ * Analyzes the path information of the classes contained within the
+ * JarAnalyzer to try and determine possible vendor or product names. If any
+ * are found they are stored in the packageVendor and packageProduct
+ * hashSets.
*
* @param classNames a list of class names
* @param dependency a dependency to analyze
- * @param addPackagesAsEvidence a flag indicating whether or not package names should be added as evidence.
+ * @param addPackagesAsEvidence a flag indicating whether or not package
+ * names should be added as evidence.
*/
protected void analyzePackageNames(List classNames,
Dependency dependency, boolean addPackagesAsEvidence) {
@@ -616,11 +630,13 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
/**
*
- * Reads the manifest from the JAR file and collects the entries. Some vendorKey entries are:
+ * Reads the manifest from the JAR file and collects the entries. Some
+ * vendorKey entries are:
*
Implementation Title
*
Implementation Version
Implementation Vendor
- *
Implementation VendorId
Bundle Name
Bundle Version
Bundle Vendor
Bundle
- * Description
Main Class
+ *
Implementation VendorId
Bundle Name
Bundle
+ * Version
Bundle Vendor
Bundle Description
Main
+ * Class
* However, all but a handful of specific entries are read in.
*
* @param dependency A reference to the dependency
@@ -628,14 +644,15 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
* @return whether evidence was identified parsing the manifest
* @throws IOException if there is an issue reading the JAR file
*/
- protected boolean parseManifest(Dependency dependency, List classInformation) throws IOException {
+ protected boolean parseManifest(Dependency dependency,
+ List classInformation)
+ throws IOException {
boolean foundSomething = false;
JarFile jar = null;
try {
jar = new JarFile(dependency.getActualFilePath());
final Manifest manifest = jar.getManifest();
if (manifest == null) {
- //don't log this for javadoc or sources jar files
if (!dependency.getFileName().toLowerCase().endsWith("-sources.jar")
&& !dependency.getFileName().toLowerCase().endsWith("-javadoc.jar")
&& !dependency.getFileName().toLowerCase().endsWith("-src.jar")
@@ -652,7 +669,6 @@ public class JarAnalyzer extends AbstractFileTypeAnalyzer {
String source = "Manifest";
String specificationVersion = null;
boolean hasImplementationVersion = false;
-
Attributes atts = manifest.getMainAttributes();
for (Entry