-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Whitelist proxy using a valkey database #7573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…iables for everything
|
Thank you for the PR! 🍰
|
|
@mhils We were also thinking about having an abstractclass or
Would you accept a PR for the abstractclass| Then we can put the Valkey one in its own In our humble opinion: comprehensive whitelist support will greatly benefit the userbase—and encourage new users of—mitmproxy =) |
|
I think this is really cool work and quite useful. But it's relatively specialized and I don't want to take over any maintenance burden. So putting it into examples/contrib is best for the time being. |
|
@mhils How about a concurrently more extreme and more general solution, expanding your diff --git a/mitmproxy/addons/script.py b/mitmproxy/addons/script.py
index bc5bc0e..c32aa54 100644
--- a/mitmproxy/addons/script.py
+++ b/mitmproxy/addons/script.py
@@ -1,6 +1,7 @@
import asyncio
import importlib.machinery
import importlib.util
+import importlib
import logging
import os
import sys
@@ -21,6 +22,11 @@ logger = logging.getLogger(__name__)
def load_script(path: str) -> types.ModuleType | None:
+ if not os.path.isfile(path):
+ mod = importlib.import_module(path)
+ sys.modules[path] = mod
+ return mod
+
fullname = "__mitmproxy_script__.{}".format(
os.path.splitext(os.path.basename(path))[0]
) |
|
Hey @mhils, how does this look? I did everything you recommended. Seems like some checks are failing though... I don't know how to fix that, but if you point me in the right direction I'll give it my best shot! Any thoughts on what @SamuelMarks suggested about supporting external plugins? Thanks again for your time! |
|
Thanks! Please remove the old file from |
Description
(Related to #7539)
I've written a plugin for mitmproxy that enforces a whitelist with a valkey (redis) database.
On
configure, this plugin:On
request, this plugin:Checklist
Note: Because this is "just a plugin", I'm not sure if it's applicable for me to update tests and modify the changelog. Happy to do this if need be :-)
Alternatives to Valkey
Probably, you don't want to add a
valkeydependency formitmproxyjust to support my random plugin. That's very understandable! A more knowledgeable friend of mine suggested I could work around this issue by writing a protocol for an abstract database object. I'm new to the concept of protocols, but I think I get the gist!Let me know if this is the preferred approach, or if there's some other way I can improve this.
Open to feedback! Thanks for your time