-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
334 lines (268 loc) · 9.58 KB
/
build.xml
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<project basedir="." default="compile">
<!-- This file contains all of the environment specific configuration, change it for your setup -->
<property file="local.properties"/>
<dirname file="${ant.file}" property="bodgeit.home"/>
<path id="java.classpath">
<fileset dir="root/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<fileset dir="build/WEB-INF/classes">
<include name="*.class" />
</fileset>
<pathelement location="build/WEB-INF/classes"/>
</path>
<target name="hack">
<echo message="file=$(ant.file) home=${ant.home} bodge=${bodgeit.home}"/>
</target>
<!-- Compile all of the source code -->
<target name="compile">
<!-- Compile the java code -->
<javac target="1.5" destdir="build/WEB-INF/classes" srcdir="src" classpathref="java.classpath" />
</target>
<target name="build" depends="compile">
<copy toDir="build"><fileset dir="root" includes="**/*"/></copy>
<delete file="build/bodgeit.war"/>
<war destfile="build/bodgeit.war" webxml="root/WEB-INF/web.xml">
<fileset dir="build"/>
</war>
</target>
<target name="deploy" depends="build">
<delete dir="${deploy.dir}/bodgeit"/>
<copy file="build/bodgeit.war" tofile="${deploy.dir}/bodgeit.war"/>
</target>
<target name="deploy-jsps">
<copy toDir="${deploy.dir}/bodgeit">
<fileset dir="root">
<include name="*.jsp" />
<include name="*.css" />
<include name="**/*.png" />
</fileset>
</copy>
</target>
<target name="test">
<!-- Run the JUnit tests -->
<junit printsummary="yes">
<classpath>
<fileset dir="root/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<pathelement location="bin"/>
</classpath>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="build/tests">
<fileset dir="src">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="zap-proxy-tests">
<!-- Run the standard tests -->
<junit printsummary="yes" fork="yes">
<sysproperty key="zap.proxy" value="${zap.addr}:${zap.port}"/>
<sysproperty key="zap.targetApp" value="${zap.targetApp}"/>
<classpath>
<fileset dir="root/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<pathelement location="bin"/>
</classpath>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="build/tests">
<fileset dir="src">
<include name="**/FunctionalZAP.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="zap-spider">
<java classname="org.zaproxy.clientapi.core.ClientApiMain">
<arg value="spider"/>
<arg value="url=${zap.targetApp}"/>
<arg value="zapaddr=${zap.addr}"/>
<arg value="zapport=${zap.port}"/>
<arg value="debug=true"/>
<classpath>
<fileset dir="lib">
<include name="zap-api*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="zap-ascan">
<java classname="org.zaproxy.clientapi.core.ClientApiMain">
<arg value="activeScanSubtree"/>
<arg value="url=${zap.targetApp}"/>
<arg value="zapaddr=${zap.addr}"/>
<arg value="zapport=${zap.port}"/>
<arg value="debug=true"/>
<classpath>
<fileset dir="lib">
<include name="zap-api*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="zap-saveSession">
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd-HH-mm-ss"/>
</tstamp>
<java classname="org.zaproxy.clientapi.core.ClientApiMain">
<arg value="saveSession"/>
<arg value="sessionName=${basedir}/bodgeit-${timestamp}"/>
<arg value="zapaddr=${zap.addr}"/>
<arg value="zapport=${zap.port}"/>
<arg value="debug=true"/>
<classpath>
<fileset dir="lib">
<include name="zap-api*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="zap-showAlerts">
<java classname="org.zaproxy.clientapi.core.ClientApiMain" failonerror="true">
<arg value="showAlerts"/>
<arg value="zapaddr=${zap.addr}"/>
<arg value="zapport=${zap.port}"/>
<arg value="debug=true"/>
<classpath>
<fileset dir="lib">
<include name="zap-api*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="zap-checkAlerts">
<!-- alertsFile.xml should fail while allAlertsFile.xml should succeed -->
<property name="alertsfile" value="${bodgeit.home}/alertsFile.xml"/>
<java classname="org.zaproxy.clientapi.core.ClientApiMain" failonerror="true">
<arg value="checkAlerts"/>
<arg value="alertsFile=${alertsfile}"/>
<arg value="zapaddr=${zap.addr}"/>
<arg value="zapport=${zap.port}"/>
<arg value="debug=true"/>
<classpath>
<fileset dir="lib">
<include name="zap-api*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="zap-stop">
<java classname="org.zaproxy.clientapi.core.ClientApiMain">
<arg value="stop"/>
<arg value="zapaddr=${zap.addr}"/>
<arg value="zapport=${zap.port}"/>
<arg value="debug=true"/>
<classpath>
<fileset dir="lib">
<include name="zap-api*.jar" />
</fileset>
</classpath>
</java>
</target>
<target name="zap-test-daemon"
description="Starts ZAP as a daemon, run the Bodgeit tests through it and then scan for vulnerabilities">
<!-- Your servlet engine must be running when you start this test -->
<!-- Start ZAP in background -->
<ant antfile="zap-build.xml" target="startZapDaemon" inheritAll="false"/>
<antcall target="zap-test"/>
</target>
<target name="zap-test-ui"
description="Starts the ZAP UI, run the Bodgeit tests through it and then scan for vulnerabilities">
<!-- Your servlet engine must be running when you start this test -->
<!-- Start ZAP with UI -->
<ant antfile="zap-build.xml" target="startZap" inheritAll="false"/>
<antcall target="zap-test"/>
</target>
<target name="zap-test"
description="Runs the Bodgeit tests through ZAP (which must be running) and then scan for vulnerabilities">
<!-- ZAP must be running when you start this test -->
<antcall target="zap-proxy-tests"/>
<sleep seconds="5"/>
<!-- Spider the whole site -->
<antcall target="zap-spider"/>
<sleep seconds="5"/>
<!-- Active scan the whole site -->
<antcall target="zap-ascan"/>
<sleep seconds="3"/>
<!-- Save to a timestamped session file -->
<antcall target="zap-saveSession"/>
<!-- Give the passive scanner thread a chance to catch up -->
<sleep seconds="5"/>
<!-- Check the alerts logged -->
<antcall target="zap-checkAlerts"/>
<!--
Note that if the above test fails ZAP will not be stopped, so you will need to call the zap-stop target directly.
-->
<!-- Stop ZAP -->
<antcall target="zap-stop"/>
</target>
<target name="zap-test-tasks-daemon"
description="Starts ZAP as a daemon, run the Bodgeit tests through it and then scan for vulnerabilities using Ant tasks">
<!-- Your servlet engine must be running when you start this test -->
<!--
You must also have configured Eclipse to use the ZAP client jar as per the
instructions in zap-build.xml
-->
<!-- Start ZAP in background -->
<ant antfile="zap-build.xml" target="startZapDaemon" inheritAll="false"/>
<antcall target="zap-test-tasks"/>
</target>
<target name="zap-test-tasks-ui"
description="Starts the ZAP UI, run the Bodgeit tests through it and then scan for vulnerabilities using Ant tasks">
<!-- Your servlet engine must be running when you start this test -->
<!--
You must also have configured Eclipse to use the ZAP client jar as per the
instructions in zap-build.xml
-->
<!-- Start ZAP with UI -->
<ant antfile="zap-build.xml" target="startZap" inheritAll="false"/>
<antcall target="zap-test-tasks"/>
</target>
<target name="zap-test-tasks"
description="Runs the Bodgeit tests through ZAP (which must be running) and then scan for vulnerabilities using Ant tasks">
<!-- ZAP must be running when you start this test -->
<!--
You must also have configured Eclipse to use the ZAP client jar as per the
instructions in zap-build.xml
-->
<antcall target="zap-proxy-tests"/>
<sleep seconds="5"/>
<!-- Spider the whole site -->
<ant antfile="zap-build.xml" target="spider" inheritAll="false"/>
<sleep seconds="5"/>
<!-- Active scan the whole site -->
<ant antfile="zap-build.xml" target="activescan" inheritAll="false"/>
<sleep seconds="3"/>
<!-- Save to a timestamped session file -->
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd-HH-mm-ss"/>
</tstamp>
<ant antfile="zap-build.xml" target="savesession" inheritAll="false">
<!-- Override the session name -->
<property name="zap.session" value="${bodgeit.home}/build/bodgeit-${timestamp}"/>
</ant>
<!-- Give the passive scanner thread a chance to catch up -->
<sleep seconds="5"/>
<!-- Check the alerts logged -->
<ant antfile="zap-build.xml" target="alertcheck" inheritAll="false"/>
<!--
Note that if the above test fails ZAP will not be stopped, so you will need to call the stopZap target directly.
-->
<!-- Stop ZAP -->
<ant antfile="zap-build.xml" target="stopZap" inheritAll="false"/>
</target>
</project>