From 9cb51928a16786aba9fe4d67aee43c05fb7a6ce8 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Thu, 23 Jan 2020 13:45:21 -0500 Subject: [PATCH] proper passthru of non-matching requests --- .../roles/mitmproxy/files/bubble_modify.py | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/automation/roles/mitmproxy/files/bubble_modify.py b/automation/roles/mitmproxy/files/bubble_modify.py index 5be107f0..02fc1ea6 100644 --- a/automation/roles/mitmproxy/files/bubble_modify.py +++ b/automation/roles/mitmproxy/files/bubble_modify.py @@ -63,20 +63,22 @@ def responseheaders(flow): device = flow.request.headers[HEADER_BUBBLE_DEVICE] if HEADER_CONTENT_TYPE in flow.response.headers: content_type = flow.response.headers[HEADER_CONTENT_TYPE ] + if matchers: + # flow.response.stream = filter_with_matchers(matchers) + bubble_log("responseheaders: contentType="+repr(content_type) + +", req_id=" + req_id + + ", device=" + device + + ", matchers: " + repr(json.loads(matchers))) + flow.response.stream = bubble_modify(req_id, + content_type, + device, + matchers) + else: + bubble_log("responseheaders: no matchers, passing thru") + pass else: - content_type = 'application/octet-stream' - bubble_log("responseheaders: "+HEADER_CONTENT_TYPE +" header not found in: "+repr(flow.response.headers)) - if matchers: - # flow.response.stream = filter_with_matchers(matchers) - bubble_log("responseheaders: contentType="+repr(content_type) - +", req_id=" + req_id - + ", device=" + device - + ", matchers: " + repr(json.loads(matchers))) - flow.response.stream = bubble_modify(req_id, - content_type, - device, - matchers) - else: + bubble_log("responseheaders: no "+HEADER_CONTENT_TYPE +" header, passing thru") pass else: + bubble_log("responseheaders: no "+HEADER_BUBBLE_MATCHERS +" header, passing thru") pass