|
1 | 1 | #!/bin/sh |
2 | 2 |
|
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 |
17 | 13 |
|
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 |
21 | 21 |
|
22 | | -else |
| 22 | +if [ -d ./working ]; then |
23 | 23 |
|
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/* |
25 | 27 |
|
26 | 28 | fi |
27 | 29 |
|
| 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