Skip to content

Commit 58700ac

Browse files
authored
Merge pull request #103 from thc202/update-apis
Update APIs of add-ons and core
2 parents e5a53ed + 015e153 commit 58700ac

File tree

7 files changed

+184
-4
lines changed

7 files changed

+184
-4
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

6-
## [Unreleased]
6+
## [0.3.0] - 2024-05-09
7+
### Added
8+
- Add the API of the following add-on:
9+
- Custom Payloads version 0.13.0.
10+
11+
### Changed
12+
- Update core APIs for 2.15.
13+
714
### Fixed
815
- Return the whole response from `users.get_user_by_id`.
916

@@ -164,7 +171,7 @@ ensure it's automatically sent in all API requests.
164171
### Changed
165172
- Moved from the main `zaproxy` repository.
166173

167-
[Unreleased]: https://github.com/zaproxy/zap-api-python/compare/0.2.0...HEAD
174+
[0.3.0]: https://github.com/zaproxy/zap-api-python/compare/0.2.0...0.3.0
168175
[0.2.0]: https://github.com/zaproxy/zap-api-python/compare/0.1.1...0.2.0
169176
[0.1.1]: https://github.com/zaproxy/zap-api-python/compare/0.1.0...0.1.1
170177
[0.1.0]: https://github.com/zaproxy/zap-api-python/compare/0.0.22...0.1.0

src/zapv2/ajaxSpider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def set_option_browser_id(self, string, apikey=''):
271271

272272
def set_option_click_default_elems(self, boolean, apikey=''):
273273
"""
274-
Sets whether or not the the AJAX Spider will only click on the default HTML elements.
274+
Sets whether or not the AJAX Spider will only click on the default HTML elements.
275275
This component is optional and therefore the API will only work if it is installed
276276
"""
277277
return six.next(six.itervalues(self.zap._request(self.zap.base + 'ajaxSpider/action/setOptionClickDefaultElems/', {'Boolean': boolean})))

src/zapv2/ascan.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ def option_allow_attack_on_start(self):
240240
"""
241241
return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionAllowAttackOnStart/')))
242242

243+
@property
244+
def option_encode_cookie_values(self):
245+
"""
246+
Tells whether or not the active scanner should encode cookie values.
247+
"""
248+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/view/optionEncodeCookieValues/')))
249+
243250
@property
244251
def option_inject_plugin_id_in_header(self):
245252
"""
@@ -572,6 +579,12 @@ def set_option_delay_in_ms(self, integer, apikey=''):
572579
"""
573580
return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionDelayInMs/', {'Integer': integer})))
574581

582+
def set_option_encode_cookie_values(self, boolean, apikey=''):
583+
"""
584+
Sets whether or not the active scanner should encode cookie values.
585+
"""
586+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'ascan/action/setOptionEncodeCookieValues/', {'Boolean': boolean})))
587+
575588
def set_option_handle_anti_csrf_tokens(self, boolean, apikey=''):
576589
"""
577590

src/zapv2/core.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ def number_of_alerts(self, baseurl=None, riskid=None):
225225
params['riskId'] = riskid
226226
return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/numberOfAlerts/', params)))
227227

228+
def get_log_level(self, name=None):
229+
"""
230+
The detailed logging config, optionally filtered based on a name (ex: starts with).
231+
"""
232+
params = {}
233+
if name is not None:
234+
params['name'] = name
235+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/view/getLogLevel/', params)))
236+
228237
@property
229238
def option_default_user_agent(self):
230239
"""
@@ -534,6 +543,12 @@ def delete_alert(self, id, apikey=''):
534543
"""
535544
return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/deleteAlert/', {'id': id})))
536545

