Skip to content

Commit 0b75204

Browse files
committed
Revert "Remove @before wrapper in favour of parsing args,kwargs"
This reverts commit 5650510.
1 parent 257cc7e commit 0b75204

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

aikido_zen/sinks/http_client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@
33
"""
44

55
from aikido_zen.helpers.get_argument import get_argument
6-
from aikido_zen.sinks import after, patch_function, on_import
6+
from aikido_zen.sinks import before, after, patch_function, on_import
77
from aikido_zen.vulnerabilities.ssrf.handle_http_response import (
88
handle_http_response,
99
)
1010
from aikido_zen.helpers.try_parse_url import try_parse_url
1111

1212

13+
@before
14+
def _putrequest(func, instance, args, kwargs):
15+
path = get_argument(args, kwargs, 1, "path")
16+
setattr(instance, "_aikido_var_path", path)
17+
18+
1319
@after
1420
def _getresponse(func, instance, args, kwargs, return_value):
15-
path = get_argument(args, kwargs, 1, "path")
21+
path = getattr(instance, "_aikido_var_path")
1622
source_url = try_parse_url(f"http://{instance.host}:{instance.port}{path}")
1723
handle_http_response(http_response=return_value, source=source_url)
1824

@@ -21,6 +27,8 @@ def _getresponse(func, instance, args, kwargs, return_value):
2127
def patch(m):
2228
"""
2329
patching module http.client
24-
- patches HTTPConnection.getresponse
30+
- patches HTTPConnection.putrequest -> stores path
31+
- patches HTTPConnection.getresponse -> handles response object
2532
"""
33+
patch_function(m, "HTTPConnection.putrequest", _putrequest)
2634
patch_function(m, "HTTPConnection.getresponse", _getresponse)

0 commit comments

Comments
 (0)