Class CentralAnalyzer
java.lang.Object
org.owasp.dependencycheck.analyzer.AbstractAnalyzer
org.owasp.dependencycheck.analyzer.AbstractFileTypeAnalyzer
org.owasp.dependencycheck.analyzer.CentralAnalyzer
- All Implemented Interfaces:
FileFilter, Analyzer, FileTypeAnalyzer
Analyzer which will attempt to locate a dependency, and the GAV information,
by querying Central for the dependency's SHA-1 digest.
- Author:
- colezlaw
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidanalyzeDependency(Dependency dependency, Engine engine) Performs the analysis.protected List<MavenArtifact> fetchMavenArtifacts(Dependency dependency) Downloads the corresponding list of MavenArtifacts of the given dependency from MavenCentral.Returns the analysis phase under which the analyzer runs.protected StringReturns the key used in the properties file to to reference the analyzer's enabled property.protected FileFilterReturns theFileFilterused to determine which files are to be analyzed.getName()Returns the analyzer's name.voidinitialize(Settings settings) Initializes the analyzer with the configured settings.voidprepareFileTypeAnalyzer(Engine engine) Initializes the analyzer once before any analysis is performed.protected voidsetCentralSearch(CentralSearch searcher) Method used by unit tests to setup the analyzer.booleanWhether the analyzer is configured to support parallel processing.Methods inherited from class AbstractFileTypeAnalyzer
accept, getFilesMatched, newHashSet, prepareAnalyzer, setFilesMatchedMethods inherited from class AbstractAnalyzer
analyze, close, closeAnalyzer, getSettings, isEnabled, prepare, setEnabled
-
Constructor Details
-
CentralAnalyzer
public CentralAnalyzer()
-
-
Method Details
-
initialize
Initializes the analyzer with the configured settings.- Specified by:
initializein interfaceAnalyzer- Overrides:
initializein classAbstractAnalyzer- Parameters:
settings- the configured settings to use
-
supportsParallelProcessing
public boolean supportsParallelProcessing()Whether the analyzer is configured to support parallel processing.- Specified by:
supportsParallelProcessingin interfaceAnalyzer- Overrides:
supportsParallelProcessingin classAbstractAnalyzer- Returns:
- true if configured to support parallel processing; otherwise false
-
prepareFileTypeAnalyzer
Initializes the analyzer once before any analysis is performed.- Specified by:
prepareFileTypeAnalyzerin classAbstractFileTypeAnalyzer- Parameters:
engine- a reference to the dependency-check engine- Throws:
InitializationException- if there's an error during initialization
-
getName
-
getAnalyzerEnabledSettingKey
Returns the key used in the properties file to to reference the analyzer's enabled property.- Specified by:
getAnalyzerEnabledSettingKeyin classAbstractAnalyzer- Returns:
- the analyzer's enabled property setting key.
-
getAnalysisPhase
Returns the analysis phase under which the analyzer runs.- Returns:
- the phase under which the analyzer runs
-
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
-
analyzeDependency
Performs the analysis.- Specified by:
analyzeDependencyin classAbstractAnalyzer- Parameters:
dependency- the dependency to analyzeengine- the engine- Throws:
AnalysisException- when there's an exception during analysis
-
fetchMavenArtifacts
protected List<MavenArtifact> fetchMavenArtifacts(Dependency dependency) throws IOException, TooManyRequestsException Downloads the corresponding list of MavenArtifacts of the given dependency from MavenCentral.As the connection to MavenCentral is known to be unreliable, we implement a simple retry logic in order to compensate for 99% of the issues.
- Parameters:
dependency- the dependency to analyze- Returns:
- the downloaded list of MavenArtifacts
- Throws:
FileNotFoundException- if the specified artifact is not foundIOException- if connecting to MavenCentral finally failedTooManyRequestsException- if Central has received too many requests.
-
setCentralSearch
Method used by unit tests to setup the analyzer.- Parameters:
searcher- the Central Search object to use.
-