Use Assess CLI with Java agents
Use this procedure if you are using Contrast Java agents and want to use the CLI to find vulnerabilities while running API or end-to-end testing.
Before you begin
Verify your application can use the Assess CLI by checking the Java supported technologies.
Steps
To install the latest Java agent , download it from from Maven Central.
Important
Do not create a configuration (YAML) file for the agent. The Assess CLI generates this file automatically.
Open a terminal window and enter the Assess CLI command:
contrast assess
This command generates the agent configuration file that the Contrast CLI and the agent share. CLI commands describes the options for this command, including the path for the configuration file.
You see output similar to this:
✔Configuration file found at "user_path"
⠼ Waiting for the session to be created.
In your IDE or a second terminal window. run your application with this command:
java -javaagent:<YourContrastJarPath> -jar <AppName>.jar
Alternative methods:
IntelliJ: Modify the run configuration to include the following command as a VM argument:
-javaagent:<YourContrastJarPath>
Replace
<YourContrastJarPath>
with the path for the Java agent'scontrast.jar
file.Using the updated run configuration automatically runs your Java application with the Contrast agent.
VS code: Modify
vmArgs
setting in your launch configuration to include the following command as a VM argument:-javaagent:<YourContrastJarPath>
Replace
<YourContrastJarPath>
with the path for the Java agent'scontrast.jar
file.Add the agent under the
vmArgs
setting
Exercise your application, either interactively or using automated API or end-to-end tests.
View the results in the terminal window where you entered the Assess CLI command.