-
Notifications
You must be signed in to change notification settings - Fork 29
/
entrypoint.sh
executable file
·247 lines (207 loc) · 6.35 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!/bin/sh -l
#required parameters
appname=$1
createprofile=$2
filepath=$3
version=$4
vid=$5
vkey=$6
#optional parameters
createsandbox=$7
sandboxname=$8
scantimeout=$9
exclude=${10}
include=${11}
criticality=${12}
pattern=${13}
replacement=${14}
sandboxid=${15}
scanallnonfataltoplevelmodules=${16}
selected=${17}
selectedpreviously=${18}
teams=${19}
toplevel=${20}
deleteincompletescan=${21}
echo "Required Information"
echo "===================="
echo "appname: $appname"
echo "createprofile: $createprofile"
echo "filepath: $filepath"
echo "version: $version"
if [ "$vid" ]
then
echo "vid: ***"
else
echo "vid:"
fi
if [ "$vkey" ]
then
echo "vkey: ***"
else
echo "vkey:"
fi
echo ""
echo "Optional Information"
echo "===================="
echo "createsandbox: $createsandbox"
echo "sandboxname: $8"
echo "scantimeout: $9"
echo "exclude: ${10}"
echo "include: ${11}"
echo "criticality: ${12}"
echo "pattern: ${13}"
echo "replacement: ${14}"
echo "sandboxid: ${15}"
echo "scanallnonfataltoplevelmodules: ${16}"
echo "selected: ${17}"
echo "selectedpreviously: ${18}"
echo "teams: ${19}"
echo "toplevel: ${20}"
echo "deleteincompletescan: ${21}"
#Check if required parameters are set
if [ -z "$appname" ] || [ -z "$createprofile" ] || [ -z "$filepath" ] || [ -z "$version" ] || [ -z "$vid" ] || [ -z "$vkey" ]
then
echo "Missing required parameter. Please check that all required parameters are set"
exit 1
fi
#required wrapper command
echo "#!/bin/sh -l" > runJava.sh
echo ""
echo "java -jar VeracodeJavaAPI.jar \\
-filepath $filepath \\
-version \"$version\" \\
-action \"uploadandscan\" \\
-appname \"$appname\" \\
-vid \"$vid\" \\
-vkey \"$vkey\" \\" >> runJava.sh
#create additioanl commands on optional input
if [ "$createsandbox" == true ]
then
echo " -createsandbox=\"true\" \\" >> runJava.sh
elif [ "$createsandbox" == false ]
then
echo " -createsandbox=\"false\" \\" >> runJava.sh
fi
if [ "$sandboxname" ]
then
if [ "$sandboxid" ]
then
echo "ERRRO: sandboxname cannot go together with sandboxid"
exit 1
else
echo " -sandboxname \"$sandboxname\" \\" >> runJava.sh
fi
fi
if [ "$scantimeout" ]
then
echo " -scantimeout \"$scantimeout\" \\" >> runJava.sh
fi
if [ "$exclude" ]
then
if [ "$selectedpreviously" ] || [ "$toplevel" ] || [ "$selected" ] || [ "$selectedpreviously" ]
then
echo "ERROR: exclude cannot go together with selectedpreviously, toplevel, selected, selectedpreviously"
exit 1
else
echo " -exclude \"$exclude\" \\" >> runJava.sh
fi
fi
if [ "$include" ]
then
if [ "$selectedpreviously" ] || [ "$toplevel" ] || [ "$selected" ] || [ "$selectedpreviously" ]
then
echo "ERROR: include cannot go together with selectedpreviously, toplevel, selected, selectedpreviously"
exit 1
else
echo " -include \"$include\" \\" >> runJava.sh
fi
fi
if [ -z "$include" ] && [ -z "$exclude" ]
then
echo " -autoscan \"true\" \\" >> runJava.sh
fi
if [ "$criticality" ]
then
echo " -criticality \"$criticality\" \\" >> runJava.sh
fi
if [ "$pattern" ]
then
if [ "$replacement" ]
then
echo " -pattern \"$pattern\" \\" >> runJava.sh
else
echo "ERROR: pattern always need the replacement parameter as well"
exit 1
fi
fi
if [ "$replacement" ]
then
if [ "$pattern" ]
then
echo " -replacement \"$replacement\" \\" >> runJava.sh
else
echo "ERROR: replacement always need the pattern parameter as well"
exit 1
fi
fi
if [ "$sandboxid" ]
then
if [ "$sandboxname" ]
then
echo "ERROR: sandboxid cannot got together with sandboxname"
exit 1
else
echo " -sandboxid \"$sandboxid\" \\" >> runJava.sh
fi
fi
if [ "$scanallnonfataltoplevelmodules" ]
then
echo " -scanallnonfataltoplevelmodules \"$scanallnonfataltoplevelmodules\" \\" >> runJava.sh
fi
if [ "$selected" ]
then
if [ "$selectedpreviously" ] || [ "$toplevel" ] || [ "$scanallnonfataltoplevelmodules" ] || [ "$exclude" ] || [ "$include" ]
then
echo "ERROR: selected cannot go together with selectedpreviously, toplevel, scanallnonfataltoplevelmodules, exclude, include"
exit 1
else
echo " -selectedpreviously \"$selectedpreviously\" \\" >> runJava.sh
fi
fi
if [ "$selectedpreviously" ]
then
if [ "$selected" ] || [ "$toplevel" ] || [ "$scanallnonfataltoplevelmodules" ] || [ "$exclude" ] || [ "$include" ]
then
echo "ERROR: selectedpreviously cannot go together with selected, toplevel, scanallnonfataltoplevelmodules, exclude, include"
exit 1
else
echo " -selectedpreviously \"$selectedpreviously\" \\" >> runJava.sh
fi
fi
if [ "$teams" ]
then
echo " -teams \"$teams\" \\" >> runJava.sh
fi
if [ "$toplevel" ]
then
if [ "$selected" ] || [ "$selectedpreviously" ] || [ "$scanallnonfataltoplevelmodules" ] || [ "$exclude" ] || [ "$include" ]
then
echo "ERROR: toplevel cannot go together with selected, selectedpreviously, scanallnonfataltoplevelmodules, exclude, include"
exit 1
else
echo " -toplevel \"$toplevel\" \\" >> runJava.sh
fi
fi
if [ "$deleteincompletescan" ]
then
echo " -deleteincompletescan \"$deleteincompletescan\" \\" >> runJava.sh
fi
echo " -createprofile \"$createprofile\"" >> runJava.sh
#below pulls latest wrapper version. alternative is to pin a version like so:
#javawrapperversion=21.5.7.7
javawrapperversion=$(curl https://repo1.maven.org/maven2/com/veracode/vosp/api/wrappers/vosp-api-wrappers-java/maven-metadata.xml | grep latest | cut -d '>' -f 2 | cut -d '<' -f 1)
#echo "javawrapperversion: $javawrapperversion"
curl -sS -o VeracodeJavaAPI.jar "https://repo1.maven.org/maven2/com/veracode/vosp/api/wrappers/vosp-api-wrappers-java/$javawrapperversion/vosp-api-wrappers-java-$javawrapperversion.jar"
chmod 777 runJava.sh
cat runJava.sh
./runJava.sh