Class DependencyCheckScanAgent
java.lang.Object
org.owasp.dependencycheck.agent.DependencyCheckScanAgent
This class provides a way to easily conduct a scan solely based on existing
evidence metadata rather than collecting evidence from the files themselves.
This class is based on the Ant task and Maven plugin with the exception that
it takes a list of dependencies that can be programmatically added from data
in a spreadsheet, database or some other datasource and conduct a scan based
on this pre-defined evidence.
Example:
List<Dependency> dependencies = new ArrayList<Dependency>();
Dependency dependency = new Dependency(new File(FileUtils.getBitBucket()));
dependency.addEvidence(EvidenceType.PRODUCT, "my-datasource", "name", "Jetty", Confidence.HIGH);
dependency.addEvidence(EvidenceType.VERSION, "my-datasource", "version", "5.1.10", Confidence.HIGH);
dependency.addEvidence(EvidenceType.VENDOR, "my-datasource", "vendor", "mortbay", Confidence.HIGH);
dependencies.add(dependency);
DependencyCheckScanAgent scan = new DependencyCheckScanAgent();
scan.setDependencies(dependencies);
scan.setReportFormat(ReportGenerator.Format.ALL);
scan.setReportOutputDirectory(System.getProperty("user.home"));
scan.execute();
- Author:
- Steve Springett
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute()Executes the dependency-check and generates the report.Get the value of applicationName.Get the value of centralUrl.Get the value of connectionString.Get the value of connectionTimeout.Returns the starting string that identifies CPEs that are qualified to be imported.Get the value of databaseDriverName.Get the value of databaseDriverPath.Get the value of databasePassword.Get the value of databaseUser.Get the value of dataDirectory.Returns a list of pre-determined dependencies.Get the value of failBuildOnCVSS.Get the value of logFile.Get the value of nexusUrl.Get the value of nvdApiKey.Get the value of pathToCore.Get the value of propertiesFilePath.Get the value of proxyPassword.Get the value of proxyPort.Get the value of proxyServer.Deprecated.Get the value of proxyUsername.Get the value of readTimeout.Get the value of reportFormat.Get the value of reportOutputDirectory.Get the value of suppressionFile.Get the value of zipExtensions.booleanGet the value of autoUpdate.booleanGet the value of centralAnalyzerEnabled.booleanGet the value of failOnUnusedSuppressionRule.booleanGet the value of generateReport.booleanGet the value of nexusAnalyzerEnabled.booleanGet the value of nexusUsesProxy.booleanGet the value of showSummary.booleanGet the value of updateOnly.voidsetApplicationName(String applicationName) Set the value of applicationName.voidsetAutoUpdate(boolean autoUpdate) Set the value of autoUpdate.voidsetCentralAnalyzerEnabled(boolean centralAnalyzerEnabled) Set the value of centralAnalyzerEnabled.voidsetCentralUrl(String centralUrl) Set the value of centralUrl.voidsetConnectionString(String connectionString) Set the value of connectionString.voidsetConnectionTimeout(String connectionTimeout) Set the value of connectionTimeout.voidsetCpeStartsWithFilter(String cpeStartsWithFilter) Sets starting string that identifies CPEs that are qualified to be imported.voidsetDatabaseDriverName(String databaseDriverName) Set the value of databaseDriverName.voidsetDatabaseDriverPath(String databaseDriverPath) Set the value of databaseDriverPath.voidsetDatabasePassword(String databasePassword) Set the value of databasePassword.voidsetDatabaseUser(String databaseUser) Set the value of databaseUser.voidsetDataDirectory(String dataDirectory) Set the value of dataDirectory.voidsetDependencies(List<Dependency> dependencies) Sets the list of dependencies to scan.voidsetFailBuildOnCVSS(Double failBuildOnCVSS) Set the value of failBuildOnCVSS.voidsetFailOnUnusedSuppressionRule(boolean failOnUnusedSuppressionRule) Set the value of failOnUnusedSuppressionRule.voidsetGenerateReport(boolean generateReport) Set the value of generateReport.voidsetLogFile(String logFile) Set the value of logFile.voidsetNexusAnalyzerEnabled(boolean nexusAnalyzerEnabled) Set the value of nexusAnalyzerEnabled.voidsetNexusUrl(String nexusUrl) Set the value of nexusUrl.voidsetNexusUsesProxy(boolean nexusUsesProxy) Set the value of nexusUsesProxy.voidsetNvdApiKey(String nvdApiKey) Set the value of nvdApiKey.voidsetPathToDotnetCore(String pathToCore) Set the value of pathToCore.voidsetPropertiesFilePath(String propertiesFilePath) Set the value of propertiesFilePath.voidsetProxyPassword(String proxyPassword) Set the value of proxyPassword.voidsetProxyPort(String proxyPort) Set the value of proxyPort.voidsetProxyServer(String proxyServer) Set the value of proxyServer.voidsetProxyUrl(String proxyUrl) Deprecated.usesetProxyServer(java.lang.String)insteadvoidsetProxyUsername(String proxyUsername) Set the value of proxyUsername.voidsetReadTimeout(String readTimeout) Set the value of readTimeout.voidsetReportFormat(ReportGenerator.Format reportFormat) Set the value of reportFormat.voidsetReportOutputDirectory(String reportOutputDirectory) Set the value of reportOutputDirectory.voidsetShowSummary(boolean showSummary) Set the value of showSummary.voidsetSuppressionFile(String suppressionFile) Set the value of suppressionFile.voidsetUpdateOnly(boolean updateOnly) Set the value of updateOnly.voidsetZipExtensions(String zipExtensions) Set the value of zipExtensions.static voidshowSummary(String projectName, Dependency[] dependencies) Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.static voidshowSummary(Dependency[] dependencies) Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.
-
Constructor Details
-
DependencyCheckScanAgent
public DependencyCheckScanAgent()
-
-
Method Details
-
getApplicationName
Get the value of applicationName.- Returns:
- the value of applicationName
-
setApplicationName
Set the value of applicationName.- Parameters:
applicationName- new value of applicationName
-
getNvdApiKey
-
setNvdApiKey
Set the value of nvdApiKey.- Parameters:
nvdApiKey- new value of nvdApiKey
-
getDependencies
Returns a list of pre-determined dependencies.- Returns:
- returns a list of dependencies
-
setDependencies
Sets the list of dependencies to scan.- Parameters:
dependencies- new value of dependencies
-
getDataDirectory
Get the value of dataDirectory.- Returns:
- the value of dataDirectory
-
setDataDirectory
Set the value of dataDirectory.- Parameters:
dataDirectory- new value of dataDirectory
-
getReportOutputDirectory
Get the value of reportOutputDirectory.- Returns:
- the value of reportOutputDirectory
-
setReportOutputDirectory
Set the value of reportOutputDirectory.- Parameters:
reportOutputDirectory- new value of reportOutputDirectory
-
getFailBuildOnCVSS
Get the value of failBuildOnCVSS.- Returns:
- the value of failBuildOnCVSS
-
setFailBuildOnCVSS
Set the value of failBuildOnCVSS.- Parameters:
failBuildOnCVSS- new value of failBuildOnCVSS
-
isAutoUpdate
public boolean isAutoUpdate()Get the value of autoUpdate.- Returns:
- the value of autoUpdate
-
setAutoUpdate
public void setAutoUpdate(boolean autoUpdate) Set the value of autoUpdate.- Parameters:
autoUpdate- new value of autoUpdate
-
isUpdateOnly
public boolean isUpdateOnly()Get the value of updateOnly.- Returns:
- the value of updateOnly
-
setUpdateOnly
public void setUpdateOnly(boolean updateOnly) Set the value of updateOnly.- Parameters:
updateOnly- new value of updateOnly
-
isGenerateReport
public boolean isGenerateReport()Get the value of generateReport.- Returns:
- the value of generateReport
-
setGenerateReport
public void setGenerateReport(boolean generateReport) Set the value of generateReport.- Parameters:
generateReport- new value of generateReport
-
getReportFormat
Get the value of reportFormat.- Returns:
- the value of reportFormat
-
setReportFormat
Set the value of reportFormat.- Parameters:
reportFormat- new value of reportFormat
-
getProxyServer
-
setProxyServer
Set the value of proxyServer.- Parameters:
proxyServer- new value of proxyServer
-
getProxyUrl
Deprecated.usegetProxyServer()insteadGet the value of proxyServer.- Returns:
- the value of proxyServer
-
setProxyUrl
Deprecated.usesetProxyServer(java.lang.String)insteadSet the value of proxyServer.- Parameters:
proxyUrl- new value of proxyServer
-
getProxyPort
-
setProxyPort
Set the value of proxyPort.- Parameters:
proxyPort- new value of proxyPort
-
getProxyUsername
Get the value of proxyUsername.- Returns:
- the value of proxyUsername
-
setProxyUsername
Set the value of proxyUsername.- Parameters:
proxyUsername- new value of proxyUsername
-
getProxyPassword
Get the value of proxyPassword.- Returns:
- the value of proxyPassword
-
setProxyPassword
Set the value of proxyPassword.- Parameters:
proxyPassword- new value of proxyPassword
-
getConnectionTimeout
Get the value of connectionTimeout.- Returns:
- the value of connectionTimeout
-
setConnectionTimeout
Set the value of connectionTimeout.- Parameters:
connectionTimeout- new value of connectionTimeout
-
getReadTimeout
-
setReadTimeout
Set the value of readTimeout.- Parameters:
readTimeout- new value of readTimeout
-
getLogFile
-
setLogFile
Set the value of logFile.- Parameters:
logFile- new value of logFile
-
getSuppressionFile
Get the value of suppressionFile.- Returns:
- the value of suppressionFile
-
setSuppressionFile
Set the value of suppressionFile.- Parameters:
suppressionFile- new value of suppressionFile
-
isShowSummary
public boolean isShowSummary()Get the value of showSummary.- Returns:
- the value of showSummary
-
setShowSummary
public void setShowSummary(boolean showSummary) Set the value of showSummary.- Parameters:
showSummary- new value of showSummary
-
setCpeStartsWithFilter
Sets starting string that identifies CPEs that are qualified to be imported.- Parameters:
cpeStartsWithFilter- filters CPEs based on this starting string (i.e. cpe:/a: )
-
getCpeStartsWithFilter
Returns the starting string that identifies CPEs that are qualified to be imported.- Returns:
- the CPE starting filter (i.e. cpe:/a: )
-
isFailOnUnusedSuppressionRule
public boolean isFailOnUnusedSuppressionRule()Get the value of failOnUnusedSuppressionRule.- Returns:
- the value of failOnUnusedSuppressionRule
-
setFailOnUnusedSuppressionRule
public void setFailOnUnusedSuppressionRule(boolean failOnUnusedSuppressionRule) Set the value of failOnUnusedSuppressionRule.- Parameters:
failOnUnusedSuppressionRule- new value of failOnUnusedSuppressionRule
-
isCentralAnalyzerEnabled
public boolean isCentralAnalyzerEnabled()Get the value of centralAnalyzerEnabled.- Returns:
- the value of centralAnalyzerEnabled
-
setCentralAnalyzerEnabled
public void setCentralAnalyzerEnabled(boolean centralAnalyzerEnabled) Set the value of centralAnalyzerEnabled.- Parameters:
centralAnalyzerEnabled- new value of centralAnalyzerEnabled
-
getCentralUrl
-
setCentralUrl
Set the value of centralUrl.- Parameters:
centralUrl- new value of centralUrl
-
isNexusAnalyzerEnabled
public boolean isNexusAnalyzerEnabled()Get the value of nexusAnalyzerEnabled.- Returns:
- the value of nexusAnalyzerEnabled
-
setNexusAnalyzerEnabled
public void setNexusAnalyzerEnabled(boolean nexusAnalyzerEnabled) Set the value of nexusAnalyzerEnabled.- Parameters:
nexusAnalyzerEnabled- new value of nexusAnalyzerEnabled
-
getNexusUrl
-
setNexusUrl
Set the value of nexusUrl.- Parameters:
nexusUrl- new value of nexusUrl
-
isNexusUsesProxy
public boolean isNexusUsesProxy()Get the value of nexusUsesProxy.- Returns:
- the value of nexusUsesProxy
-
setNexusUsesProxy
public void setNexusUsesProxy(boolean nexusUsesProxy) Set the value of nexusUsesProxy.- Parameters:
nexusUsesProxy- new value of nexusUsesProxy
-
getDatabaseDriverName
Get the value of databaseDriverName.- Returns:
- the value of databaseDriverName
-
setDatabaseDriverName
Set the value of databaseDriverName.- Parameters:
databaseDriverName- new value of databaseDriverName
-
getDatabaseDriverPath
Get the value of databaseDriverPath.- Returns:
- the value of databaseDriverPath
-
setDatabaseDriverPath
Set the value of databaseDriverPath.- Parameters:
databaseDriverPath- new value of databaseDriverPath
-
getConnectionString
Get the value of connectionString.- Returns:
- the value of connectionString
-
setConnectionString
Set the value of connectionString.- Parameters:
connectionString- new value of connectionString
-
getDatabaseUser
-
setDatabaseUser
Set the value of databaseUser.- Parameters:
databaseUser- new value of databaseUser
-
getDatabasePassword
Get the value of databasePassword.- Returns:
- the value of databasePassword
-
setDatabasePassword
Set the value of databasePassword.- Parameters:
databasePassword- new value of databasePassword
-
getZipExtensions
Get the value of zipExtensions.- Returns:
- the value of zipExtensions
-
setZipExtensions
Set the value of zipExtensions.- Parameters:
zipExtensions- new value of zipExtensions
-
getPathToDotnetCore
-
setPathToDotnetCore
Set the value of pathToCore.- Parameters:
pathToCore- new value of pathToCore
-
getPropertiesFilePath
Get the value of propertiesFilePath.- Returns:
- the value of propertiesFilePath
-
setPropertiesFilePath
Set the value of propertiesFilePath.- Parameters:
propertiesFilePath- new value of propertiesFilePath
-
execute
Executes the dependency-check and generates the report.- Returns:
- a reference to the engine used to perform the scan.
- Throws:
ScanAgentException- thrown if there is an exception executing the scan.
-
showSummary
Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.- Parameters:
dependencies- a list of dependency objects
-
showSummary
Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.- Parameters:
projectName- the name of the projectdependencies- a list of dependency objects
-
getProxyServer()instead