From 25bdf2f9d8469a03447883cd37dcf67fde768d26 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 8 Oct 2021 18:34:51 +0200 Subject: [PATCH] web: update filters --- mitmproxy/addons/view.py | 2 +- mitmproxy/tools/web/app.py | 1 + test/mitmproxy/tools/web/test_app.py | 1 + web/src/js/__tests__/ducks/_tflow.ts | 2 + web/src/js/filt/filt.js | Bin 77559 -> 87312 bytes web/src/js/filt/filt.peg | 187 +++++++++++++++++++-------- web/src/js/flow.ts | 1 + 7 files changed, 142 insertions(+), 52 deletions(-) diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index b3b6e4f5a..4d7d750a2 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -330,7 +330,7 @@ class View(collections.abc.Sequence): self.set_filter(filt) def set_filter(self, flt: typing.Optional[flowfilter.TFilter]): - self.filter = flt or matchall + self.filter = flt or flowfilter.match_all self._refilter() # View Updates diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py index 9deba965e..8746c7e8e 100644 --- a/mitmproxy/tools/web/app.py +++ b/mitmproxy/tools/web/app.py @@ -58,6 +58,7 @@ def flow_to_json(flow: mitmproxy.flow.Flow) -> dict: "type": flow.type, "modified": flow.modified(), "marked": emoji.get(flow.marked, "🔴") if flow.marked else "", + "comment": flow.comment, } if flow.client_conn: diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 99cbb61bd..ae4ee0414 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -48,6 +48,7 @@ def test_generate_tflow_js(tdata): ] tf_http.request.trailers = Headers(trailer="qvalue") tf_http.response.trailers = Headers(trailer="qvalue") + tf_http.comment = "I'm a comment!" tf_tcp = tflow.ttcpflow(err=True) tf_tcp.id = "2ea7012b-21b5-4f8f-98cd-d49819954001" diff --git a/web/src/js/__tests__/ducks/_tflow.ts b/web/src/js/__tests__/ducks/_tflow.ts index f2685e1cc..072d78e4a 100644 --- a/web/src/js/__tests__/ducks/_tflow.ts +++ b/web/src/js/__tests__/ducks/_tflow.ts @@ -22,6 +22,7 @@ export function THTTPFlow(): Required { "tls_established": true, "tls_version": "TLSv1.2" }, + "comment": "I'm a comment!", "error": { "msg": "error", "timestamp": 946681207.0 @@ -180,6 +181,7 @@ export function TTCPFlow(): Required { "tls_established": true, "tls_version": "TLSv1.2" }, + "comment": "", "error": { "msg": "error", "timestamp": 946681207.0 diff --git a/web/src/js/filt/filt.js b/web/src/js/filt/filt.js index 4131311bc133a5a93356dca1f1d350f340ee5d15..3b7699362bed6a7183cb5f493de82605a729c8e7 100644 GIT binary patch delta 5887 zcmb_gdvsLgwO`-KYch{yGS5shnK?575;7r~Gm|$26GR?%0fAcRrAS^34++UkW)SMC zAzr<RGl}qawDhUOF&b=c*|5dewT{3*p|b))ui5t6dc>p`{O(3f=oVXC@PH zb$Qpi`6F}A_w8?gzx~_4z0dj1U(e-^Ka-dEP?I~-J1_v3G=AlxS8EmU{)o#0U4@Pu zK37z#2{eiAqIaYh#tZ$>t@XjBLI*slt zpJ)T{psp6?=p671ok!ECOhlnu7XV4`gX20U?A5z9!4^K#4_9>(Oyb0?dJi}aWd=zZ zAKJAmG#G=&^nrZ!@{Hb^$1lNCWP^|Oj)H!5rc-B4HX1hOLY2t|6D1zlYzo5rB}LF` z*1jp5?CKrf85*YGg=RmTF_-46Bj`%gtU%ZWlO_pHmehdH zT*M>IHI-|c8#ulQgv}B#vkxZC2HdC4(9Fk&L*aqmuSP&`k@A&mq{CW}9wxT8SseQQ zfgKp#I&KV?ib`R^QlJ_|;rladC4G8rl!I*vzyh;f9}NxP9vaSC-fk^OZ@1i<*|}G1 zNsrRThpdkDEpDl8Q8FDJ?uU1*5tw$166{P4C(gkK?=QAaUPM}<{{(~f+r zcVzcxSl?w9q0e3;;KE6>0}k0sakpkTX?Njo3v_DTaMj+1*R4b;tSj~8NNCIQydal4 z+>%5<>NkI-%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