Fork me on GitHub

Tasks

Task Description
dependencyCheckAnalyze Runs dependency-check against the project and generates a report.
dependencyCheckAggregate Runs dependency-check against a multi-project build and generates a report.
dependencyCheckUpdate Updates the local cache of the NVD data from NIST.
dependencyCheckPurge Deletes the local copy of the NVD. This is used to force a refresh of the data.

Configuration:

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

check.dependsOn dependencyCheckAnalyze
Property Description Default Value
autoUpdate Sets whether auto-updating of the NVD CVE/CPE data is enabled. It is not recommended that this be turned to false. true
analyzedTypes The default artifact types that will be analyzed. [‘jar’, ‘aar’, ‘js’, ‘war’, ‘ear’, ‘zip’]
cveValidForHours Sets the number of hours to wait before checking for new updates from the NVD. 4
format The report format to be generated (HTML, XML, CSV, JSON, JUNIT, ALL). HTML
formats A list of report formats to be generated (HTML, XML, CSV, JSON, JUNIT, ALL).  
junitFailOnCVSS If using the JUNIT report format the junitFailOnCVSS sets the CVSS score threshold that is considered a failure. 0
failBuildOnCVSS Specifies 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. 11
failOnError Fails the build if an error occurs during the dependency-check analysis. true
outputDirectory The location to write the report(s). This directory will be located in the build directory. build/reports
skipTestGroups When set to true (the default) all dependency groups that being with ‘test’ will be skipped. true
suppressionFile The 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/jeremylong/DependencyCheck/issues/1878#issuecomment-487533799)  
suppressionFiles A 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/jeremylong/DependencyCheck/issues/1878#issuecomment-487533799)  
hintsFile The file path to the XML hints file - used to resolve false negatives  
skip If set to true dependency-check analysis will be skipped. false
skipConfigurations A list of configurations that will be skipped. This is mutually exclusive with the scanConfigurations property. [] which means no configuration is skipped.
scanConfigurations A 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.
scanSet A list of directories that will be scanned for additional dependencies. [‘src/main/resources’,‘src/main/webapp’]

Example

dependencyCheck {
    autoUpdate=false
    cveValidForHours=1
    format='ALL'
}

Proxy Configuration

Config Group Property Description Default Value
proxy server The proxy server; see the proxy configuration page for more information.  
proxy port The proxy port.  
proxy username Defines the proxy user name.  
proxy password Defines the proxy password.  

Example

dependencyCheck {
    proxy {
        server=some.proxy.server
        port=8989
    }
}

Advanced Configuration

The following properties can be configured in the dependencyCheck task. However, they are less frequently changed. One exception may be the cvedUrl properties, which can be used to host a mirror of the NVD within an enterprise environment. When mirroring the NVD you must mirror the *.json.gz and the *.meta files. Note, if ANY of the cve configuration group are set - they should all be set to ensure things work as expected.

Config Group Property Description Default Value
cve urlModified URL for the modified CVE JSON data feed. When mirroring the NVD you must mirror the *.json.gz and the *.meta files. https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-modified.json.gz
cve urlBase Base URL for each year’s CVE JSON data feed, the %d will be replaced with the year. https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-%d.json.gz
data directory Sets the data directory to hold SQL CVEs contents. This should generally not be changed.  
data driver The name of the database driver. Example: org.h2.Driver.  
data driverPath The path to the database driver JAR file; only used if the driver is not in the class path.  
data connectionString The connection string used to connect to the database. See using a database server.  
data username The username used when connecting to the database.  
data password The password used when connecting to the database.  

