Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.jeremylong:dependency-check-gradle:10.0.3'
}
<dependency>
<groupId>com.github.jeremylong</groupId>
<artifactId>dependency-check-gradle</artifactId>
<version>10.0.3</version>
</dependency>
libraryDependencies += "com.github.jeremylong" % "dependency-check-gradle" % "10.0.3"
:dependencies [[com.github.jeremylong/dependency-check-gradle "10.0.3"]]
The dependency-check gradle plugin allows projects to monitor dependent libraries for known, published vulnerabilities.
Breaking Changes are included in the 9.0.0 release. Please see the 9.0.0 Upgrade Notice on the primary dependency-check site for more information.
With 9.0.0 users may encounter issues with NoSuchMethodError
exceptions due to
dependency resolution. If you encounter this issue you will need to pin some of
the transitive dependencies of dependency-check to specific versions. For example:
/buildSrc/build.gradle
dependencies {
constraints {
// org.owasp.dependencycheck needs at least this version of jackson. Other plugins pull in older versions..
add("implementation", "com.fasterxml.jackson:jackson-bom:2.16.1")
// org.owasp.dependencycheck needs these versions. Other plugins pull in older versions..
add("implementation", "org.apache.commons:commons-lang3:3.14.0")
add("implementation", "org.apache.commons:commons-text:1.11.0")
}
}
The latest version is 11.1.1.
Below are the quick start instructions. Please see the documentation site for more detailed information on configuration and usage.
Add the plugin to your build.gradle file:
plugins {
id "org.owasp.dependencycheck" version "11.1.1"
}
Once gradle plugin applied, run following gradle task to check dependencies:
gradle dependencyCheckAnalyze --info
The reports will be generated automatically under build/reports
directory.
If your project includes multiple sub-projects, the report will be generated for each sub-project in their own build/reports
.
Questions List:
- What if my project includes multiple sub-project? How can I use this plugin for each of them including the root project?
- How to customize the report directory?
Try put 'apply plugin: "dependency-check"' inside the 'allprojects' or 'subprojects' if you'd like to check all sub-projects only, see below:
(1) For all projects including root project:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.owasp:dependency-check-gradle:11.1.1"
}
}
allprojects {
apply plugin: 'org.owasp.dependencycheck'
}
(2) For all sub-projects:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.owasp:dependency-check-gradle:11.1.1"
}
}
subprojects {
apply plugin: 'org.owasp.dependencycheck'
}
In this way, the dependency check will be executed for all projects (including root project) or just sub projects.
By default, all reports will be placed under build/reports
folder, to change the default reporting folder name modify the configuration section like this:
subprojects {
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
outputDirectory = "$buildDir/security-report"
}
}
plugins {
id("org.owasp.dependencycheck") version "11.1.1" apply false
}
allprojects {
apply(plugin = "org.owasp.dependencycheck")
}
configure<org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension> {
format = org.owasp.dependencycheck.reporting.ReportGenerator.Format.ALL.toString()
}