question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unify Replacement UX

See original GitHub issue

Problem Description

The replacement addon currently calls flow.replace(), which performs replacements in URL, HTTP Headers, and request/response body. This is messy and terrible because there is no way to control in which part of the flow replacements should be done - it does many things, and none of them well. It’s often luck that replacements work. For example, in many cases, replacements like /~s/response-body “work” because URL/header replacements are not performed if they don’t match syntactically:

https://github.com/mitmproxy/mitmproxy/blob/3131160e1c53a55845bb824038e602c14d92cf74/mitmproxy/net/http/headers.py#L172-L177

I think there is some opportunity for improvement here. 😄

Proposed Changes

With the advent of a “map local” editor in #3940, I think it is time to clean up things here and implement the following changes:

  1. The replacements addon is for HTTP body replacements (and later on TCP/WebSocket messages). We can possibly rename it to make this more clear (ReplaceContent? ReplaceData?). This also means we can implement it in the addon and get rid of HTTPFlow.replace and its descendants.
  2. SetHeaders is for header modifications.
  3. Map remote/map local addons are for request line modification/redirection to localhost.

This also means we can unify the expression syntax for these four addons:

old syntax new syntax
Map Local [/filter]/url/file-or-directory
Map Remote [/filter]/url-regex/replacement
SetHeader /filter/name/value [/filter]/header-name/[@]header-value
Replacements /filter[/regex]/[@]replacement [/filter]/body-regex/[@]replacement

@mitmproxy/devs, @Prinzhorn, @naivekun, any thoughts? 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
mhilscommented, Dec 13, 2020

Yes, complete. 😃 👍

1reaction
mhilscommented, Apr 29, 2020

I always die a little when I have to use a regex in Burp and have to escape all the dots in a hostname or file extensions 🤦

Just don’t escape them, it will match the right things anyways 😉🙊

More seriously: I see your point, but globs are very much limited when it comes to replacements and not just matching. Let’s keep this in mind, but we likely need regexes somewhere anyways, and then it may pay off to be consistent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UX design & systems thinking: product portfolio unification ...
As Russell Ackoff wrote in his book, idealised design “begins with designing the system with which we would replace existing system right now...
Read more >
How to unify your UX across platforms
Discover how to make a seamless UX across various devices.
Read more >
UniFi Router Comparison: USG vs UDM vs UXG - McCann Tech
Ubiquiti hasn't made a direct replacement for the USG, and no standalone UniFi router can match it's low price.
Read more >
Defining and evolving a North Star vision to unify products | ...
Challenge: Integrate acquired products to create a cohesive, modern and functional experience for users of an enterprise software solution.
Read more >
Design Systems 101
It creates a unified language within and between crossfunctional teams. Especially when design responsibilities shift or when teams become ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found