Skip to content

Commit 04e6368

Browse files
authored
Merge pull request #521 from psiinon/api-file-xfer
API File Transfer help
2 parents 5b80ba8 + 4a83b0c commit 04e6368

File tree

2 files changed

+51
-0
lines changed
  • addOns/help/src/main/javahelp/contents

2 files changed

+51
-0
lines changed

addOns/help/src/main/javahelp/contents/start/features/api.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,41 @@ <H1>API</H1>
2828
Future versions of ZAP will increase the functionality available via the APi.
2929
</p>
3030

31+
<H2><a name="filexfer">File Transfer</a></H2>
32+
33+
Many API endpoints allow you to load or save files to and from the file system.
34+
<p>
35+
The core API also supports uploading and downloading files, but this is disabled by default as a security measure.
36+
If an attacker is able to access the ZAP API then with this feature enabled they would be able to upload their own script to
37+
ZAP and then run it. ZAP scripts run with the same permissions as ZAP and so this is full remote code execution access.
38+
<p>
39+
To enable file transfer you will need to have an API key set and to enable it via the
40+
<a href="../../ui/dialogs/options/api.html#filexferenabled">Options API screen</a>.
41+
You can also enable file transfers via the command line as explained in the help for that screen.
42+
<p>
43+
With file transfer enabled you will be able to upload text files to the
44+
<a href="../../ui/dialogs/options/api.html#xferdir">Transfer Directory</a> using the 'fileUpload' 'other' endpoint
45+
and download them from there using the 'fileDownload' 'other' endpoint.
46+
You can specify subdirectories (e.g. "subdir/myfile") but any attempt to upload or download a file to or from another directory
47+
(e.g. using "../../") will be rejected.
48+
The 'fileUpload' endpoint only accepts POST requests and you should use an encoding of either "multipart/form-data" or "application/x-www-form-urlencoded".
49+
The web UI allows you to select and upload local files.
50+
<p>
51+
Curl example for uploading a file:
52+
<pre>
53+
curl \
54+
-F fileContents=@/full/path/to/file/to/be/uploaded \
55+
-F apikey=your-api-key \
56+
-F fileName=destination-filename \
57+
http://localhost:8080/OTHER/core/other/fileUpload/
58+
</pre>
59+
<p>
60+
To download a file generated by another API endpoint you will need to specify a file name/path starting with "${XFER}".
61+
For example you could export a context to "${XFER}/contexts/my.context" and then download it by specifying "contexts/my.context".
62+
<p>
63+
To upload a file to another API endpoint you need to do the reverse - first upload it, e.g. to "plans/myplan.yaml", and
64+
then import it via the path "${XFER}/plans/myplan.yaml".
65+
3166

3267
<H2>See also</H2>
3368
<table>

addOns/help/src/main/javahelp/contents/ui/dialogs/options/api.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ <H3>Secure Only</H3>
2424

2525
If enabled then the API will only be available via HTTPS. Otherwise it will be available via both HTTP and HTTPS.<br/>
2626

27+
<H3><a name="filexferenabled">File Transfer Enabled</a></H3>
28+
29+
If enabled then files can be transfered to and from ZAP via the API.
30+
This option is only available if the API key is <i>not</i> disabled.
31+
For more details see <a href="../../../start/features/api.html#filexfer">File Transfer</a>.
32+
<p>
33+
You can also enable this option via the command line using the parameter: <code>-config api.filexfer=true</code>
34+
35+
<H3><a name="xferdir">Transfer Directory</a></H3>
36+
37+
The directory used to transfer files to and from ZAP via the API.
38+
This option is only available if the API key is <i>not</i> disabled.
39+
For more details see <a href="../../../start/features/api.html#filexfer">File Transfer</a>.
40+
<p>
41+
You can also set the Transfer Directory via the command line using: <code>-config api.xferdir=/full/path/to/dir</code>
42+
2743
<H3>API Key</H3>
2844

2945
A key that must be specified on all API 'actions' and some 'other' operations.<br/>

0 commit comments

Comments
 (0)