Skip to content

add keyboard shortcut n to mitmweb (by using runCommand inside the kb shortcut handler)#5061

Merged
mhils merged 2 commits intomitmproxy:mainfrom
ianklatzco:mitmweb-create
Jan 16, 2022
Merged

add keyboard shortcut n to mitmweb (by using runCommand inside the kb shortcut handler)#5061
mhils merged 2 commits intomitmproxy:mainfrom
ianklatzco:mitmweb-create

Conversation

@ianklatzco
Copy link
Copy Markdown
Contributor

@ianklatzco ianklatzco commented Jan 15, 2022

Description

Following the behavior of mitmproxy, this adds an n keybind to mitmweb, which creates a new flow in the FlowView:
image

Which can then be clicked, edited, and r'd to be sent.

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

@ianklatzco
Copy link
Copy Markdown
Contributor Author

Last failing check is an unreachable URL validation; currently the /create endpoint doesn't have any way to specify a URL (example.com is hardcoded, and then users edit the desired URL in the web UI).

I'll probably add a way for POST /flows/create to take a URL and then write a test, when I touch this next.

@mhils
Copy link
Copy Markdown
Member

mhils commented Jan 15, 2022

👍 on adding this, thanks for the PR! 😃

We could potentially remove a lot of boilerplate by just using runCommand("view.flows.create", "get", "https://example.com/") either in flows.ts:create or directly in keyboard.tsx:onKeyDown. The functionality to directly call mitmproxy commands via the POST /commands endpoint is fairly new, which is why most of the existing code goes through the trouble of defining new routes etc. Alternatively we should at least just invoke the command in your newly defined CreateFlow endpoint. Either way is fine for me, let me know what you think. :)

(also feel free to ask stupid questions here or on Slack. Based on your PR I'm assuming quite a bit of familiarity with everything already, happy to explain stuff in more detail :))

@ianklatzco ianklatzco force-pushed the mitmweb-create branch 2 times, most recently from 4a91b30 to 32a16de Compare January 16, 2022 01:49
@ianklatzco ianklatzco changed the title add keyboard shortcut n to mitmweb (by creating /flows/create route) add keyboard shortcut n to mitmweb (by using runCommand inside the kb shortcut handler) Jan 16, 2022
@ianklatzco
Copy link
Copy Markdown
Contributor Author

All zipped up and rebased. Should be good to go! Please merge at your convenience if everything looks okay.

@mhils
Copy link
Copy Markdown
Member

mhils commented Jan 16, 2022

This looks super straightforward, excellent! 🎉
It could be useful to add File -> New Flow as well so that it's easier to discover, but let's leave that for a new PR! 😃

@mhils mhils merged commit 1abb8f6 into mitmproxy:main Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants