|
| 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 2017 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 replacer(object): |
| 26 | + |
| 27 | + def __init__(self, zap): |
| 28 | + self.zap = zap |
| 29 | + |
| 30 | + @property |
| 31 | + def rules(self): |
| 32 | + """ |
| 33 | + Returns full details of all of the rules |
| 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 + 'replacer/view/rules/'))) |
| 37 | + |
| 38 | + def add_rule(self, description, enabled, matchtype, matchregex, matchstring, replacement, initiators=None, apikey=''): |
| 39 | + """ |
| 40 | + 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> |
| 41 | + This component is optional and therefore the API will only work if it is installed |
| 42 | + """ |
| 43 | + params = {'description': description, 'enabled': enabled, 'matchType': matchtype, 'matchRegex': matchregex, 'matchString': matchstring, 'replacement': replacement, 'apikey': apikey} |
| 44 | + if initiators is not None: |
| 45 | + params['initiators'] = initiators |
| 46 | + return six.next(six.itervalues(self.zap._request(self.zap.base + 'replacer/action/addRule/', params))) |
| 47 | + |
| 48 | + def remove_rule(self, description, apikey=''): |
| 49 | + """ |
| 50 | + Removes the rule with the given description |
| 51 | + This component is optional and therefore the API will only work if it is installed |
| 52 | + """ |
| 53 | + return six.next(six.itervalues(self.zap._request(self.zap.base + 'replacer/action/removeRule/', {'description': description, 'apikey': apikey}))) |
| 54 | + |
| 55 | + def set_enabled(self, description, bool, apikey=''): |
| 56 | + """ |
| 57 | + Enables or disables the rule with the given description based on the bool parameter |
| 58 | + This component is optional and therefore the API will only work if it is installed |
| 59 | + """ |
| 60 | + return six.next(six.itervalues(self.zap._request(self.zap.base + 'replacer/action/setEnabled/', {'description': description, 'bool': bool, 'apikey': apikey}))) |
0 commit comments