Class ArchiveAnalyzer
- java.lang.Object
-
- org.owasp.dependencycheck.analyzer.AbstractAnalyzer
-
- org.owasp.dependencycheck.analyzer.AbstractFileTypeAnalyzer
-
- org.owasp.dependencycheck.analyzer.ArchiveAnalyzer
-
- All Implemented Interfaces:
java.io.FileFilter,Analyzer,FileTypeAnalyzer
@ThreadSafe public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer
An analyzer that extracts files from archives and ensures any supported files contained within the archive are added to the dependency list.
- Author:
- Jeremy Long
-
-
Constructor Summary
Constructors Constructor Description ArchiveAnalyzer()Make java compiler happy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(java.io.File pathname)Determines if the file can be analyzed by the analyzer.voidanalyzeDependency(Dependency dependency, Engine engine)Analyzes a given dependency.voidcloseAnalyzer()The close method deletes any temporary files and directories created during analysis.AnalysisPhasegetAnalysisPhase()Returns the phase that the analyzer is intended to run in.protected java.lang.StringgetAnalyzerEnabledSettingKey()Returns the key used in the properties file to reference the analyzer's enabled property.protected java.io.FileFiltergetFileFilter()Returns theFileFilterused to determine which files are to be analyzed.java.lang.StringgetName()Returns the name of the analyzer.voidinitialize(Settings settings)Initializes the analyzer with the configured settings.voidprepareFileTypeAnalyzer(Engine engine)The prepare method does nothing for this Analyzer.-
Methods inherited from class org.owasp.dependencycheck.analyzer.AbstractFileTypeAnalyzer
getFilesMatched, newHashSet, prepareAnalyzer, setFilesMatched
-
Methods inherited from class org.owasp.dependencycheck.analyzer.AbstractAnalyzer
analyze, close, getSettings, isEnabled, prepare, setEnabled, supportsParallelProcessing
-
-
-
-
Method Detail
-
initialize
public void initialize(Settings settings)
Initializes the analyzer with the configured settings.- Specified by:
initializein interfaceAnalyzer- Overrides:
initializein classAbstractAnalyzer- Parameters:
settings- the configured settings to use
-
getFileFilter
protected java.io.FileFilter getFileFilter()
Description copied from class:AbstractFileTypeAnalyzerReturns the
FileFilterused to determine which files are to be analyzed. An example would be an analyzer that inspected Java jar files. Implementors may useFileFilterBuilder.If the analyzer returns null it will not cause additional files to be analyzed, but will be executed against every file loaded.
- Specified by:
getFileFilterin classAbstractFileTypeAnalyzer- Returns:
- the file filter used to determine which files are to be analyzed
-
getName
public java.lang.String getName()
Returns the name of the analyzer.- Returns:
- the name of the analyzer.
-
getAnalysisPhase
public AnalysisPhase getAnalysisPhase()
Returns the phase that the analyzer is intended to run in.- Returns:
- the phase that the analyzer is intended to run in.
-
getAnalyzerEnabledSettingKey
protected java.lang.String getAnalyzerEnabledSettingKey()
Returns the key used in the properties file to reference the analyzer's enabled property.- Specified by:
getAnalyzerEnabledSettingKeyin classAbstractAnalyzer- Returns:
- the analyzer's enabled property setting key
-
prepareFileTypeAnalyzer
public void prepareFileTypeAnalyzer(Engine engine) throws InitializationException
The prepare method does nothing for this Analyzer.- Specified by:
prepareFileTypeAnalyzerin classAbstractFileTypeAnalyzer- Parameters:
engine- a reference to the dependency-check engine- Throws:
InitializationException- is thrown if there is an exception deleting or creating temporary files
-
closeAnalyzer
public void closeAnalyzer() throws java.lang.ExceptionThe close method deletes any temporary files and directories created during analysis.- Overrides:
closeAnalyzerin classAbstractAnalyzer- Throws:
java.lang.Exception- thrown if there is an exception deleting temporary files
-
accept
public boolean accept(java.io.File pathname)
Determines if the file can be analyzed by the analyzer. If the npm analyzer are enabled the archive analyzer will skip the node_modules and bower_modules directories.- Specified by:
acceptin interfacejava.io.FileFilter- Overrides:
acceptin classAbstractFileTypeAnalyzer- Parameters:
pathname- the path to the file- Returns:
- true if the file can be analyzed by the given analyzer; otherwise false
-
analyzeDependency
public void analyzeDependency(Dependency dependency, Engine engine) throws AnalysisException
Analyzes a given dependency. If the dependency is an archive, such as a WAR or EAR, the contents are extracted, scanned, and added to the list of dependencies within the engine.- Specified by:
analyzeDependencyin classAbstractAnalyzer- Parameters:
dependency- the dependency to analyzeengine- the engine scanning- Throws:
AnalysisException- thrown if there is an analysis exception
-
-