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
2 changes: 2 additions & 0 deletions src/zapv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .params import params
from .pnh import pnh
from .pscan import pscan
from .replacer import replacer
from .reveal import reveal
from .script import script
from .search import search
Expand Down Expand Up @@ -90,6 +91,7 @@ def __init__(self, proxies=None, apikey=None):
self.params = params(self)
self.pnh = pnh(self)
self.pscan = pscan(self)
self.replacer = replacer(self)
self.reveal = reveal(self)
self.script = script(self)
self.search = search(self)
Expand Down
60 changes: 60 additions & 0 deletions src/zapv2/replacer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Zed Attack Proxy (ZAP) and its related class files.
#
# ZAP is an HTTP/HTTPS proxy for assessing web application security.
#
# Copyright 2017 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 replacer(object):

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

@property
def rules(self):
"""
Returns full details of all of the rules
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 + 'replacer/view/rules/')))

def add_rule(self, description, enabled, matchtype, matchregex, matchstring, replacement, initiators=None, apikey=''):
"""
Adds a replacer rule. For the parameters: desc is a user friendly description, enabled is true or false, matchType is one of [REQ_HEADER, REQ_HEADER_STR, REQ_BODY_STR, RESP_HEADER, RESP_HEADER_STR, RESP_BODY_STR], matchRegex should be true if the matchString should be treated as a regex otherwise false, matchString is the string that will be matched against, replacement is the replacement string, initiators may be blank (for all initiators) or a comma separated list of integers as defined in <a href="https://github.com/zaproxy/zaproxy/blob/develop/src/org/parosproxy/paros/network/HttpSender.java">HttpSender</a>
This component is optional and therefore the API will only work if it is installed
"""
params = {'description': description, 'enabled': enabled, 'matchType': matchtype, 'matchRegex': matchregex, 'matchString': matchstring, 'replacement': replacement, 'apikey': apikey}
if initiators is not None:
params['initiators'] = initiators
return six.next(six.itervalues(self.zap._request(self.zap.base + 'replacer/action/addRule/', params)))

def remove_rule(self, description, apikey=''):
"""
Removes the rule with the given description
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 + 'replacer/action/removeRule/', {'description': description, 'apikey': apikey})))

def set_enabled(self, description, bool, apikey=''):
"""
Enables or disables the rule with the given description based on the bool parameter
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 + 'replacer/action/setEnabled/', {'description': description, 'bool': bool, 'apikey': apikey})))