Skip to content

Commit e80999b

Browse files
authored
Merge pull request #44 from thc202/update-apis
Update/add APIs of add-ons
2 parents dc5c68a + 95e3208 commit e80999b

File tree

5 files changed

+87
-3
lines changed

5 files changed

+87
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

66
## [Unreleased]
77
### Added
8-
- Add API for WebSockets add-on, version 15.
8+
- Add API for Context Alert Filters add-on, version 8.
9+
- Add API for WebSockets add-on, version 19.
910
- Add API for SOAP Scanner add-on, version 3.
1011
### Changed
1112
- Minimum Python 3 version is now 3.4.
13+
- Update Selenium API, per release of version 15.0.0.
1214

1315
### Changed
1416
- Update core APIs for ZAP 2.8.0.

src/zapv2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
from .acsrf import acsrf
2929
from .alert import alert
30+
from .alertFilter import alertFilter
3031
from .ascan import ascan
3132
from .ajaxSpider import ajaxSpider
3233
from .authentication import authentication
@@ -82,6 +83,7 @@ def __init__(self, proxies=None, apikey=None, validate_status_code=False):
8283

8384
self.acsrf = acsrf(self)
8485
self.alert = alert(self)
86+
self.alertFilter = alertFilter(self)
8587
self.ajaxSpider = ajaxSpider(self)
8688
self.ascan = ascan(self)
8789
self.authentication = authentication(self)

src/zapv2/alertFilter.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 2019 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 alertFilter(object):
26+
27+
def __init__(self, zap):
28+
self.zap = zap
29+
30+
def alert_filter_list(self, contextid):
31+
"""
32+
Lists the alert filters of the context with the given ID.
33+
This component is optional and therefore the API will only work if it is installed
34+
"""
35+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'alertFilter/view/alertFilterList/', {'contextId': contextid})))
36+
37+
def add_alert_filter(self, contextid, ruleid, newlevel, url=None, urlisregex=None, parameter=None, enabled=None, apikey=''):
38+
"""
39+
Adds a new alert filter for the context with the given ID.
40+
This component is optional and therefore the API will only work if it is installed
41+
"""
42+
params = {'contextId': contextid, 'ruleId': ruleid, 'newLevel': newlevel, 'apikey': apikey}
43+
if url is not None:
44+
params['url'] = url
45+
if urlisregex is not None:
46+
params['urlIsRegex'] = urlisregex
47+
if parameter is not None:
48+
params['parameter'] = parameter
49+
if enabled is not None:
50+
params['enabled'] = enabled
51+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'alertFilter/action/addAlertFilter/', params)))
52+
53+
def remove_alert_filter(self, contextid, ruleid, newlevel, url=None, urlisregex=None, parameter=None, enabled=None, apikey=''):
54+
"""
55+
Removes an alert filter from the context with the given ID.
56+
This component is optional and therefore the API will only work if it is installed
57+
"""
58+
params = {'contextId': contextid, 'ruleId': ruleid, 'newLevel': newlevel, 'apikey': apikey}
59+
if url is not None:
60+
params['url'] = url
61+
if urlisregex is not None:
62+
params['urlIsRegex'] = urlisregex
63+
if parameter is not None:
64+
params['parameter'] = parameter
65+
if enabled is not None:
66+
params['enabled'] = enabled
67+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'alertFilter/action/removeAlertFilter/', params)))

src/zapv2/selenium.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def option_firefox_driver_path(self):
5454
@property
5555
def option_ie_driver_path(self):
5656
"""
57-
Returns the current path to IEDriverServer
5857
This component is optional and therefore the API will only work if it is installed
5958
"""
6059
return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/view/optionIeDriverPath/')))
@@ -90,7 +89,6 @@ def set_option_firefox_driver_path(self, string, apikey=''):
9089

9190
def set_option_ie_driver_path(self, string, apikey=''):
9291
"""
93-
Sets the current path to IEDriverServer
9492
This component is optional and therefore the API will only work if it is installed
9593
"""
9694
return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/action/setOptionIeDriverPath/', {'String': string, 'apikey': apikey})))

src/zapv2/websocket.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,24 @@ def messages(self, channelid=None, start=None, count=None, payloadpreviewlength=
5858
params['payloadPreviewLength'] = payloadpreviewlength
5959
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/view/messages/', params)))
6060

61+
@property
62+
def break_text_message(self):
63+
"""
64+
Returns a text representation of an intercepted websockets message
65+
This component is optional and therefore the API will only work if it is installed
66+
"""
67+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/view/breakTextMessage/')))
68+
6169
def send_text_message(self, channelid, outgoing, message, apikey=''):
6270
"""
6371
Sends the specified message on the channel specified by channelId, if outgoing is 'True' then the message will be sent to the server and if it is 'False' then it will be sent to the client
6472
This component is optional and therefore the API will only work if it is installed
6573
"""
6674
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/action/sendTextMessage/', {'channelId': channelid, 'outgoing': outgoing, 'message': message, 'apikey': apikey})))
75+
76+
def set_break_text_message(self, message, outgoing, apikey=''):
77+
"""
78+
Sets the text message for an intercepted websockets message
79+
This component is optional and therefore the API will only work if it is installed
80+
"""
81+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/action/setBreakTextMessage/', {'message': message, 'outgoing': outgoing, 'apikey': apikey})))

0 commit comments

Comments
 (0)