Skip to content

Commit 0b20868

Browse files
author
owen-jones-diffblue
authored
Merge pull request diffblue#469 from diffblue/owen-jones-diffblue/standardise-shell-scripts
SEC-515: Standardise shell scripts
2 parents 8d98407 + 61281ba commit 0b20868

File tree

7 files changed

+244
-622
lines changed

7 files changed

+244
-622
lines changed

benchmarks/GENUINE/Alfresco.sh

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
#!/usr/bin/env bash
22

3-
script_dir=$(pwd)
4-
53
if [ -z "$SECURITY_SCANNER_HOME" ]; then
6-
SECURITY_SCANNER_HOME=../../dist
7-
if [ ! -d "$SECURITY_SCANNER_HOME" ]; then
8-
echo "Need to set SECURITY_SCANNER_HOME to cmake directory"
9-
exit 1
10-
fi
11-
echo "SECURITY_SCANNER_HOME set to path: $SECURITY_SCANNER_HOME"
4+
echo "Need to set SECURITY_SCANNER_HOME to cmake directory"
5+
exit 1
6+
fi
7+
8+
# Stop script if a command does not succeed
9+
set -e
10+
11+
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
12+
REPO_DIR=$SCRIPT_DIR/Alfresco
13+
DEPLOY_DIR=$REPO_DIR/__dist__
14+
if [ -z "$OUTPUT_DIR" ]; then
15+
OUTPUT_DIR=$SECURITY_SCANNER_HOME/GENUINE
1216
fi
1317

14-
if [[ ! -d "Alfresco" ]]; then
18+
if [[ ! -d $REPO_DIR ]]; then
19+
# First switch to Java 7
1520
java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
1621
if [[ ! "$java_version" < "1.8" ]]; then
1722
echo "WRONG JAVA VERSION: $java_version"
1823
jdk_7_presence=$(update-java-alternatives --list 2>&1 | grep "java-1.7.0-openjdk-amd64")
19-
if [[ "$jdk_7_presence" == "" ]]; then
24+
if [ -z "$jdk_7_presence" ]; then
2025
echo "In order to install JAVA 1.7 do the following:"
2126
echo " sudo add-apt-repository ppa:openjdk-r/ppa"
2227
echo " sudo apt update"
@@ -41,32 +46,45 @@ if [[ ! -d "Alfresco" ]]; then
4146
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/bin
4247
fi
4348

44-
mkdir Alfresco
45-
cd Alfresco
46-
47-
# The next two statements are commented, because it access the old repo
48-
# which was deleted. It was actually a mirror of the SVN repo used below.
49-
# git clone [email protected]:Alfresco/community-edition .
50-
# git checkout 5fcc93f009c6fb8578e87e79dc19a44309210602
51-
52-
# We are checking out the revision in which we know about the issue.
49+
# Clone the repository and check out a commit which has the issue.
50+
# Originally we looked at commit 5fcc93f009c6fb8578e87e79dc19a44309210602 in
51+
# the git repository [email protected]:Alfresco/community-edition . It has
52+
# since been deleted, but fortunately it was just a clone of the svn
53+
# repository below.
54+
mkdir -p $REPO_DIR
55+
cd $REPO_DIR
5356
svn checkout -r 74720 https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root .
5457

58+
# Build and install
5559
mvn install -DskipTests
5660

57-
mkdir __dist__
58-
mkdir __dist__/webapps
59-
cp projects/web-client/target/alfresco-4.3.0-SNAPSHOT.war __dist__/webapps
60-
cp projects/slingshot/target/share-4.3.0-SNAPSHOT.war __dist__/webapps
61-
mkdir __dist__/lib
62-
cp projects/3rd-party/lib/devenv/mysql-connector-java-5.1.13-bin.jar __dist__/lib
63-
cp projects/3rd-party/lib/devenv/postgresql-9.3-1101-jdbc41.jar __dist__/lib
64-
cp projects/3rd-party/lib/j2ee/portlet_20.jar __dist__/lib
65-
cp projects/3rd-party/lib/xalan-2.7.0/xalan.jar __dist__/lib
66-
cp projects/3rd-party/lib/xalan-2.7.0/serializer.jar __dist__/lib
61+
# Deploy web apps
62+
mkdir -p $DEPLOY_DIR/webapps
63+
cp projects/web-client/target/alfresco-4.3.0-SNAPSHOT.war $DEPLOY_DIR/webapps
64+
cp projects/slingshot/target/share-4.3.0-SNAPSHOT.war $DEPLOY_DIR/webapps
65+
66+
# Deploy libraries
67+
mkdir $DEPLOY_DIR/lib
68+
cp projects/3rd-party/lib/devenv/mysql-connector-java-5.1.13-bin.jar $DEPLOY_DIR/lib
69+
cp projects/3rd-party/lib/devenv/postgresql-9.3-1101-jdbc41.jar $DEPLOY_DIR/lib
70+
cp projects/3rd-party/lib/j2ee/portlet_20.jar $DEPLOY_DIR/lib
71+
cp projects/3rd-party/lib/xalan-2.7.0/xalan.jar $DEPLOY_DIR/lib
72+
cp projects/3rd-party/lib/xalan-2.7.0/serializer.jar $DEPLOY_DIR/lib
6773

