Skip to content

Commit dccf3ef

Browse files
committed
Change Contrast agent setup to use contrast.yaml config file per
vendor request.
1 parent e457c9a commit dccf3ef

File tree

6 files changed

+85
-56
lines changed

6 files changed

+85
-56
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
.DS_Store
22
.java-version
3+
.classpath
4+
.project
5+
.settings/
36
reports/
47
target/
58
testfiles/
9+
tools/Contrast/contrast.jar
10+
tools/Contrast/contrast.yaml
11+
tools/Contrast/working/
612

pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,7 @@
320320
-Xmx8G
321321
-javaagent:${basedir}/tools/Contrast/contrast.jar
322322
-Dcontrast.dir=${basedir}/tools/Contrast/working
323-
-Dcontrast.agent.java.standalone_app_name=OWASPBenchmark
324-
-Dcontrast.application.name=OWASPBenchmark
325-
-Dcontrast.application.path=/
326-
-Dcontrast.assess.rules.disabled_rules="autocomplete-missing,cache-controls-missing,clickjacking-control-missing,csrf"
327-
-Dcontrast.assess.threshold.entries=100000
328-
-Dcontrast.protect.enable=false
329-
-Dcontrast.level=debug
330-
-Dcontrast.log.daily=true
323+
-Dcontrast.config.path=${basedir}/tools/Contrast/contrast.yaml
331324
</cargo.jvmargs>
332325
<cargo.servlet.port>8443</cargo.servlet.port>
333326
<cargo.protocol>https</cargo.protocol>

tools/Contrast/contrast.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contrast Security configuration file
2+
3+
# Fill in your credentials from *your* Contrast TeamServer below:
4+
api:
5+
url: https://___________/Contrast
6+
api_key: ________________
7+
service_key: ________________
8+
user_name: _____________________ # The email address you login to TeamServer with
9+
10+
# These settings are for OWASP Benchmark and shouldn't be changed
11+
java:
12+
standalone_app_name: owasp-benchmark
13+
agent:
14+
logger:
15+
level: debug
16+
server:
17+
name: owasp-server
18+
environment: development
19+
assess:
20+
enable: true
21+
threshold:
22+
entries: 100000
23+
rules:
24+
disabled_rules: autocomplete-missing,cache-controls-missing,clickjacking-control-missing,csrf
25+
protect:
26+
enable: false
27+

tools/Contrast/readme.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
DISCLAIMER: OWASP does not endorse any commercial tools, including this one. Benchmark support for this tool is simply for user convenience and should not be considered an endorsement of this tool.
22

3-
Contrast is a commercial tool. If you are interested in running Contrast on the Benchmark, you'll have to get a license for it from the vendor just like you would for any commercial tool. Once you have it, you need to place the contrast.jar file in this directory in order to run the Benchmark with Contrast using one of the runBenchmark_wContrast scripts, and then crawl the Benchmark to generate scan results with one of the runCrawler scripts.
3+
Contrast is a commercial product, so you need to provide your Contrast credentials in the contrast.yaml file in order to run it. You can use your enterprise Contrast account or sign up for the free Contrast Community Edition (CE) at https://www.contrastsecurity.com/contrast-community-edition.
4+
5+
To run Benchmark with Contrast, you can use the runBenchmark_wContrast.sh script
6+
1. This script will download the latest Contrast agent
7+
2. It will start the Benchmark application server with the Contrast agent as configured by contrast.yaml
8+
3. It will then pause, waiting for input from the web crawler (see next step)
9+
4. In a separate shell, you need to run the runCrawler.sh script from the Benchmark root directory
10+
5. When the crawler finishes (after about a minute) *you* hit CTRL+C in the runBenchmark_wContrast window to stop the server
11+
6. The Contrast script will then copy the Contrast vulnerability results to the Benchmark /results directory
12+
7. Run createScorecards.sh in the Benchmark root directory to create a detailed scorecard in /scorecard that includes these Contrast results
413

