Back to Dependencycheck

Configuration

src/site/markdown/dependency-check-gradle/configuration.md

12.2.250.0 KB
Original Source

Tasks

TaskDescription
dependencyCheckAnalyzeRuns dependency-check against the project and generates a report.
dependencyCheckAggregateRuns dependency-check against a multi-project build and generates a report.
dependencyCheckUpdateUpdates the local cache of the NVD data from NIST.
dependencyCheckPurgeDeletes the local copy of the NVD. This is used to force a refresh of the data.

Configuration:

groovy
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.owasp:dependency-check-gradle:${project.version}'
    }
}
apply plugin: 'org.owasp.dependencycheck'

check.dependsOn dependencyCheckAnalyze
PropertyDescriptionDefault Value
autoUpdateSets whether auto-updating of the NVD API CVE data is enabled. It is not recommended that this be turned to false.true
analyzedTypesThe default artifact types that will be analyzed.['jar', 'aar', 'js', 'war', 'ear', 'zip']
formatThe report format to be generated (HTML, XML, CSV, JSON, JUNIT, SARIF, JENKINS, GITLAB, ALL).HTML
formatsA list of report formats to be generated (HTML, XML, CSV, JSON, JUNIT, SARIF, JENKINS, GITLAB, ALL). 
junitFailOnCVSSIf using the JUNIT report format the junitFailOnCVSS sets the CVSS score threshold that is considered a failure.0
failBuildOnCVSSSpecifies if the build should be failed if a CVSS score equal to or above a specified level is identified. The default is 11; since the CVSS scores are 0-10, by default the build will never fail. More information on CVSS scores can be found at the NVD11
failOnErrorFails the build if an error occurs during the dependency-check analysis.true
outputDirectoryThe location to write the report(s). This directory will be located in the build directory.${buildDir}/reports
skipTestGroupsWhen set to true (the default) all dependency groups that being with 'test' will be skipped.true
suppressionFileThe file path to the XML suppression file - used to suppress false positives. The configured value can be a local file path, a URL to a suppression file, or even a reference to a file on the class path (see https://github.com/dependency-check/DependencyCheck/issues/1878#issuecomment-487533799) 
suppressionFilesA list of file paths to the XML suppression files - used to suppress false positives. The configured values can be a local file path, a URL to a suppression file, or even a reference to a file on the class path (see https://github.com/dependency-check/DependencyCheck/issues/1878#issuecomment-487533799) 
failBuildOnUnusedSuppressionRuleSpecifies that if any unused suppression rule is found, the build will fail. This is best combined with a Gradle CLI --warn arg or org.gradle.logging.level=warn property so the unused rules are logged before task failure.false
hintsFileThe file path to the XML hints file - used to resolve false negatives 
skipIf set to true dependency-check analysis will be skipped.false
skipConfigurationsA list of configurations that will be skipped. This is mutually exclusive with the scanConfigurations property.[] which means no configuration is skipped.
scanConfigurationsA list of configurations that will be scanned, all other configurations are skipped. This is mutually exclusive with the skipConfigurations property.[] which implicitly means all configurations get scanned.
scanProjectsA list of projects that will be scanned, all other projects are skipped. The list or projects to skip must include a preceding colon: scanProjects = [':app']. This is mutually exclusive with the skipProjects property.[] which implicitly means all projects get scanned.
skipProjectsA list of projects that will be skipped. The list or projects to skip must include a preceding colon: skipProjects = [':sub1']. This is mutually exclusive with the scanProjects property.[] which means no projects are skipped.
scanBuildEnvA boolean indicating whether to scan the buildEnv.false
scanDependenciesA boolean indicating whether to scan the dependencies.true
scanSetA list of directories that will be scanned for additional dependencies.['src/main/resources','src/main/webapp', './package.json', './package-lock.json', './npm-shrinkwrap.json', './Gopkg.lock', './go.mod']

Example

groovy
dependencyCheck {
    autoUpdate = false
    format = 'ALL'
}

Proxy Configuration

Please see https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy

Advanced Configuration

The following properties can be configured in the dependencyCheck task. However, they are less frequently changed.

Config GroupPropertyDescriptionDefault Value
 showSummaryWhether to print the summary of found vulnerabilities after completion.true
 suppressionFileUserCredentials used for basic authentication for web-hosted suppression files 
 suppressionFilePasswordCredentials used for basic authentication for web-hosted suppression files 
 suppressionFileBearerTokenCredentials used for bearer authentication for web-hosted suppression files 
nvdapiKeyThe API Key to access the NVD API; obtained from https://nvd.nist.gov/developers/request-an-api-key 
nvdendpointThe NVD API endpoint URL; setting this is uncommon.https://services.nvd.nist.gov/rest/json/cves/2.0
nvdmaxRetryCountThe maximum number of retry requests for a single call to the NVD API.10
nvddelayThe number of milliseconds to wait between calls to the NVD API.3500 with an NVD API Key or 8000 without an API Key
nvdresultsPerPageThe number records for a single page from NVD API (must be <=2000).2000
nvddatafeedUrlThe URL for the NVD API Data feed that can be generated using https://github.com/jeremylong/open-vulnerability-cli/blob/main/README.md#mirroring-the-nvd-cve-data 
nvddatafeedUserCredentials used for basic authentication for the NVD API Data feed. 
nvddatafeedPasswordCredentials used for basic authentication for the NVD API Data feed. 
nvddatafeedBearerTokenCredentials used for bearer authentication for the NVD API Data feed. 
nvdvalidForHoursThe number of hours to wait before checking for new updates from the NVD.4
datadirectorySets the data directory to hold SQL CVEs contents. This should generally not be changed. 
datadriverThe database driver full classname; note, only needs to be set if the driver is not JDBC4 compliant or the JAR is outside of the class path. 
datadriverPathThe path to the database driver JAR file; only needs to be set if the driver is not in the class path. 
dataconnectionStringThe connection string used to connect to the database. See using a database server. 
datausernameThe username used when connecting to the database. 
datapasswordThe password used when connecting to the database. 
slackenabledWhether or not slack notifications are enabled.false
slackwebhookUrlThe custom incoming webhook URL to receive notifications. Note that the current implementation only notifies about build failures so this should be used in combination with failBuildOnCVSS. 
hostedSuppressionsenabledWhether the hosted suppressions file will be used.true
hostedSuppressionsforceupdateSets whether hosted suppressions file will update regardless of the autoupdate setting.false
hostedSuppressionsurlThe URL to a mirrored copy of the hosted suppressions file for internet-constrained environments.https://dependency-check.github.io/DependencyCheck/suppressions/publishedSuppressions.xml
hostedSuppressionsuserCredentials used for basic authentication for the hosted suppressions file. 
hostedSuppressionspasswordCredentials used for basic authentication for the hosted suppressions file. 
hostedSuppressionsbearerTokenCredentials used for bearer authentication for the hosted suppressions file. 
hostedSuppressionsvalidForHoursThe number of hours to wait before checking for new updates of the hosted suppressions file .2
cacheossIndexSets whether the OSS Index Analyzer will cache results. Cached results expire after 24 hours.true
cachecentralSets whether the Central Analyzer will cache results. Cached results expire after 30 days.true
cachenodeAuditSets whether the Node Audit Analyzer should cache results locally. Cached results expire after 24 hours.true

Example

groovy
dependencyCheck {
    data.directory = 'd:/nvd'
}

Analyzer Configuration

In addition to the above, the dependencyCheck plugin can be configured to enable or disable specific analyzers by configuring the analyzers section. Note, specific file type analyzers will automatically disable themselves if no file types that they support are detected - so specifically disabling the analyzers is likely not needed.

Config GroupPropertyDescriptionDefault Value
analyzersexperimentalEnabledSets whether the experimental analyzers will be used. If not set to true the analyzers marked as experimental (see below) will not be usedfalse
analyzersarchiveEnabledSets whether the Archive Analyzer will be used.true
analyzerszipExtensionsA comma-separated list of additional file extensions to be treated like a ZIP file, the contents will be extracted and analyzed. 
analyzersjarEnabledSets whether Jar Analyzer will be used.true
analyzersdartEnabledSets whether the experimental Dart Analyzer will be used. experimentalEnabled must be set to true.true
analyzerscentralEnabledSets whether Central Analyzer will be used. If you have non-Gradle-managed jar dependencies inside archives or non-Java ecosystem dependencies, you may want to enable this analyzer (or the alternative Nexus/Artifactory analyzers) to reduce chance of false negatives.false
analyzerspyDistributionEnabledSets whether the experimental Python Distribution Analyzer will be used. experimentalEnabled must be set to true.true
analyzerspyPackageEnabledSets whether the experimental Python Package Analyzer will be used. experimentalEnabled must be set to true.true
analyzersrubygemsEnabledSets whether the experimental Ruby Gemspec Analyzer will be used. experimentalEnabled must be set to true.true
analyzersopensslEnabledSets whether the openssl Analyzer should be used.true
analyzersnuspecEnabledSets whether the .NET Nuget Nuspec Analyzer will be used.true
analyzersnugetconfEnabledSets whether the experimental .NET Nuget packages.config Analyzer will be used. experimentalEnabled must be set to true.true
analyzersassemblyEnabledSets whether the .NET Assembly Analyzer should be used.true
analyzersmsbuildEnabledSets whether the MS Build Analyzer should be used.true
analyzerspathToDotnetThe path to dotnet core - needed on some systems to analyze .net assemblies. 
analyzerscmakeEnabledSets whether the experimental CMake Analyzer should be used. experimentalEnabled must be set to true.true
analyzersautoconfEnabledSets whether the experimental autoconf Analyzer should be used. experimentalEnabled must be set to true.true
analyzerscomposerEnabledSets whether the experimental PHP Composer Lock File Analyzer should be used. experimentalEnabled must be set to true.true
analyzerscomposerSkipDevSets whether the experimental PHP Composer Lock File Analyzer should skip "packages-dev".false
analyzerscpanEnabledSets whether the experimental Perl CPAN File Analyzer should be used. experimentalEnabled must be set to true.true
analyzerscocoapodsEnabledSets whether the experimental Cocoapods Analyzer should be used. experimentalEnabled must be set to true.true
analyzerscarthageEnabledSets whether the experimental Carthage Analyzer should be used. experimentalEnabled must be set to true.true
analyzersswiftEnabledSets whether the experimental Swift Package Manager Analyzer should be used. experimentalEnabled must be set to true.true
analyzersswiftPackageResolvedEnabledSets whether the experimental Swift Package Resolved Analyzer should be used. experimentalEnabled must be set to true.true
analyzersbundleAuditEnabledSets whether the Ruby Bundle Audit Analyzer should be used.true
analyzerspathToBundleAuditThe path to bundle audit. 
analyzersgolangDepEnabledSets whether the experimental Golang Dependency Analyzer should be used. experimentalEnabled must be set to true.true
analyzersgolangModEnabledSets whether the experimental Goland Module Analyzer should be used; requires go to be installed. experimentalEnabled must be set to true.true
analyzerspathToGoThe path to go. 

Analyzers Additional Configuration

Within the analyzers group, the following sub-groups are configurable.

Config GroupPropertyDescriptionDefault Value
nexusenabledSets whether Nexus Analyzer will be used. This analyzer is an alternative to the Central or Artifactory Analyzers, allowing retrieval from Sonatype Nexus installations.false
nexusurlDefines the Nexus web service endpoint (example http://domain.enterprise/nexus/service/local/). If not set the Nexus Analyzer will be disabled. 
nexususesProxyWhether the defined proxy should be used when connecting to Nexus.true
nexususerThe username to authenticate to the Nexus Server's web service end point. If not set the Nexus Analyzer will use an unauthenticated connection. 
nexuspasswordThe password to authenticate to the Nexus Server's web service end point. If not set the Nexus Analyzer will use an unauthenticated connection. 
artifactoryenabledSets whether Artifactory analyzer will be used. This analyzer is an alternative to the Central or Nexus Analyzers, allowing metadata retrieval from Artifactory installations.false
artifactoryurlThe Artifactory server URL. 
artifactoryusesProxyWhether Artifactory should be accessed through a proxy or not.false
artifactoryparallelAnalysisWhether the Artifactory analyzer should be run in parallel or not.true
artifactoryusernameThe user name (only used with API token) to connect to Artifactory instance. 
artifactoryapiTokenThe API token to connect to Artifactory instance, only used if the username or the API key are not defined by artifactoryAnalyzerServerId,artifactoryAnalyzerUsername or artifactoryAnalyzerApiToken 
artifactorybearerTokenThe bearer token to connect to Artifactory instance. 
kevenabledSets whether the Known Exploited Vulnerability update and analyzer are enabled.true
kevurlThe URL to (a mirror of) the CISA Known Exploited Vulnerabilities JSON data feed.https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json
kevuserCredentials used for basic authentication for the CISA Known Exploited Vulnerabilities JSON data feed. 
kevpasswordCredentials used for basic authentication for the CISA Known Exploited Vulnerabilities JSON data feed. 
kevbearerTokenCredentials used for bearer authentication for the CISA Known Exploited Vulnerabilities JSON data feed. 
kevvalidForHoursThe number of hours to wait before checking for new updates of the hosted suppressions file .2
nodePackageenabledSets whether the Node Package Analyzer should be used.true
nodePackageskipDevDependenciesSets whether the Node Package Analyzer will skip devDependencies.false
nodeAuditenabledSets whether the Node Audit Analyzer should be used. This analyzer requires an internet connection.true
nodeAudituseCacheSets whether the Node Audit Analyzer should cache results locally. Cached results expire after 24 hours.true
nodeAuditskipDevDependenciesSets whether the Node Audit Analyzer should skip devDependencies.false
nodeAuditpnpmEnabledSets whether the Pnpm Audit Analyzer should be used. This analyzer requires yarn and an internet connection.true
nodeAuditpnpmPathSets the path to the pnpm executable. 
nodeAudityarnEnabledSets whether the Yarn Audit Analyzer should be used. This analyzer requires yarn and an internet connection.true
nodeAudityarnPathSets the path to the yarn executable. 
nodeAuditpnpmEnabledSets whether the Pnpm Audit Analyzer should be used. This analyzer requires pnpm and an internet connection.true
nodeAuditpnpmPathThe path to pnpm. 
nodeAuditurlThe node audit API url to use. 
retirejsenabledSets whether the RetireJS Analyzer should be used.true
retirejsforceupdateSets whether the RetireJS Analyzer should update regardless of the autoupdate setting.false
retirejsretireJsUrlThe URL to the Retire JS repository.https://raw.githubusercontent.com/Retirejs/retire.js/master/repository/jsrepository.json
retirejsuserCredentials used for basic authentication for the Retire JS repository URL. 
retirejspasswordCredentials used for basic authentication for the Retire JS repository URL. 
retirejsbearerTokenCredentials used for bearer authentication for the Retire JS repository URL. 
retirejsfilterNonVulnerableConfigures the RetireJS Analyzer to remove non-vulnerable JS dependencies from the report.false
retirejsfiltersConfigures the list of regular expressions used to filter JS files based on content. 
ossIndexenabledSets whether the OSS Index Analyzer will be used. This analyzer requires an internet connection, and authentication is mandatory.true
ossIndexurlAlternative base URL for the OSS Index API. If not set the public Sonatype OSS Index API on Sonatype Guide will be used.https://api.guide.sonatype.com
ossIndexusername(deprecated) Sets the OSS Index API username for use with legacy OSS Index API tokens. Username is not required after migration to using Sonatype Guide personal access token as password. 
ossIndexpasswordSets the Sonatype Guide personal access token or (deprecated) legacy OSS Index API token to authenticate with. 
ossIndexvalidForHoursThe number of hours to wait before checking for new updates on individual packages/components from Sonatype OSS Index24
ossIndexwarnOnlyOnRemoteErrorsSets whether remote errors from the OSS Index (e.g. BAD GATEWAY, RATE LIMIT EXCEEDED) will result in warnings only instead of failing execution.false

Example

groovy
dependencyCheck {
    analyzers.assemblyEnabled = false

    analyzers.artifactory.enabled = true
    analyzers.artifactory.url = 'https://internal.artifactory.url'

    analyzers.retirejs.filters = ['(i)copyright Jeremy Long']

    analyzers.ossIndex.password = 'sonatype_pat_42cc601cd7ff12a531a0b1eada8dcf56d777b336'
}