Skip to content

Commit c1f0127

Browse files
author
owen-jones-diffblue
authored
Merge pull request diffblue#433 from diffblue/owen-jones-diffblue/webgoat-shell-script
SEC-428: webgoat shell script
2 parents 9eea141 + 30df658 commit c1f0127

File tree

2 files changed

+75
-15
lines changed

2 files changed

+75
-15
lines changed

benchmarks/GENUINE/README.txt

+12-15
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,10 @@ Install guide for Ubuntu:
3434

3535
1. git clone [email protected]:WebGoat/WebGoat.git
3636
2. cd WebGoat
37-
3. git checkout develop
38-
4. Add handling of exception 'SQLException' to the method 'completed' in file:
39-
/webgoat-lessons/sql-injection/src/main/java/org/owasp/webgoat/plugin/mitigation/SqlInjectionLesson12a.java
40-
So, the updated should be line 34 and it should look like this:
41-
public AttackResult completed(@RequestParam String ip) throws SQLException {
42-
5. mvn clean install -DskipTests
43-
6. Create the following files representing the entry point to WebGoat:
44-
./WebGoat/__MAIN__/src/main/java/Main.java:
37+
3. git checkout a922c00
38+
4. mvn clean install -DskipTests
39+
5. Create the following files representing the entry point to WebGoat:
40+
./__MAIN__/src/main/java/Main.java:
4541
/*
4642
Lessons considered in this file:
4743
[Sql Injection] Assignment6, registerNewUser
@@ -281,7 +277,7 @@ Install guide for Ubuntu:
281277

282278
Uncomment one of the blocks (depending on what lesson you want to analyse).
283279

284-
./WebGoat/__MAIN__/pom.xml:
280+
./__MAIN__/pom.xml:
285281
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
286282
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
287283
<modelVersion>4.0.0</modelVersion>
@@ -348,7 +344,7 @@ Install guide for Ubuntu:
348344
</dependencies>
349345
</project>
350346

351-
./WebGoat/__MAIN__/build.py:
347+
./__MAIN__/build.py:
352348
import os
353349
import shutil
354350

@@ -359,12 +355,13 @@ Install guide for Ubuntu:
359355
shutil.rmtree("./target/classes/org")
360356
if os.path.isfile("./target/__MAIN__-8.0.0.M3.jar"):
361357
os.remove("./target/__MAIN__-8.0.0.M3.jar")
362-
363-
6. cd __MAIN__
364-
7. python3 ./build.py
365-
8. cd ..
358+
359+
6. copy ../../LIBRARIES/models/model/src/main/java/org to ./__MAIN__/src/main/java/
360+
7. cd __MAIN__
361+
8. python3 ./build.py
366362
9. cd ..
367-
10. rm -rf ./webgoat-container
363+
10. cd ..
364+
11. rm -rf ./webgoat-container
368365

369366
The WebGoat does not seem to have a deployment step. Fortunately, the whole
370367
app is relatively small, so we can load everything for each lesson. It means

benchmarks/GENUINE/WebGoat.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "$SECURITY_SCANNER_HOME" ]; then
4+
echo "Need to set SECURITY_SCANNER_HOME to cmake directory"
5+
exit 1
6+
fi
7+
8+
LESSONS_WHICH_WORK='webgoat-run-SqlInjectionLesson5a webgoat-run-SqlInjectionLesson5b webgoat-run-SqlInjectionLesson6a webgoat-run-SqlInjectionLesson12a webgoat-run-SqlInjectionChallenge webgoat-run-Assignment5 webgoat-run-Assignment6 webgoat-run-CrossSiteScriptingLesson5a webgoat-run-SimpleXXE webgoat-run-BlindSendFileAssignment'
9+
LESSONS_WHICH_DO_NOT_WORK='webgoat-run-CrossSiteScriptingLesson5a webgoat-run-Assignment3 webgoat-run-ContentTypeAssignment webgoat-run-VulnerableComponentsLesson webgoat-run-MissingFunctionACUsers'
10+
11+
set -u
12+
set -x
13+
14+
SCRIPT_WORKING_DIR=$(pwd)
15+
REPO_DIR=$SCRIPT_WORKING_DIR/WebGoat
16+
17+
# 1. git clone [email protected]:WebGoat/WebGoat.git
18+
git clone [email protected]:WebGoat/WebGoat.git
19+
20+
# 2. cd WebGoat
21+
cd WebGoat
22+
23+
# 3. git checkout develop
24+
git checkout a922c00
25+
26+
# 4. mvn clean install -DskipTests
27+
mvn clean install -DskipTests
28+
29+
# 5. Create the following files representing the entry point to WebGoat:
30+
mkdir -p __MAIN__/src/main/java
31+
cp ../WebGoat_files/Main.java __MAIN__/src/main/java/Main.java
32+
cp ../WebGoat_files/pom.xml __MAIN__/pom.xml
33+
34+
# 6. copy ../../LIBRARIES/models/model/src/main/java/org to ./__MAIN__/src/main/java/
35+
cp -r ../../LIBRARIES/models/model/src/main/java/org __MAIN__/src/main/java/
36+
37+
# 7. cd __MAIN__
38+
cd __MAIN__
39+
40+
# 8. python3 ./build.py
41+
if [ -d "./target" ]; then
42+
rm -rf ./target
43+
fi
44+
mvn clean package
45+
if [ -d "./target/classes/org" ]; then
46+
rm -rf ./target/classes/org
47+
fi
48+
if [ -e "./target/__MAIN__-8.0.0.M3.jar" ]; then
49+
rm ./target/__MAIN__-8.0.0.M3.jar
50+
fi
51+
52+
# 9. cd ..
53+
# 10. cd ..
54+
# 11. rm -rf ./webgoat-container
55+
rm -rf ../../webgoat-container
56+
57+
# Run security-analyser on each lesson which works separately
58+
cd $SECURITY_SCANNER_HOME
59+
60+
for LESSON in $LESSONS_WHICH_WORK
61+
do
62+
python3 $SCRIPT_WORKING_DIR/../../driver/run.py -C $SCRIPT_WORKING_DIR/WebGoatRules.json -I $REPO_DIR -L $REPO_DIR -R $SCRIPT_WORKING_DIR/WebGoat-results/$LESSON -T $SCRIPT_WORKING_DIR/WebGoat-tmp --name WebGoat --verbosity 9 --use-models-library --do-not-use-precise-access-paths --rebuild --timeout 10000000 --entry-point Main.$LESSON
63+
done

0 commit comments

Comments
 (0)