514
See the Tool Scanning Tips page at OWASP (https://owasp.org/www-project-benchmark/#div-scanning_tips) for the latest instructions on how to scan the Benchmark with any vulnerability detection tool, including Contrast.
615

7-
Contrast has released Contrast Community Edition (CE), which is free, subject to the terms of its use. If you don't have a commercial license for Contrast, it is likely you can use Contrast CE on Benchmark. See: https://www.contrastsecurity.com/community-edition-lp for more information.

tools/Contrast/runBenchmark_wContrast.bat

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
11
#!/bin/sh
22

3-
if [ -f ./contrast.jar ]; then
4-
5-
if [ -d ./working ]; then
6-
7-
rm -r ./working/cache
8-
rm -r ./working/contrast.log
9-
echo ""
10-
echo "Previous Contrast results in tools/Contrast/working removed"
11-
echo ""
12-
13-
fi
14-
15-
cd ../..
16-
mvn clean package cargo:run -Pdeploywcontrast
3+
if grep -q "____" "contrast.yaml"; then
4+
echo
5+
echo "Contrast is a commercial product, so you need to provide your Contrast credentials in the contrast.yaml file in order to run it."
6+
echo "You can use your enterprise Contrast account or sign up for the free Contrast Community Edition (CE) at \"https://www.contrastsecurity.com/contrast-community-edition\"."
7+
echo "When logged in to the Contrast TeamServer, your credentials are available via \"User settings\" in the top right menu. See the Profile section 'YOUR KEYS'."
8+
echo
9+
echo "ERROR: ____ placeholders are still present in contrast.yaml file. Please provide your credentials as directed as they are required for you to proceed."
10+
echo
11+
exit 1
12+
fi
1713

18-
echo "Copying Contrast report to results directory"
19-
cp tools/Contrast/working/contrast.log results/Benchmark_1.2-Contrast.log
20-
cd tools/Contrast
14+
# Check if contrast.jar is there and is less than 24 hours old. If so, don't bother to download again
15+
if $(find contrast.jar -mmin +1440); then
16+
echo "Using Contrast agent downloaded in past day"
17+
else
18+
echo "Fetching the latest Contrast agent"
19+
curl -o contrast.jar -L "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.contrastsecurity&a=contrast-agent&v=LATEST"
20+
fi
2121

22-
else
22+
if [ -d ./working ]; then
2323

24-
echo "Contrast is a commercial product, so you need a licensed version of Contrast in order to run it on the Benchmark. If you have access to Contrast, download the Contrast Agent for Java (contrast.jar) from the Team Server and put it into the /tools/Contrast folder, and then rerun this script. If you don't have a license for Contrast, you can probably use the free Contrast Community Edition (CE) on Benchmark. See: https://www.contrastsecurity.com/community-edition-lp"
24+
echo
25+
echo "Removing previous Contrast results in ./working"
26+
rm -rf ./working/*
2527

2628
fi
2729

30+
echo
31+
echo "Starting Benchmark application server with Contrast agent"
32+
echo " 1. Verify that the output shows \"Starting JVM\"."
33+
echo " 2. If the output contains \"Continuing without Contrast...\" the credentials in contrast.yaml are most likely incorrect or missing."
34+
echo " 3. Once the Benchmark server is fully started, open another terminal window and run the runCrawler.sh script from the Benchmark root directory."
35+
echo " 4. When the crawler finishes (takes a minute or two), hit CTRL+C in this window to stop the server and write the Contrast results to the /results folder."
36+
echo
37+
echo "========================================================================================================================"
38+
39+
cd ../..
40+
mvn clean package cargo:run -Pdeploywcontrast
41+
42+
echo
43+
echo "Copying Contrast report to results directory"
44+
cd tools/Contrast
45+
cp ./working/contrast.log ../../results/Benchmark_1.2-Contrast.log
46+
echo
47+
echo " 5. You can generate a scorecard by running createScorecards.sh in the Benchmark root directory."
48+
echo
49+

0 commit comments

Comments
 (0)