mitmproxy
mitmproxy copied to clipboard
Make scripts path relative to config file
Problem Description
Currently mitm commands will load scripts found in config.yaml relatively from where the command is ran which is fine when using the cli option -s but seems counter-intuitive when using a config file.
Current behaviour :
$ mitmproxy --set confdir=proxy
/home/lficheux/.local/bin/mitmproxy: Error reading proxy/config.yaml: No such script
$ tree proxy
proxy
├── addons
│ └── addons.py
├── config.yaml
$ cat proxy/config.yaml
scripts: ['./addons/addons.py', ]
(The error message could also do with a bit more verbosity in my opinion, I could do another PR for that.)
Proposal
Make scripts path relative to the config file they come from. If scripts path come from the cli option -s do nothing.
I have already made a pull request : https://github.com/mitmproxy/mitmproxy/pull/4860
Alternatives
- Using absolute paths but that defeats the point.
Thanks! I think that's a useful change in general and your PR looks good on the surface. I won't find the time to review this properly in the next few weeks. Either we'll find someone else to look properly at this, or I'll likely handle it in December or so. 😃
Alrighty thanks ! Let me know if I can do anything to help along the way :)
I updated the PR :)