546+
def set_log_level(self, name, loglevel, apikey=''):
547+
"""
548+
Sets the logging level for a given logger name.
549+
"""
550+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'core/action/setLogLevel/', {'name': name, 'logLevel': loglevel})))
551+
537552
def set_option_default_user_agent(self, string, apikey=''):
538553
"""
539554
Sets the user agent that ZAP should use when creating HTTP messages (for example, spider messages or CONNECT requests to outgoing proxy).

src/zapv2/custompayloads.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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 2024 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+
This file was automatically generated.
20+
"""
21+
22+
import six
23+
24+
25+
class custompayloads(object):
26+
27+
def __init__(self, zap):
28+
self.zap = zap
29+
30+
@property
31+
def custom_payloads_categories(self):
32+
"""
33+
Lists all available categories.
34+
This component is optional and therefore the API will only work if it is installed
35+
"""
36+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/view/customPayloadsCategories/')))
37+
38+
def custom_payloads(self, category=None):
39+
"""
40+
Lists all the payloads currently loaded (category, payload, enabled state). Optionally filtered by category.
41+
This component is optional and therefore the API will only work if it is installed
42+
"""
43+
params = {}
44+
if category is not None:
45+
params['category'] = category
46+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/view/customPayloads/', params)))
47+
48+
def disable_custom_payloads(self, category=None, apikey=''):
49+
"""
50+
Disables payloads for a given category.
51+
This component is optional and therefore the API will only work if it is installed
52+
"""
53+
params = {}
54+
if category is not None:
55+
params['category'] = category
56+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/action/disableCustomPayloads/', params)))
57+
58+
def enable_custom_payloads(self, category=None, apikey=''):
59+
"""
60+
Enables payloads for a given category.
61+
This component is optional and therefore the API will only work if it is installed
62+
"""
63+
params = {}
64+
if category is not None:
65+
params['category'] = category
66+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/action/enableCustomPayloads/', params)))
67+
68+
def remove_custom_payload(self, category, payload=None, apikey=''):
69+
"""
70+
Removes a payload.
71+
This component is optional and therefore the API will only work if it is installed
72+
"""
73+
params = {'category': category}
74+
if payload is not None:
75+
params['payload'] = payload
76+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/action/removeCustomPayload/', params)))
77+
78+
def add_custom_payload(self, category, payload=None, apikey=''):
79+
"""
80+
Adds a new payload.
81+
This component is optional and therefore the API will only work if it is installed
82+
"""
83+
params = {'category': category}
84+
if payload is not None:
85+
params['payload'] = payload
86+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/action/addCustomPayload/', params)))
87+
88+
def enable_custom_payload(self, category, payload=None, apikey=''):
89+
"""
90+
Enables a given payload.
91+
This component is optional and therefore the API will only work if it is installed
92+
"""
93+
params = {'category': category}
94+
if payload is not None:
95+
params['payload'] = payload
96+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/action/enableCustomPayload/', params)))
97+
98+
def disable_custom_payload(self, category, payload=None, apikey=''):
99+
"""
100+
Disables a given payload.
101+
This component is optional and therefore the API will only work if it is installed
102+
"""
103+
params = {'category': category}
104+
if payload is not None:
105+
params['payload'] = payload
106+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'custompayloads/action/disableCustomPayload/', params)))

src/zapv2/search.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ def urls_by_url_regex(self, regex, baseurl=None, start=None, count=None):
4040
params['count'] = count
4141
return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/urlsByUrlRegex/', params)))
4242

43+
def urls_by_tag_regex(self, regex, baseurl=None, start=None, count=None):
44+
"""
45+
Returns the URLs of the HTTP messages that match the given regular expression in their history Tags optionally filtered by URL and paginated with 'start' position and 'count' of messages.
46+
"""
47+
params = {'regex': regex}
48+
if baseurl is not None:
49+
params['baseurl'] = baseurl
50+
if start is not None:
51+
params['start'] = start
52+
if count is not None:
53+
params['count'] = count
54+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/urlsByTagRegex/', params)))
55+
4356
def urls_by_request_regex(self, regex, baseurl=None, start=None, count=None):
4457
"""
4558
Returns the URLs of the HTTP messages that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages.
@@ -92,6 +105,19 @@ def messages_by_url_regex(self, regex, baseurl=None, start=None, count=None):
92105
params['count'] = count
93106
return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/messagesByUrlRegex/', params)))
94107

108+
def messages_by_tag_regex(self, regex, baseurl=None, start=None, count=None):
109+
"""
110+
Returns the HTTP messages that match the given regular expression in their history Tags optionally filtered by URL and paginated with 'start' position and 'count' of messages.
111+
"""
112+
params = {'regex': regex}
113+
if baseurl is not None:
114+
params['baseurl'] = baseurl
115+
if start is not None:
116+
params['start'] = start
117+
if count is not None:
118+
params['count'] = count
119+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'search/view/messagesByTagRegex/', params)))
120+
95121
def messages_by_request_regex(self, regex, baseurl=None, start=None, count=None):
96122
"""
97123
Returns the HTTP messages that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages.
@@ -144,6 +170,19 @@ def har_by_url_regex(self, regex, baseurl=None, start=None, count=None, apikey='
144170
params['count'] = count
145171
return (self.zap._request_other(self.zap.base_other + 'search/other/harByUrlRegex/', params))
146172

173+
def har_by_tag_regex(self, regex, baseurl=None, start=None, count=None, apikey=''):
174+
"""
175+
Returns the HTTP messages, in HAR format, that match the given regular expression in their history Tags optionally filtered by URL and paginated with 'start' position and 'count' of messages.
176+
"""
177+
params = {'regex': regex}
178+
if baseurl is not None:
179+
params['baseurl'] = baseurl
180+
if start is not None:
181+
params['start'] = start
182+
if count is not None:
183+
params['count'] = count
184+
return (self.zap._request_other(self.zap.base_other + 'search/other/harByTagRegex/', params))
185+
147186
def har_by_request_regex(self, regex, baseurl=None, start=None, count=None, apikey=''):
148187
"""
149188
Returns the HTTP messages, in HAR format, that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages.

src/zapv2/wappalyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, zap):
3030
@property
3131
def list_sites(self):
3232
"""
33-
Lists all the sites recognized by the wappalyzer addon.
33+
Lists all the sites recognized by the Technology Detection add-on.
3434
This component is optional and therefore the API will only work if it is installed
3535
"""
3636
return six.next(six.itervalues(self.zap._request(self.zap.base + 'wappalyzer/view/listSites/')))

0 commit comments

Comments
 (0)