Kaynağa Gözat

always pass user_agent for proper redis key construction

pull/43/head
Jonathan Cobb 4 yıl önce
ebeveyn
işleme
67c3705c1a
1 değiştirilmiş dosya ile 9 ekleme ve 9 silme
  1. +9
    -9
      bubble-server/src/main/resources/packer/roles/mitmproxy/files/bubble_modify.py

+ 9
- 9
bubble-server/src/main/resources/packer/roles/mitmproxy/files/bubble_modify.py Dosyayı Görüntüle

@@ -22,7 +22,7 @@ STANDARD_FILTER_HEADERS = {HEADER_CONTENT_TYPE: CONTENT_TYPE_BINARY}
REDIS_FILTER_PASSTHRU_PREFIX = '__chunk_filter_pass__'
REDIS_FILTER_PASSTHRU_DURATION = 600

def filter_chunk(flow, chunk, req_id, last, content_encoding=None, content_type=None, user_agent=None, content_length=None, csp=None):
def filter_chunk(flow, chunk, req_id, user_agent, last, content_encoding=None, content_type=None, content_length=None, csp=None):
if debug_capture_fqdn:
host = None
if flow.client_conn.tls_established:
@@ -49,7 +49,7 @@ def filter_chunk(flow, chunk, req_id, last, content_encoding=None, content_type=
redis_passthru_key = REDIS_FILTER_PASSTHRU_PREFIX + flow.request.method + '~~~' + user_agent + ':' + flow.request.url
do_pass = REDIS.get(redis_passthru_key)
if do_pass:
# bubble_log('filter_chunk: req_id='+req_id+': passthru found in redis, returning chunk')
bubble_log('filter_chunk: req_id='+req_id+': passthru found in redis, returning chunk')
REDIS.touch(redis_passthru_key)
return chunk

@@ -94,7 +94,7 @@ def filter_chunk(flow, chunk, req_id, last, content_encoding=None, content_type=
return response.content


def bubble_filter_chunks(flow, chunks, req_id, content_encoding, content_type, user_agent, csp):
def bubble_filter_chunks(flow, chunks, req_id, user_agent, content_encoding, content_type, csp):
"""
chunks is a generator that can be used to iterate over all chunks.
"""
@@ -111,20 +111,20 @@ def bubble_filter_chunks(flow, chunks, req_id, content_encoding, content_type, u
else:
last = False
if first:
yield filter_chunk(flow, chunk, req_id, last, content_encoding, content_type, user_agent, content_length, csp)
yield filter_chunk(flow, chunk, req_id, user_agent, last, content_encoding, content_type, content_length, csp)
first = False
else:
yield filter_chunk(flow, chunk, req_id, last)
yield filter_chunk(flow, chunk, req_id, user_agent, last)
if not content_length:
yield filter_chunk(flow, None, req_id, True) # get the last bits of data
yield filter_chunk(flow, None, req_id, user_agent, True) # get the last bits of data
except Exception as e:
bubble_log('bubble_filter_chunks: exception='+repr(e))
traceback.print_exc()
yield None


def bubble_modify(flow, req_id, content_encoding, content_type, user_agent, csp):
return lambda chunks: bubble_filter_chunks(flow, chunks, req_id, content_encoding, content_type, user_agent, csp)
def bubble_modify(flow, req_id, user_agent, content_encoding, content_type, csp):
return lambda chunks: bubble_filter_chunks(flow, chunks, req_id, user_agent, content_encoding, content_type, csp)


def send_bubble_response(response):
@@ -205,7 +205,7 @@ def responseheaders(flow):

content_length_value = flow.response.headers.pop(HEADER_CONTENT_LENGTH, None)
bubble_log(prefix+'content_encoding='+repr(content_encoding) + ', content_type='+repr(content_type))
flow.response.stream = bubble_modify(flow, req_id, content_encoding, content_type, user_agent, csp)
flow.response.stream = bubble_modify(flow, req_id, user_agent, content_encoding, content_type, csp)
if content_length_value:
flow.response.headers['transfer-encoding'] = 'chunked'
# find server_conn to set fake_chunks on


Yükleniyor…
İptal
Kaydet