Skip to content

Commit 6e991c6

Browse files
committed
Update APIs of add-ons and core
Update `fileUpload` to use the expected HTTP method. Add/update the APIs of the following add-ons: - Custom Payloads version 0.13.0 - Selenium version 15.16.0 Signed-off-by: thc202 <[email protected]>
1 parent b5d021d commit 6e991c6

File tree

4 files changed

+201
-1
lines changed

4 files changed

+201
-1
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

66
## [Unreleased]
7+
### Added
8+
* Add the API of the following add-on:
9+
* Custom Payloads version 0.13.0.
10+
711
### Changed
812
* Allow to call the ZAP API with custom HTTP method (e.g. file upload).
13+
* Update the APIs of the following add-on:
14+
* Selenium version 15.16.0.
15+
16+
### Fixed
17+
* Correct the HTTP method used by `fileUpload` core API.
918

1019
## [2.0.0-rc.3] - 2023-10-14
1120
### Changed

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ Core.prototype.fileDownload = function (args) {
881881
* @param {string} filecontents - The contents of the file.
882882
**/
883883
Core.prototype.fileUpload = function (args) {
884-
return this.api.request('/core/other/fileUpload/', { fileName: args.filename, fileContents: args.filecontents }, 'other')
884+
return this.api.request('/core/other/fileUpload/', { fileName: args.filename, fileContents: args.filecontents }, 'other', 'POST')
885885
}
886886

887887
module.exports = Core

src/custompayloads.js

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/* Zed Attack Proxy (ZAP) and its related class files.
2+
*
3+
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
4+
*
5+
* Copyright 2023 the ZAP development team
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
'use strict'
21+
22+
/**
23+
* This file was automatically generated.
24+
*/
25+
function Custompayloads (clientApi) {
26+
this.api = clientApi
27+
}
28+
29+
/**
30+
* Lists all available categories.
31+
* This component is optional and therefore the API will only work if it is installed
32+
**/
33+
Custompayloads.prototype.customPayloadsCategories = function () {
34+
return this.api.request('/custompayloads/view/customPayloadsCategories/')
35+
}
36+
37+
/**
38+
* Lists all the payloads currently loaded (category, payload, enabled state). Optionally filtered by category.
39+
* This component is optional and therefore the API will only work if it is installed
40+
* @param {string} category - The category for which the payloads should be displayed.
41+
**/
42+
Custompayloads.prototype.customPayloads = function (args) {
43+
const params = { }
44+
if (args.category && args.category !== null) {
45+
params.category = args.category
46+
}
47+
return this.api.request('/custompayloads/view/customPayloads/', params)
48+
}
49+
50+
/**
51+
* Disables payloads for a given category.
52+
* This component is optional and therefore the API will only work if it is installed
53+
* @param {string} category - The category for which the payloads should be disabled (leave empty for all).
54+
**/
55+
Custompayloads.prototype.disableCustomPayloads = function (args) {
56+
const params = { }
57+
if (args.category && args.category !== null) {
58+
params.category = args.category
59+
}
60+
return this.api.request('/custompayloads/action/disableCustomPayloads/', params)
61+
}
62+
63+
/**
64+
* Enables payloads for a given category.
65+
* This component is optional and therefore the API will only work if it is installed
66+
* @param {string} category - The category for which the payloads should be enabled (leave empty for all).
67+
**/
68+
Custompayloads.prototype.enableCustomPayloads = function (args) {
69+
const params = { }
70+
if (args.category && args.category !== null) {
71+
params.category = args.category
72+
}
73+
return this.api.request('/custompayloads/action/enableCustomPayloads/', params)
74+
}
75+
76+
/**
77+
* Removes a payload.
78+
* This component is optional and therefore the API will only work if it is installed
79+
* @param {string} category - The category of the payload being removed.
80+
* @param {string} payload - The payload being removed.
81+
**/
82+
Custompayloads.prototype.removeCustomPayload = function (args) {
83+
const params = { category: args.category }
84+
if (args.payload && args.payload !== null) {
85+
params.payload = args.payload
86+
}
87+
return this.api.request('/custompayloads/action/removeCustomPayload/', params)
88+
}
89+
90+
/**
91+
* Adds a new payload.
92+
* This component is optional and therefore the API will only work if it is installed
93+
* @param {string} category - The category for the new payload.
94+
* @param {string} payload - The payload to be added.
95+
**/
96+
Custompayloads.prototype.addCustomPayload = function (args) {
97+
const params = { category: args.category }
98+
if (args.payload && args.payload !== null) {
99+
params.payload = args.payload
100+
}
101+
return this.api.request('/custompayloads/action/addCustomPayload/', params)
102+
}
103+
104+
/**
105+
* Enables a given payload.
106+
* This component is optional and therefore the API will only work if it is installed
107+
* @param {string} category - The category for the payload being enabled.
108+
* @param {string} payload - The payload being enabled.
109+
**/
110+
Custompayloads.prototype.enableCustomPayload = function (args) {
111+
const params = { category: args.category }
112+
if (args.payload && args.payload !== null) {
113+
params.payload = args.payload
114+
}
115+
return this.api.request('/custompayloads/action/enableCustomPayload/', params)
116+
}
117+
118+
/**
119+
* Disables a given payload.
120+
* This component is optional and therefore the API will only work if it is installed
121+
* @param {string} category - The category for the payload being disabled.
122+
* @param {string} payload - The payload being disabled.
123+
**/
124+
Custompayloads.prototype.disableCustomPayload = function (args) {
125+
const params = { category: args.category }
126+
if (args.payload && args.payload !== null) {
127+
params.payload = args.payload
128+
}
129+
return this.api.request('/custompayloads/action/disableCustomPayload/', params)
130+
}
131+
132+
module.exports = Custompayloads

src/selenium.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ Selenium.prototype.optionFirefoxBinaryPath = function () {
5757
return this.api.request('/selenium/view/optionFirefoxBinaryPath/')
5858
}
5959

60+
/**
61+
* This component is optional and therefore the API will only work if it is installed
62+
**/
63+
Selenium.prototype.optionFirefoxDefaultProfile = function () {
64+
return this.api.request('/selenium/view/optionFirefoxDefaultProfile/')
65+
}
66+
6067
/**
6168
* Returns the current path to Firefox driver (geckodriver)
6269
* This component is optional and therefore the API will only work if it is installed
@@ -86,6 +93,15 @@ Selenium.prototype.optionPhantomJsBinaryPath = function () {
8693
return this.api.request('/selenium/view/optionPhantomJsBinaryPath/')
8794
}
8895

96+
/**
97+
* Gets the browser arguments.
98+
* This component is optional and therefore the API will only work if it is installed
99+
* @param {string} browser - The browser, chrome or firefox.
100+
**/
101+
Selenium.prototype.getBrowserArguments = function (args) {
102+
return this.api.request('/selenium/view/getBrowserArguments/', { browser: args.browser })
103+
}
104+
89105
/**
90106
* Sets the current path to Chrome binary
91107
* This component is optional and therefore the API will only work if it is installed
@@ -113,6 +129,13 @@ Selenium.prototype.setOptionFirefoxBinaryPath = function (args) {
113129
return this.api.request('/selenium/action/setOptionFirefoxBinaryPath/', { String: args.string })
114130
}
115131

132+
/**
133+
* This component is optional and therefore the API will only work if it is installed
134+
**/
135+
Selenium.prototype.setOptionFirefoxDefaultProfile = function (args) {
136+
return this.api.request('/selenium/action/setOptionFirefoxDefaultProfile/', { String: args.string })
137+
}
138+
116139
/**
117140
* Sets the current path to Firefox driver (geckodriver)
118141
* This component is optional and therefore the API will only work if it is installed
@@ -143,4 +166,40 @@ Selenium.prototype.setOptionPhantomJsBinaryPath = function (args) {
143166
return this.api.request('/selenium/action/setOptionPhantomJsBinaryPath/', { String: args.string })
144167
}
145168

169+
/**
170+
* Adds a browser argument.
171+
* This component is optional and therefore the API will only work if it is installed
172+
* @param {string} browser - The browser, chrome or firefox.
173+
* @param {string} argument - The argument.
174+
* @param {string} enabled - The enabled state, true or false.
175+
**/
176+
Selenium.prototype.addBrowserArgument = function (args) {
177+
const params = { browser: args.browser, argument: args.argument }
178+
if (args.enabled && args.enabled !== null) {
179+
params.enabled = args.enabled
180+
}
181+
return this.api.request('/selenium/action/addBrowserArgument/', params)
182+
}
183+
184+
/**
185+
* Removes a browser argument.
186+
* This component is optional and therefore the API will only work if it is installed
187+
* @param {string} browser - The browser, chrome or firefox.
188+
* @param {string} argument - The argument.
189+
**/
190+
Selenium.prototype.removeBrowserArgument = function (args) {
191+
return this.api.request('/selenium/action/removeBrowserArgument/', { browser: args.browser, argument: args.argument })
192+
}
193+
194+
/**
195+
* Sets whether or not a browser argument is enabled.
196+
* This component is optional and therefore the API will only work if it is installed
197+
* @param {string} browser - The browser, chrome or firefox.
198+
* @param {string} argument - The argument.
199+
* @param {string} enabled - The enabled state, true or false.
200+
**/
201+
Selenium.prototype.setBrowserArgumentEnabled = function (args) {
202+
return this.api.request('/selenium/action/setBrowserArgumentEnabled/', { browser: args.browser, argument: args.argument, enabled: args.enabled })
203+
}
204+
146205
module.exports = Selenium

0 commit comments

Comments
 (0)