Example

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 Group Property Description Default Value
analyzers experimentalEnabled Sets whether the experimental analyzers will be used. If not set to true the analyzers marked as experimental (see below) will not be used false
analyzers archiveEnabled Sets whether the Archive Analyzer will be used. true
analyzers zipExtensions A comma-separated list of additional file extensions to be treated like a ZIP file, the contents will be extracted and analyzed.  
analyzers jarEnabled Sets whether Jar Analyzer will be used. true
analyzers centralEnabled Sets whether Central Analyzer will be used. If this analyzer is being disabled there is a good chance you also want to disable the Nexus Analyzer (see below). true
analyzers ossIndexEnabled Sets whether the OSS Index Analyzer will be enabled. true
analyzers nexusEnabled Sets whether Nexus Analyzer will be used (requires Nexus Pro). This analyzer is superceded by the Central Analyzer; however, you can configure this to run against a Nexus Pro installation. true
analyzers nexusUrl Defines the Nexus Server’s web service end point (example http://domain.enterprise/service/local/). If not set the Nexus Analyzer will be disabled.  
analyzers nexusUsesProxy Whether or not the defined proxy should be used when connecting to Nexus. true
analyzers pyDistributionEnabled Sets whether the experimental Python Distribution Analyzer will be used. true
analyzers pyPackageEnabled Sets whether the experimental Python Package Analyzer will be used. true
analyzers rubygemsEnabled Sets whether the experimental Ruby Gemspec Analyzer will be used. true
analyzers opensslEnabled Sets whether or not the openssl Analyzer should be used. true
analyzers nuspecEnabled Sets whether or not the .NET Nuget Nuspec Analyzer will be used. true
analyzers nugetconfEnabled Sets whether or not the experimental .NET Nuget packages.config Analyzer will be used. true
analyzers assemblyEnabled Sets whether or not the .NET Assembly Analyzer should be used. true
analyzers pathToDotnet The path to dotnet core - needed on some systems to analyze .net assemblies.  
analyzers cmakeEnabled Sets whether or not the experimental CMake Analyzer should be used. true
analyzers autoconfEnabled Sets whether or not the experimental autoconf Analyzer should be used. true
analyzers composerEnabled Sets whether or not the experimental PHP Composer Lock File Analyzer should be used. true
analyzers nodeEnabled Sets whether or not the Node.js Analyzer should be used. true
analyzers nodeAuditEnabled Sets whether the Node Audit Analyzer should be used. true
analyzers cocoapodsEnabled Sets whether or not the experimental Cocoapods Analyzer should be used. true
analyzers swiftEnabled Sets whether or not the experimental Swift Package Manager Analyzer should be used. true
analyzers bundleAuditEnabled Sets whether or not the experimental Ruby Bundle Audit Analyzer should be used. true
analyzers pathToBundleAudit The path to bundle audit.  
analyzers retiredEnabled Sets whether the retired analyzers will be used. If not set to true the analyzers marked as experimental (see below) will not be used false
analyzers golangDepEnabled Sets whether or not the experimental Golang Dependency Analyzer should be used. true
analyzers golangModEnabled Sets whether or not the experimental Goland Module Analyzer should be used; requires go to be installed. true
analyzers pathToGo The path to go.  

Additional Analyzer Configuration

Config Group Property Description Default Value
artifactory enabled Sets whether Artifactory analyzer will be used false
artifactory url The Artifactory server URL.   
artifactory usesProxy Whether Artifactory should be accessed through a proxy or not. false
artifactory parallelAnalysis Whether the Artifactory analyzer should be run in parallel or not.  true
artifactory username The user name (only used with API token) to connect to Artifactory instance.  
artifactory apiToken The API token to connect to Artifactory instance, only used if the username or the API key are not defined by artifactoryAnalyzerServerId,artifactoryAnalyzerUsername or artifactoryAnalyzerApiToken  
artifactory bearerToken The bearer token to connect to Artifactory instance  
retirejs enabled Sets whether the RetireJS Analyzer should be used. true
retirejs retireJsUrl The URL to the Retire JS repository. Note the file name must be jsrepository.json. https://raw.githubusercontent.com/Retirejs/retire.js/master/repository/jsrepository.json
retirejs filterNonVulnerable Configures the RetireJS Analyzer to remove non-vulnerable JS dependencies from the report. false
retirejs filters Configures the list of regular expessions used to filter JS files based on content.  
ossIndex enabled Sets whether Sonatype’s OSS Index will be used. true
ossIndex username The optional user name to connect to Sonatype’s OSS Index.  
ossIndex password The optional passwod or API token to connect to Sonatype’s OSS Index,  

Example

dependencyCheck {
    analyzers {
        assemblyEnabled=false
        artifactory {
            enabled=true
            url='https://internal.artifactory.url'
        }
        retirejs {
            filters = ['(i)copyright Jeremy Long']
        }
        ossIndex {
            username = 'example@gmail.com'
            password = '42cc601cd7ff12a531a0b1eada8dcf56d777b336'
    }
}