Skip to content

Commit a397e48

Browse files
committed
add draft blog post for mitmproxy 12
1 parent 4f7509b commit a397e48

File tree

1 file changed

+78
-0
lines changed
  • src/content/posts/releases/mitmproxy-12

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: "Mitmproxy 12: Interactive Contentviews"
3+
date: 2025-04-22
4+
weight: 10
5+
tags:
6+
- releases
7+
authors:
8+
- maximilian-hils
9+
---
10+
11+
We're thrilled to announce the release of mitmproxy 12, introducing *Interactive Contentviews*!
12+
It's now possible to modify the prettified representation of binary protocols,
13+
which is then re-encoded back into the original binary format.
14+
15+
<!--more-->
16+
17+
# Interactive Contentviews
18+
19+
First [introduced in 2011], the ability to pretty-print HTTP message bodies has been a mitmproxy feature
20+
since the very early days.
21+
The functionality later became a shared component between the console and web interfaces
22+
in 2015 ([#764]), soon followed by support for custom user-provided views ([#833]).
23+
However, these views were always read-only; editing binary protocols meant changing raw bytes.
24+
25+
Now, with interactive contentviews, you can directly edit the human-readable, prettified representation,
26+
and mitmproxy will handle the task of re-encoding it back into its binary form.
27+
This dramatically simplifies tinkering with unknown binary protocols such as gRPC/Protobuf or MsgPack.
28+
29+
(protobuf gif)
30+
31+
[introduced in 2011]: https://github.com/mitmproxy/mitmproxy/commit/93ef691badcdaa1b7a5801eb40982c69f9b89534
32+
[#764]: https://github.com/mitmproxy/mitmproxy/pull/764
33+
[#833]: https://github.com/mitmproxy/mitmproxy/pull/832
34+
35+
## Spotlight: gRPC & Protobuf
36+
37+
The prime example of interactive contentviews is our enhanced gRPC and Protobuf support.
38+
You can now modify Protobuf messages directly within mitmproxy,
39+
whether you have access to the Protobuf definitions (`.proto` files) or not.
40+
41+
- **Known Protobufs:** Set the new [`protobuf_definitions`] option in mitmproxy to your `.proto` file
42+
and edit fields by name.
43+
- **Unknown Protobufs:** You won't have field names, but you can still interactively modify primitive values
44+
(strings, integers, nested messages) and mitmproxy will re-encode your changes.
45+
46+
(screenshot of example gRPC with and without definitions)
47+
48+
[`protobuf_definitions`]: https://docs.mitmproxy.org/stable/concepts/options/#protobuf_definitions
49+
50+
## New Contentview API
51+
52+
Underpinning this interactivity is a revamped and drastically simpler Contentview API.
53+
Instead of returning a list of lines with inline markup,
54+
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:
56+
57+
(DNS example snippet)
58+
59+
Check out our [new contentview documentation] for more examples!
60+
61+
[`prettify`]: https://docs.mitmproxy.org/stable/api/mitmproxy/contentviews.html#Contentview.prettify
62+
[`reencode`]: https://docs.mitmproxy.org/stable/api/mitmproxy/contentviews.html#Contentview.reencode
63+
[new contentview documentation]: https://docs.mitmproxy.org/stable/addons/contentviews/
64+
65+
## Rust-based Contentviews
66+
67+
With the new API, we're also increasing our investment in Rust to deliver safe and performant contentviews:
68+
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).
74+
75+
[MsgPack implementation]: https://github.com/mitmproxy/mitmproxy_rs/blob/5ec05682b122a2c1ee6584b4fe57a698eef573fd/mitmproxy-contentviews/src/msgpack.rs
76+
[serde]: https://serde.rs/
77+
[mitmproxy-highlight]: https://github.com/mitmproxy/mitmproxy_rs/tree/main/mitmproxy-highlight
78+
[tree-sitter]: https://tree-sitter.github.io/tree-sitter/

0 commit comments

Comments
 (0)