6874
cd ..
6975
fi
7076

71-
(cd $SECURITY_SCANNER_HOME && python3 $script_dir/../../driver/run.py -C $script_dir/AlfrescoRules.json -I $script_dir/Alfresco/__dist__/webapps/alfresco-4.3.0-SNAPSHOT.war -L $script_dir/Alfresco/__dist__/lib -R $script_dir/../../dist/GENUINE/Alfresco/RESULTS -T $script_dir/../../dist/GENUINE/Alfresco/TEMP --name Alfresco --verbosity 9 --use-models-library --use-apache-tomcat --do-not-use-precise-access-paths --rebuild --timeout 10000000 --entry-point org.alfresco.web.bean.ajax.PickerBean.getCategoryNodes)
77+
# Run security-analyser
78+
cd $SECURITY_SCANNER_HOME
7279

80+
python3 $SCRIPT_DIR/../../driver/run.py \
81+
-C $SCRIPT_DIR/AlfrescoRules.json \
82+
-I $DEPLOY_DIR/webapps/alfresco-4.3.0-SNAPSHOT.war \
83+
-L $DEPLOY_DIR/lib \
84+
-R $OUTPUT_DIR/Alfresco/results \
85+
-T $OUTPUT_DIR/Alfresco/temp \
86+
--name Alfresco \
87+
--use-models-library --use-apache-tomcat \
88+
--timeout 10000000 --verbosity 9 --rebuild \
89+
--do-not-use-precise-access-paths \
90+
--entry-point org.alfresco.web.bean.ajax.PickerBean.getCategoryNodes

benchmarks/GENUINE/CiteSeerX.sh

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
11
#!/usr/bin/env bash
22

3-
if [ $1 ]; then
4-
SECURITY_SCANNER_HOME=$1
5-
fi
6-
73
if [ -z "$SECURITY_SCANNER_HOME" ]; then
84
echo "Need to set SECURITY_SCANNER_HOME to cmake directory"
95
exit 1
106
fi
117

12-
SCRIPT_WORKING_DIR=$(pwd)
13-
REPO_DIR=$SCRIPT_WORKING_DIR/CiteSeerX
8+
# Stop script if a command does not succeed
9+
set -e
1410

15-
# Clone repo and check out a commit which builds (head of master)
16-
cd $REPO_DIR
17-
git clone https://github.com/SeerLabs/CiteSeerX.git .
18-
git checkout 8a62545ffc904f2b41b4ecd30ce91900dc7790f4
11+
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
12+
REPO_DIR=$SCRIPT_DIR/CiteSeerX
13+
DEPLOY_DIR=$REPO_DIR
14+
FILES_DIR=$SCRIPT_DIR/CiteSeerX_files
15+
if [ -z "$OUTPUT_DIR" ]; then
16+
OUTPUT_DIR=$SECURITY_SCANNER_HOME/GENUINE
17+
fi
1918

