Skip to content

mmahmoodictbd/contrast-security-poc

Repository files navigation

POC on Contrast Security

Motivation

With Contrast your applications automatically detect and fix vulnerabilities, identify attacks, and defend themselves. With this POC, I’m checking if it’s worth the money as a product.

Features

It’s a sample Spring Boot application to play with Contrast.

screenshot

How to run

Prerequisite
  • JDK 1.8 (Tested with Oracle JDK)

  • Maven 3.x+

  • contrast_security.yaml (Download from contrastsecurity.com and put it in /etc/contrast/java)

  • and contrast.jar (Download from contrastsecurity.com and put it in contrast-resource dir in the project)

Example contrast_security.yaml
api:
  url: https://ce.contrastsecurity.com/Contrast
  api_key: my_api_key
  service_key: my_service_key
  user_name: my_user_name
Build and Run
$ mvn clean compile install
$ java -Dcontrast.appname=contrast-security-poc -javaagent:./contrast-resource/contrast.jar -jar target/contrast-security-poc-1.0.0.jar
Running With Contrast Maven Plugin

Set the following environment variables

CONTRAST_USERNAME=YOUR_USERNAME
CONTRAST_APIKEY=YOUR_CONTRAST_APIKEY
CONTRAST_SERVICEKEY=YOUR_CONTRAST_SERVICEKEY
CONTRAST_ORG_UUID=YOUR_CONTRAST_ORG_UUID
CONTRAST_APPID=YOUR_CONTRAST_APPID
CONTRAST_APPNAME=YOUR_CONTRAST_APPNAME
CONTRAST_SERVERNAME=YOUR_CONTRAST_SERVERNAME
mvn install -P run-with-contrast

App in K8s

Build Docker image for agent
$ docker build -t mmahmood/contrast-agent:latest -f Dockerfile-contrast-agent .
$ docker push mmahmood/contrast-agent:latest
Build Docker image for app
$ mvn clean compile package
$ mvn dockerfile:build
$ docker push mmahmood/contrast-security-poc:latest
Deploy POC app with agent in Kubernetes
$ kubectl apply -f deployment-k8s/contrast-security-poc-all-in-one.yml

App in Docker Compose

Build Docker image with the agent
$ docker build -t mmahmood/contrast-security-poc-with-contrast-agent:latest --build-arg JAR_FILE=target/contrast-security-poc.jar -f Dockerfile-app-with-contrast-agent .
$ docker push mmahmood/contrast-security-poc-with-contrast-agent:latest
Deploy POC app with agent in Kubernetes
$ docker-compose up

Releases

No releases published

Packages

No packages published