Skip to content

Commit 44ac341

Browse files
committed
mitmproxy 12
1 parent a397e48 commit 44ac341

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

src/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ theme = "mitmproxy"
55
relativeURLs = true
66

77
[params]
8-
version = "11.1.0"
8+
version = "12.0.0"
99

1010
[indexes]
1111
tag = "tags"
824 KB
Binary file not shown.
16.6 KB
Loading

src/content/posts/releases/mitmproxy-12/index.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Mitmproxy 12: Interactive Contentviews"
3-
date: 2025-04-22
3+
date: 2025-04-29
44
weight: 10
55
tags:
66
- releases
@@ -26,7 +26,12 @@ Now, with interactive contentviews, you can directly edit the human-readable, pr
2626
and mitmproxy will handle the task of re-encoding it back into its binary form.
2727
This dramatically simplifies tinkering with unknown binary protocols such as gRPC/Protobuf or MsgPack.
2828

29-
(protobuf gif)
29+
<figure>
30+
<video controls>
31+
<source src="grpc.mp4" type="video/mp4">
32+
</video>
33+
<figcaption>Modifying a gRPC message on-the-fly (without knowing its schema).</figcaption>
34+
</figure>
3035

3136
[introduced in 2011]: https://github.com/mitmproxy/mitmproxy/commit/93ef691badcdaa1b7a5801eb40982c69f9b89534
3237
[#764]: https://github.com/mitmproxy/mitmproxy/pull/764
@@ -43,7 +48,9 @@ whether you have access to the Protobuf definitions (`.proto` files) or not.
4348
- **Unknown Protobufs:** You won't have field names, but you can still interactively modify primitive values
4449
(strings, integers, nested messages) and mitmproxy will re-encode your changes.
4550

46-
(screenshot of example gRPC with and without definitions)
51+
{{< figure src="grpc.png"
52+
alt="A screenshot of mitmproxy's gRPC rendering, both with and without protobuf definitions"
53+
caption="gRPC with (left) and without (right) Protobuf definitions." >}}
4754

4855
[`protobuf_definitions`]: https://docs.mitmproxy.org/stable/concepts/options/#protobuf_definitions
4956

@@ -52,27 +59,47 @@ whether you have access to the Protobuf definitions (`.proto` files) or not.
5259
Underpinning this interactivity is a revamped and drastically simpler Contentview API.
5360
Instead of returning a list of lines with inline markup,
5461
the new [`prettify`] method simply takes `bytes` and returns `str`, and then [`reencode`] does the reverse.
55-
As a simple example, here's what mitmproxy's builtin contentview for DNS messages looks like:
62+
As an example, here's a simple interactive contentview that dumps and parses data as hex:
5663

57-
(DNS example snippet)
64+
```python
65+
from mitmproxy import contentviews
5866

59-
Check out our [new contentview documentation] for more examples!
67+
class Hex(contentviews.InteractiveContentview):
68+
def prettify(
69+
self,
70+
data: bytes,
71+
metadata: contentviews.Metadata
72+
) -> str:
73+
return data.hex()
74+
75+
def reencode(
76+
self,
77+
prettified: str,
78+
metadata: contentviews.Metadata
79+
) -> bytes:
80+
return bytes.fromhex(prettified)
81+
82+
contentviews.add(Hex)
83+
```
84+
85+
Adding this to mitmproxy is as easy as `mitmproxy -s example.py`,
86+
please check out our [new contentview documentation] for more examples!
6087

6188
[`prettify`]: https://docs.mitmproxy.org/stable/api/mitmproxy/contentviews.html#Contentview.prettify
6289
[`reencode`]: https://docs.mitmproxy.org/stable/api/mitmproxy/contentviews.html#Contentview.reencode
6390
[new contentview documentation]: https://docs.mitmproxy.org/stable/addons/contentviews/
6491

65-
## Rust-based Contentviews
92+
## Rust-based Contentviews 🦀
6693

67-
With the new API, we're also increasing our investment in Rust to deliver safe and performant contentviews:
94+
With the new Contentview API, we're also increasing our investment in Rust:
6895

69-
- **Built-in contentviews can now also be written in Rust.** In fact, the gRPC, Protobuf, and MsgPack contentviews
70-
are all Rust-based. The [MsgPack implementation] is a great example to demonstrate how access to the crates.io
71-
ecosystem and the [serde] framework in particular makes writing contentviews super easy.
72-
- **Syntax highlighting is now done in Rust.** For mitmproxy and mitmweb, the [mitmproxy-highlight] crate does all the
73-
work (using [tree-sitter] under the hood).
96+
- **Contentviews can now be written in Rust.**
97+
Access to the crates.io ecosystem (and [Serde] in particular) makes it easy to write safe and performant
98+
contentviews. In fact, the new gRPC, Protobuf, and MsgPack contentviews are all Rust-based.
99+
- **Syntax highlighting is now done centrally in Rust.** For mitmproxy and mitmweb, the [mitmproxy-highlight] crate does
100+
all the work (using [tree-sitter] under the hood). Contentviews only need to declare their output format.
101+
This is much more efficient than the previous implementation, where every contentview had to do highlighting itself.
74102

75-
[MsgPack implementation]: https://github.com/mitmproxy/mitmproxy_rs/blob/5ec05682b122a2c1ee6584b4fe57a698eef573fd/mitmproxy-contentviews/src/msgpack.rs
76-
[serde]: https://serde.rs/
103+
[Serde]: https://serde.rs/
77104
[mitmproxy-highlight]: https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-highlight
78105
[tree-sitter]: https://tree-sitter.github.io/tree-sitter/

0 commit comments

Comments
 (0)