Skip to main content

Contrast CLI

Contrast CLI is a command-line tool, distributed via Homebrew on macOS and Linux, that signs you in to Contrast, instruments Docker containers with a Contrast agent, and runs a CVE Shield demo for prospects evaluating the Free tier.

Note

This CLI installs separately from the existing Contrast CLI used by Contrast enterprise customers to scan code and open-source dependencies in static application security testing (SAST).

The Contrast CLI commands help Free tier prospects who find instrumenting their first application challenging. Paid customers can use them too, but they are intended for temporary debugging, troubleshooting, and evaluation. For production rollouts, keep using your usual agent deployment method.

Installing the Contrast CLI does not install, remove, or otherwise affect any instance of the existing Contrast CLI. There is no shared configuration or overlapping commands between them.

Before you begin

Make sure you have everything you need before you start.

  • macOS or Linux with a UI and browser

  • Homebrew

  • A Java application (optional if running a demo)

  • Docker Engine

  • Docker Desktop (optional)

  • A Contrast account and the URL of your Contrast instance

  • A web browser on the same machine for signing in to Contrast

Install the CLI

Install the CLI from Homebrew by running the following commands:

brew install contrastsecurity/tap/contrast-cli

Verify the installation

Run the following command to confirm that the CLI installed and to see which version you have:

contrast-cli --version

Sign in to Contrast

After you install the CLI, run the following command to authenticate it with your Contrast account. Replace <Your-Contrast-Instance-URL> with the HTTPS address of your Contrast instance.

contrast-cli configure --url <Your-Contrast-Instance-URL>

For example, if you have signed up for CVE Shield Free, run the following command:

contrast-cli configure --url https://cs004.contrastsecurity.com

Your default browser opens to the Contrast sign-in page. Sign in there. If the browser does not open, copy the sign-in URL that the CLI prints in your terminal and paste it into a browser on the same machine.

After signing in, close the browser window and return to your terminal window. The CLI fetches your API keys and stores them, along with your sign-in, in your operating system keychain.

You have five minutes to finish signing in. If time runs out, run the command again.

Sign out

To revoke your sign-in and remove the credentials and keys that the CLI stored on your machine, run the following command:

contrast-cli sign-out

To watch CVE Shield detect a real vulnerability in a sample application, see Demo Contrast CVE Shield.