Add support for extra extensions provided externally

Former-commit-id: c827feb563cde449090dade2b17bfa6709df37be
This commit is contained in:
Henri Gomez
2014-02-11 14:05:26 +01:00
parent e4fd446946
commit c11cb38269
9 changed files with 99 additions and 9 deletions

View File

@@ -20,6 +20,8 @@ package org.owasp.dependencycheck.taskdefs;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -32,6 +34,8 @@ import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.ant.types.resources.Resources;
import org.owasp.dependencycheck.Engine;
import org.owasp.dependencycheck.analyzer.Analyzer;
import org.owasp.dependencycheck.analyzer.ArchiveAnalyzer;
import org.owasp.dependencycheck.data.nvdcve.CveDB;
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
import org.owasp.dependencycheck.data.nvdcve.DatabaseProperties;
@@ -616,6 +620,30 @@ public class DependencyCheckTask extends Task {
this.databasePassword = databasePassword;
}
/**
* File extensions to add to analysis next to jar, zip, ....
*/
private String extraExtensions;
/**
* Get the value of extraExtensions.
*
* @return the value of extraExtensions
*/
public String getExtraExtensions() {
return extraExtensions;
}
/**
* Set the value of extraExtensions.
*
* @param extraExtensions new value of extraExtensions
*/
public void setExtraExtensions(String extraExtensions) {
this.extraExtensions = extraExtensions;
}
@Override
public void execute() throws BuildException {
final InputStream in = DependencyCheckTask.class.getClassLoader().getResourceAsStream(LOG_PROPERTIES_FILE);
@@ -626,6 +654,12 @@ public class DependencyCheckTask extends Task {
populateSettings();
final Engine engine = new Engine();
if (extraExtensions != null && ! extraExtensions.isEmpty())
for (Analyzer analyzer : engine.getAnalyzers())
if (analyzer instanceof ArchiveAnalyzer)
((ArchiveAnalyzer)analyzer).addSupportedExtensions(new HashSet<String>(Arrays.asList(extraExtensions.split("\\s*,\\s*"))));
for (Resource resource : path) {
final FileProvider provider = resource.as(FileProvider.class);
if (provider != null) {

View File

@@ -42,5 +42,6 @@ databaseDriverPath | The path to the database driver JAR file; only used if t
connectionString | The connection string used to connect to the database. | Optional
databaseUser | The username used when connecting to the database. | Optional
databasePassword | The password used when connecting to the database. | Optional
extraExtensions | List of extra extensions to be scanned, comma separated. | Optional