Skip to content

Refactor how we process --set options#5067

Merged
mhils merged 4 commits intomitmproxy:mainfrom
mhils:fix-setval
Mar 16, 2022
Merged

Refactor how we process --set options#5067
mhils merged 4 commits intomitmproxy:mainfrom
mhils:fix-setval

Conversation

@mhils
Copy link
Copy Markdown
Member

@mhils mhils commented Jan 16, 2022

refs #5056

Comment thread mitmproxy/addons/core.py
Comment thread mitmproxy/optmanager.py
Comment thread mitmproxy/tools/main.py Outdated
sys.exit(1)

try:
# TODO: `--set` should take precedence over config.yaml, but we do this first for now as it may modify confdir.
Copy link
Copy Markdown

@marwinxxii marwinxxii Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created an issue to track this and not forget #5069

Comment thread mitmproxy/addons/core.py
Comment thread mitmproxy/tools/console/options.py Outdated
try:
current = getattr(self.master.options, foc.opt.name)
d = self.master.options.parse_setval(foc.opt, v, current)
d = self.master.options.parse_setval(foc.opt, [v])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I'm following. Could you explain what you are referring to? This here only handles non-sequence types.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that if there is a set method which accepts a name and a value we don't need to use update.

In general my first impression is that we could make things consistent if we either always expect the caller to do parse_setval or allow two ways of setting options: parsed pair or a raw string (in which case parse_setval becomes a private function?)

Comment thread mitmproxy/addons/core.py
Comment thread mitmproxy/optmanager.py
Comment thread mitmproxy/addons/core.py
@mhils
Copy link
Copy Markdown
Member Author

mhils commented Jan 20, 2022

I've made some changes based on your feedback - thanks again! We now end up funneling everything through set=... specs because I couldn't get the structure equally straightforward otherwise, but this should be good to go now. I will have to take a bit of a mitmproxy hiatus for the next few weeks, but this will go in right after together with your tests! Thanks again! :)

Comment thread mitmproxy/optmanager.py Outdated
@marwinxxii
Copy link
Copy Markdown

I ran locally the test from #5010 (comment) and it passed successfully.

@mhils mhils marked this pull request as ready for review March 16, 2022 07:27
@mhils
Copy link
Copy Markdown
Member Author

mhils commented Mar 16, 2022

Thank you again for the initial PR and the very helpful reviews! 🍰

@mhils mhils enabled auto-merge (squash) March 16, 2022 07:29
@mhils mhils merged commit 6f05877 into mitmproxy:main Mar 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