mitmproxy icon indicating copy to clipboard operation
mitmproxy copied to clipboard

Make scripts path relative to config file

Open Speedlulu opened this issue 4 years ago • 3 comments

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.

Speedlulu avatar Oct 25 '21 13:10 Speedlulu

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. 😃

mhils avatar Oct 25 '21 13:10 mhils

Alrighty thanks ! Let me know if I can do anything to help along the way :)

Speedlulu avatar Oct 25 '21 14:10 Speedlulu

I updated the PR :)

Speedlulu avatar Nov 30 '23 18:11 Speedlulu