Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

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

### Changed
- Update core APIs for ZAP 2.8.0.
Expand Down
2 changes: 2 additions & 0 deletions src/zapv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from .acsrf import acsrf
from .alert import alert
from .alertFilter import alertFilter
from .ascan import ascan
from .ajaxSpider import ajaxSpider
from .authentication import authentication
Expand Down Expand Up @@ -82,6 +83,7 @@ def __init__(self, proxies=None, apikey=None, validate_status_code=False):

self.acsrf = acsrf(self)
self.alert = alert(self)
self.alertFilter = alertFilter(self)
self.ajaxSpider = ajaxSpider(self)
self.ascan = ascan(self)
self.authentication = authentication(self)
Expand Down
67 changes: 67 additions & 0 deletions src/zapv2/alertFilter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Zed Attack Proxy (ZAP) and its related class files.
#
# ZAP is an HTTP/HTTPS proxy for assessing web application security.
#
# Copyright 2019 the ZAP development team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This file was automatically generated.
"""

import six


class alertFilter(object):

def __init__(self, zap):
self.zap = zap

def alert_filter_list(self, contextid):
"""
Lists the alert filters of the context with the given ID.
This component is optional and therefore the API will only work if it is installed
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'alertFilter/view/alertFilterList/', {'contextId': contextid})))

def add_alert_filter(self, contextid, ruleid, newlevel, url=None, urlisregex=None, parameter=None, enabled=None, apikey=''):
"""
Adds a new alert filter for the context with the given ID.
This component is optional and therefore the API will only work if it is installed
"""
params = {'contextId': contextid, 'ruleId': ruleid, 'newLevel': newlevel, 'apikey': apikey}
if url is not None:
params['url'] = url
if urlisregex is not None:
params['urlIsRegex'] = urlisregex
if parameter is not None:
params['parameter'] = parameter
if enabled is not None:
params['enabled'] = enabled
return six.next(six.itervalues(self.zap._request(self.zap.base + 'alertFilter/action/addAlertFilter/', params)))

def remove_alert_filter(self, contextid, ruleid, newlevel, url=None, urlisregex=None, parameter=None, enabled=None, apikey=''):
"""
Removes an alert filter from the context with the given ID.
This component is optional and therefore the API will only work if it is installed
"""
params = {'contextId': contextid, 'ruleId': ruleid, 'newLevel': newlevel, 'apikey': apikey}
if url is not None:
params['url'] = url
if urlisregex is not None:
params['urlIsRegex'] = urlisregex
if parameter is not None:
params['parameter'] = parameter
if enabled is not None:
params['enabled'] = enabled
return six.next(six.itervalues(self.zap._request(self.zap.base + 'alertFilter/action/removeAlertFilter/', params)))
2 changes: 0 additions & 2 deletions src/zapv2/selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def option_firefox_driver_path(self):
@property
def option_ie_driver_path(self):
"""
Returns the current path to IEDriverServer
This component is optional and therefore the API will only work if it is installed
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/view/optionIeDriverPath/')))
Expand Down Expand Up @@ -90,7 +89,6 @@ def set_option_firefox_driver_path(self, string, apikey=''):

def set_option_ie_driver_path(self, string, apikey=''):
"""
Sets the current path to IEDriverServer
This component is optional and therefore the API will only work if it is installed
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'selenium/action/setOptionIeDriverPath/', {'String': string, 'apikey': apikey})))
Expand Down
15 changes: 15 additions & 0 deletions src/zapv2/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,24 @@ def messages(self, channelid=None, start=None, count=None, payloadpreviewlength=
params['payloadPreviewLength'] = payloadpreviewlength
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/view/messages/', params)))

@property
def break_text_message(self):
"""
Returns a text representation of an intercepted websockets message
This component is optional and therefore the API will only work if it is installed
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/view/breakTextMessage/')))

def send_text_message(self, channelid, outgoing, message, apikey=''):
"""
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
This component is optional and therefore the API will only work if it is installed
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/action/sendTextMessage/', {'channelId': channelid, 'outgoing': outgoing, 'message': message, 'apikey': apikey})))

def set_break_text_message(self, message, outgoing, apikey=''):
"""
Sets the text message for an intercepted websockets message
This component is optional and therefore the API will only work if it is installed
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'websocket/action/setBreakTextMessage/', {'message': message, 'outgoing': outgoing, 'apikey': apikey})))