Skip to content

Commit 923cf24

Browse files
Add support for 'method' parameter in Replacer 'add_rule' (#164)
Signed-off-by: Arran Cardnell <arran.cardnell@intruder.io>
1 parent 4e9d778 commit 923cf24

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

CHANGELOG.md

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

66
## [Unreleased]
77

8+
### Changed
9+
- Added support for 'method' parameter on Replacer 'add_rule'
10+
811
## [0.5.0] - 2025-12-15
912
### Added
1013
- Add the APIs of the following add-ons:

src/zapv2/replacer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# ZAP is an HTTP/HTTPS proxy for assessing web application security.
44
#
5-
# Copyright 2025 the ZAP development team
5+
# Copyright 2026 the ZAP development team
66
#
77
# Licensed under the Apache License, Version 2.0 (the "License");
88
# you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ def rules(self):
3535
"""
3636
return six.next(six.itervalues(self.zap._request(self.zap.base + 'replacer/view/rules/')))
3737

38-
def add_rule(self, description, enabled, matchtype, matchregex, matchstring, replacement=None, initiators=None, url=None, apikey=''):
38+
def add_rule(self, description, enabled, matchtype, matchregex, matchstring, replacement=None, initiators=None, url=None, method=None, apikey=''):
3939
"""
4040
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://www.zaproxy.org/docs/constants/">Request Initiator Constants</a>
4141
This component is optional and therefore the API will only work if it is installed
@@ -47,6 +47,8 @@ def add_rule(self, description, enabled, matchtype, matchregex, matchstring, rep
4747
params['initiators'] = initiators
4848
if url is not None:
4949
params['url'] = url
50+
if method is not None:
51+
params['method'] = method
5052
return six.next(six.itervalues(self.zap._request(self.zap.base + 'replacer/action/addRule/', params)))
5153

5254
def remove_rule(self, description, apikey=''):

0 commit comments

Comments
 (0)