Contrast Gradle plugin
The Gradle plugin for Contrast Security enables:
The installation of the Contrast Java Agent
A connection to Contrast
Verifying applications for new vulnerabilities
Before you begin
Make sure you have Gradle 8.3+
Tasks
The plugin has two publicly available tasks.
resolveAgent
: Pulls down the agent provided by the ContrastSDK. If an agent is provided with the jarPath configuration field, the plugin verifies that the file exists.contrastCheck
: Runs all configuredTest
tasks with the agent installed, and fails the build if any vulnerabilities are found for the application on Contrast.
Configuration
Import the plugin from the Gradle Plugin Portal:
plugins{ id 'com.contrastsecurity.contrastplugin' version '3.0.0' }
This plugin is configured via the contrastConfiguration
block in your project's gradle.build
script. The username
, apiKey
, serviceKey
, and orgUuid
are the same credentials normally used. These can be found in Contrast under user profile > User Settings and user profile > Organization Settings.
contrastConfiguration{ username = '<username>' apiKey = '<apiKey>' serviceKey = '<serviceKey>' apiUrl = '<apiUrl>' orgUuid = '<orgUuid>' appName = '<appName>' serverName = '<serverName>' appVersion = '<appVersion>' jarPath = "<path.to.local.agent.jar>" }
Configuration Properties
Configuration Value | Description | Required |
---|---|---|
| Can be found in Contrast under User Settings | Yes |
| Can be found in Contrast under Organization Settings | Yes |
| The URL from the Contrast organization you use and ends in | Yes |
| If | No |
| Used to correlate data on Contrast, can be an existing application and server, but can also be new values for each | Yes |
| Path to a provided Contrast Java Agent. If not provided, the plugin will download a path from the SDK. | No |
| Configures the minimum severity of vulnerability required for the plugin to fail the build. Values in order of increasing severity:
Defaults to Medium | No |
Usage
Once your plugin has been added to your project and configured, run:
./gradlew contrastCheck
This will run all tasks of type Test
in the project with the Contrast Java Agent attached. If any vulnerabilities that exceed the minimum severity level are found, the build will fail and the vulnerabilities will be logged to <buildFolder>/contrast/traceResults_<testTaskName>.txt
.