20-
# There are some example 'template' files that we need to rename to build correctly
21-
rename 's/\.template//' conf/*.template
19+
if [[ ! -d $REPO_DIR ]]; then
20+
# Clone repo and check out a commit which builds (head of master)
21+
mkdir -p $REPO_DIR
22+
cd $REPO_DIR
23+
git clone https://github.com/SeerLabs/CiteSeerX.git .
24+
git checkout 8a62545ffc904f2b41b4ecd30ce91900dc7790f4
2225

23-
# Apply the git patch to remove sanitization of query
24-
patch -p1 -f < $SCRIPT_WORKING_DIR/CiteSeerX_files/introduce_XXS_vulnerability.patch
26+
# Apply the git patch to remove sanitization of query
27+
patch -p1 -f < $FILES_DIR/introduce_XXS_vulnerability.patch
2528

26-
# Build
27-
ant
29+
# There are some example 'template' files that we need to rename to build correctly
30+
rename 's/\.template//' conf/*.template
31+
32+
# Build
33+
ant
34+
fi
2835

2936
# Run security-analyser
3037
cd $SECURITY_SCANNER_HOME
3138

32-
python3 $SCRIPT_WORKING_DIR/../../driver/run.py \
33-
-C $SCRIPT_WORKING_DIR/CiteSeerXRules.json \
34-
-I $REPO_DIR \
35-
-L $REPO_DIR \
36-
-R $SCRIPT_WORKING_DIR/CiteSeerX.results \
37-
-T $SCRIPT_WORKING_DIR/CiteSeerX.tmp \
38-
--name CiteSeerX --verbosity 9 \
39+
python3 $SCRIPT_DIR/../../driver/run.py \
40+
-C $SCRIPT_DIR/CiteSeerXRules.json \
41+
-I $DEPLOY_DIR \
42+
-L $DEPLOY_DIR \
43+
-R $OUTPUT_DIR/CiteSeerX/results \
44+
-T $OUTPUT_DIR/CiteSeerX/temp \
45+
--name CiteSeerX \
3946
--use-models-library \
40-
--timeout 10000000 \
41-
--entry-point edu.psu.citeseerx.web.SearchController.handleRequest \
47+
--timeout 10000000 --verbosity 9 --rebuild \
4248
--do-not-use-precise-access-paths \
43-
--dump-html-program \
44-
--dump-html-summaries \
45-
--dump-html-statistics \
46-
--rebuild \
49+
--entry-point edu.psu.citeseerx.web.SearchController.handleRequest

benchmarks/GENUINE/DSpace.sh

Lines changed: 42 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,54 @@ if [ -z "$SECURITY_SCANNER_HOME" ]; then
55
exit 1
66
fi
77

8-
set -u
9-
set -x
10-
11-
SCRIPT_WORKING_DIR=$(pwd)
12-
REPO_DIR=$SCRIPT_WORKING_DIR/DSpace
13-
14-
# 1. Open a terminal in the directory of this readme file and clone DSpace:
15-
16-
git clone https://github.com/DSpace/DSpace
17-
cd DSpace
18-
19-
# 2. (Optional) Checkout commit:
20-
21-
git checkout ed7d2980e264901bb60c63da183d620d49772f3e
22-
23-
# and in the file:
24-
# <this-dir>/DSpace/build.properties
25-
# update the variable 'dspace.install.dir' as follows:
26-
# dspace.install.dir=<this-dir>/DSpace/__dist__
27-
28-
echo dspace.install.dir=$REPO_DIR/__dist__ >> build.properties
29-
30-
# The checkout will give you a version with a fixed XSS issue. In order to
31-
# return the XSS issue back comment out lines 94-108 in file:
32-
# <this-dir>/DSpace/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/AbstractBrowserServlet.java
33-
# (NOTE: you can also check out the previous commit; but was not tested)
34-
35-
patch -p1 < $SCRIPT_WORKING_DIR/DSpace_files/introduce-xss-vulnerability.patch
36-
37-
# 3. Enter the directory '<this-dir>/DSpace' and type the following command:
8+
# Stop script if a command does not succeed
9+
set -e
10+
11+
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
12+
REPO_DIR=$SCRIPT_DIR/DSpace
13+
DEPLOY_DIR=$REPO_DIR
14+
FILES_DIR=$SCRIPT_DIR/DSpace_files
15+
if [ -z "$OUTPUT_DIR" ]; then
16+
OUTPUT_DIR=$SECURITY_SCANNER_HOME/GENUINE
17+
fi
3818

39-
mvn clean package
19+
if [[ ! -d $REPO_DIR ]]; then
20+
# Clone the repository and checkout a commit which builds
21+
mkdir -p $REPO_DIR
22+
cd $REPO_DIR
23+
git clone https://github.com/DSpace/DSpace .
24+
git checkout ed7d2980e264901bb60c63da183d620d49772f3e
4025

41-
# 4. Set the install directory (variable dspace.dir) in dspace/target/dspace-installer/config/dspace.cfg to
42-
# <this-dir>/DSpace/build.properties as above
26+
# Reintroduce the XSS issue
27+
patch -p1 < $FILES_DIR/introduce-xss-vulnerability.patch
4328

44-
sed -i "[email protected] = /[email protected] = $REPO_DIR/__dist__@" dspace/target/dspace-installer/config/dspace.cfg
29+
# Update 'dspace.install.dir'
30+
echo dspace.install.dir=$DEPLOY_DIR >> build.properties
4531

46-
# 5. Enter the directory '<this-dir>/DSpace/dspace/target/dspace-installer'
47-
# and type the following commands:
48-
# ant init_installation
49-
# ant init_configs
50-
# ant install_code
51-
# ant copy_webapps
32+
# Build and package
33+
mvn clean package
5234

53-
cd dspace/target/dspace-installer
54-
ant init_installation
55-
ant init_configs
56-
ant install_code
57-
ant copy_webapps
35+
# Set the install directory (variable 'dspace.dir')
36+
sed -i "[email protected] = /[email protected] = $DEPLOY_DIR@" dspace/target/dspace-installer/config/dspace.cfg
5837

59-
### Finally, analyse it:
38+
# install
39+
cd dspace/target/dspace-installer
40+
ant init_installation
41+
ant init_configs
42+
ant install_code
43+
ant copy_webapps
44+
fi
6045

46+
# Run security-analyser
6147
cd $SECURITY_SCANNER_HOME
6248

63-
python3 $SCRIPT_WORKING_DIR/../../driver/run.py \
64-
-C \
65-
$SCRIPT_WORKING_DIR/DSpace_rules.json \
66-
-I \
67-
$REPO_DIR/__dist__/webapps/jspui \
68-
-R \
69-
$SCRIPT_WORKING_DIR/DSpace-results \
70-
-T \
71-
$SCRIPT_WORKING_DIR/DSpace-tmp \
72-
--name \
73-
DSpace-jspui-BrowseServlet \
74-
--verbosity \
75-
10 \
76-
--use-models-library \
77-
--use-apache-tomcat \
78-
--use-spring-framework \
79-
--dump-html-statistics \
80-
--timeout \
81-
10000000 \
82-
--entry-point \
83-
org.dspace.app.webui.servlet.BrowserServlet.doDSGet \
84-
--do-not-use-precise-access-paths
49+
python3 $SCRIPT_DIR/../../driver/run.py \
50+
-C $SCRIPT_DIR/DSpace_rules.json \
51+
-I $DEPLOY_DIR/webapps/jspui \
52+
-R $OUTPUT_DIR/DSpace/results \
53+
-T $OUTPUT_DIR/DSpace/temp \
54+
--name DSpace-jspui-BrowseServlet \
55+
--use-models-library --use-apache-tomcat --use-spring-framework \
56+
--timeout 10000000 --verbosity 9 --rebuild \
57+
--do-not-use-precise-access-paths \
58+
--entry-point org.dspace.app.webui.servlet.BrowserServlet.doDSGet

benchmarks/GENUINE/Ginco.sh

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,65 @@
11
#!/usr/bin/env bash
22

33
if [ -z "$SECURITY_SCANNER_HOME" ]; then
4-
SECURITY_SCANNER_HOME=../../dist
5-
if [ ! -d "$SECURITY_SCANNER_HOME" ]; then
6-
echo "Need to set SECURITY_SCANNER_HOME to cmake directory"
7-
exit 1
8-
fi
9-
echo "SECURITY_SCANNER_HOME set to path: $SECURITY_SCANNER_HOME"
4+
echo "Need to set SECURITY_SCANNER_HOME to cmake directory"
5+
exit 1
106
fi
117

12-
if [[ ! -d "Ginco" ]]; then
13-
mkdir Ginco
14-
cd Ginco
8+
# Stop script if a command does not succeed
9+
set -e
1510

16-
git clone https://github.com/culturecommunication/ginco .
11+
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
12+
REPO_DIR=$SCRIPT_DIR/Ginco
13+
DEPLOY_DIR=$REPO_DIR/__dist__
14+
FILES_DIR=$SCRIPT_DIR/Ginco_files
15+
if [ -z "$OUTPUT_DIR" ]; then
16+
OUTPUT_DIR=$SECURITY_SCANNER_HOME/GENUINE
17+
fi
1718

18-
# This is the commit where the XSS issue was fixed: 2fb5a070034deda25b2d50a98e9e6b42754e6425
19-
# This is the subsequent commit mentioned in the README.txt file: fb937f67a78a1f01017cee3a12f4d79d325ec82f
20-
# Nevertheless, we do not checkout any of them. We actually checkout
21-
# latest 'master' branch on 2017-11-17 10:18:50.
19+
if [[ ! -d $REPO_DIR ]]; then
20+
# Clone the repository and check out a commit which builds (master branch on
21+
# 2017-11-17 10:18:50)
22+
mkdir -p $REPO_DIR
23+
cd $REPO_DIR
24+
git clone https://github.com/culturecommunication/ginco .
2225
git checkout e5b62450f61f76feccd2c2d5bf8ed33d1e258d87
2326

24-
patch -p1 -f < ../Ginco_files/0001-Reverting-XSS-issue-and-adding-generation-of-jar.patch
27+
# Reintroduce the XSS issue fixed in commit
28+
# 2fb5a070034deda25b2d50a98e9e6b42754e6425
29+
patch -p1 -f < $FILES_DIR/0001-Reverting-XSS-issue-and-adding-generation-of-jar.patch
2530

31+
# install
2632
mvn install -DskipTests
27-
28-
# Now we create an artificial entry-point project and build it
29-
cp -r ../Ginco_files/__MAIN__/ .
33+
34+
# Create an artificial entry-point project and build it
35+
cp -r $FILES_DIR/__MAIN__/ .
3036
mkdir -p __MAIN__/src/main/java/org/cprover
3137
cp ../../LIBRARIES/models/model/src/main/java/org/cprover/* __MAIN__/src/main/java/org/cprover
3238
(cd __MAIN__ && mvn package)
3339

34-
# Finally, we deploy built binaries to the deplyment directory '__dist__'
35-
mkdir -p __dist__/ginco-admin/{webapp,lib}
36-
mkdir -p __dist__/ginco-webservices/webapp
37-
cp __MAIN__/target/classes/Main.class __dist__/ginco-admin/webapp
40+
# Finally, we deploy built binaries to the deployment directory
41+
mkdir -p $DEPLOY_DIR/ginco-admin/webapp
42+
mkdir -p $DEPLOY_DIR/ginco-admin/lib
43+
mkdir -p $DEPLOY_DIR/ginco-webservices/webapp
44+
cp __MAIN__/target/classes/Main.class $DEPLOY_DIR/ginco-admin/webapp
3845
cp __MAIN__/target/classes/SKOSImportService.class __dist__/ginco-admin/webapp
3946
cp ginco-admin/target/ginco-admin-classes.jar __dist__/ginco-admin/lib
4047
cp ginco-webservices/target/ginco-webservices.war __dist__/ginco-webservices/webapp
4148

4249
cd ..
4350
fi
4451

45-
(cd $SECURITY_SCANNER_HOME && python3 ../driver/run.py -C ../benchmarks/GENUINE/GincoRules.json -I ../benchmarks/GENUINE/Ginco/__dist__/ginco-admin/webapp -L ../benchmarks/GENUINE/Ginco/__dist__/ginco-admin/lib -R GENUINE/Ginco/RESULTS -T GENUINE/Ginco/TEMP --name Ginco --verbosity 9 --use-models-library --do-not-use-precise-access-paths --rebuild --timeout 10000000 --entry-point Main.main)
52+
# Run security-analyser
53+
cd $SECURITY_SCANNER_HOME
4654

55+
python3 $SCRIPT_DIR/../../driver/run.py \
56+
-C $SCRIPT_DIR/GincoRules.json \
57+
-I $DEPLOY_DIR/ginco-admin/webapp \
58+
-L $DEPLOY_DIR/ginco-admin/lib \
59+
-R $OUTPUT_DIR/Ginco/results \
60+
-T $OUTPUT_DIR/Ginco/temp \
61+
--name Ginco \
62+
--use-models-library \
63+
--timeout 10000000 --verbosity 9 --rebuild \
64+
--do-not-use-precise-access-paths \
65+
--entry-point Main.main

0 commit comments

Comments
 (0)