mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-24 10:01:35 +01:00
Fixed javadoc. Some reformatting of FileFilterBuilder.
Former-commit-id: 66a81beb1f1361b16743a762f6941dfef626ca4a
This commit is contained in:
@@ -24,41 +24,53 @@ import org.apache.commons.io.filefilter.NameFileFilter;
|
|||||||
import org.apache.commons.io.filefilter.OrFileFilter;
|
import org.apache.commons.io.filefilter.OrFileFilter;
|
||||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for building useful {@link FileFilter} instances for
|
* <p>Utility class for building useful {@link FileFilter} instances for
|
||||||
* {@link org.owasp.dependencycheck.analyzer.AbstractFileTypeAnalyzer} implementations. The built filter uses
|
* {@link org.owasp.dependencycheck.analyzer.AbstractFileTypeAnalyzer} implementations. The built filter uses
|
||||||
* {@link OrFileFilter} to logically OR the given filter conditions.
|
* {@link OrFileFilter} to logically OR the given filter conditions. Example usage:</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* FileFilter filter = FileFilterBuilder.newInstance().addExtensions("jar", "war").build();
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author Dale Visser <dvisser@ida.org>
|
* @author Dale Visser <dvisser@ida.org>
|
||||||
|
* @see <a href="https://en.wikipedia.org/wiki/Builder_pattern">Builder pattern</a>
|
||||||
*/
|
*/
|
||||||
public class FileFilterBuilder {
|
public class FileFilterBuilder {
|
||||||
|
|
||||||
|
private Set<String> filenames = new HashSet<String>();
|
||||||
|
private Set<String> extensions = new HashSet<String>();
|
||||||
|
private List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new instance and return it. This method is for convenience in using the builder pattern within a single
|
||||||
|
* statement.
|
||||||
|
*
|
||||||
|
* @return a new builder instance
|
||||||
|
*/
|
||||||
public static FileFilterBuilder newInstance() {
|
public static FileFilterBuilder newInstance() {
|
||||||
return new FileFilterBuilder();
|
return new FileFilterBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> filenames = new HashSet<String>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add to the set of filenames to accept for analysis. Case-sensitivity is assumed.
|
* Add to the set of filenames to accept for analysis. Case-sensitivity is assumed.
|
||||||
*
|
*
|
||||||
* @param names one or more filenames to accept for analysis
|
* @param names one or more filenames to accept for analysis
|
||||||
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public FileFilterBuilder addFilenames(String... names) {
|
public FileFilterBuilder addFilenames(String... names) {
|
||||||
filenames.addAll(Arrays.asList(names));
|
filenames.addAll(Arrays.asList(names));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> extensions = new HashSet<String>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add to the set of file extensions to accept for analysis. Case-insensitivity is assumed.
|
* Add to the set of file extensions to accept for analysis. Case-insensitivity is assumed.
|
||||||
*
|
*
|
||||||
* @param extensions one or more file extensions to accept for analysis
|
* @param extensions one or more file extensions to accept for analysis
|
||||||
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public FileFilterBuilder addExtensions(String... extensions) {
|
public FileFilterBuilder addExtensions(String... extensions) {
|
||||||
return this.addExtensions(Arrays.asList(extensions));
|
return this.addExtensions(Arrays.asList(extensions));
|
||||||
@@ -68,6 +80,7 @@ public class FileFilterBuilder {
|
|||||||
* Add to the set of file extensions to accept for analysis. Case-insensitivity is assumed.
|
* Add to the set of file extensions to accept for analysis. Case-insensitivity is assumed.
|
||||||
*
|
*
|
||||||
* @param extensions one or more file extensions to accept for analysis
|
* @param extensions one or more file extensions to accept for analysis
|
||||||
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public FileFilterBuilder addExtensions(Iterable<String> extensions) {
|
public FileFilterBuilder addExtensions(Iterable<String> extensions) {
|
||||||
for (String extension : extensions) {
|
for (String extension : extensions) {
|
||||||
@@ -77,12 +90,11 @@ public class FileFilterBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add to a list of {@link IOFileFilter} instances to consult for whether to accept a file for analysis.
|
* Add to a list of {@link IOFileFilter} instances to consult for whether to accept a file for analysis.
|
||||||
*
|
*
|
||||||
* @param filters one or more file filters to consult for whether to accept for analysis
|
* @param filters one or more file filters to consult for whether to accept for analysis
|
||||||
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public FileFilterBuilder addFileFilters(IOFileFilter... filters) {
|
public FileFilterBuilder addFileFilters(IOFileFilter... filters) {
|
||||||
fileFilters.addAll(Arrays.asList(filters));
|
fileFilters.addAll(Arrays.asList(filters));
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ public final class PomUtils {
|
|||||||
*
|
*
|
||||||
* @param file the pom.xml file
|
* @param file the pom.xml file
|
||||||
* @return returns a
|
* @return returns a
|
||||||
* @throws AnalysisException is thrown if there is an exception extracting or parsing the POM
|
* @throws AnalysisException is thrown if there is an exception extracting or parsing the POM {@link Model} object
|
||||||
* {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object
|
|
||||||
*/
|
*/
|
||||||
public static Model readPom(File file) throws AnalysisException {
|
public static Model readPom(File file) throws AnalysisException {
|
||||||
Model model = null;
|
Model model = null;
|
||||||
@@ -78,8 +77,7 @@ public final class PomUtils {
|
|||||||
* @param path the path to the pom.xml file within the jar file
|
* @param path the path to the pom.xml file within the jar file
|
||||||
* @param jar the jar file to extract the pom from
|
* @param jar the jar file to extract the pom from
|
||||||
* @return returns a
|
* @return returns a
|
||||||
* @throws AnalysisException is thrown if there is an exception extracting or parsing the POM
|
* @throws AnalysisException is thrown if there is an exception extracting or parsing the POM {@link Model} object
|
||||||
* {@link org.owasp.dependencycheck.jaxb.pom.generated.Model} object
|
|
||||||
*/
|
*/
|
||||||
public static Model readPom(String path, JarFile jar) throws AnalysisException {
|
public static Model readPom(String path, JarFile jar) throws AnalysisException {
|
||||||
final ZipEntry entry = jar.getEntry(path);
|
final ZipEntry entry = jar.getEntry(path);
|
||||||
|
|||||||
Reference in New Issue
Block a user