Skip to content
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

Stream large bodies warn with modify body #6514

Merged

Conversation

rosydawn6
Copy link
Contributor

Description

Added alert logging for stream_large_bodies and modify_body and enhance documentation around these options ( #6479 )

Checklist

  • [NA] I have updated tests where applicable.
  • [Y] I have added an entry to the CHANGELOG.

Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

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

Thank you for the super nice first PR! It's great to have both docs updates + an interactive warning. 😃 🍰 🚀

Super small suggestions below. :)

mitmproxy/addons/modifybody.py Outdated Show resolved Hide resolved
mitmproxy/addons/modifybody.py Outdated Show resolved Hide resolved
@@ -211,6 +213,7 @@ def configure(self, updated) -> None:
if "stream_large_bodies" in updated:
try:
human.parse_size(ctx.options.stream_large_bodies)
logging.log(ALERT, "Cannot modify streamed bodies.")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
logging.log(ALERT, "Cannot modify streamed bodies.")
logging.log(ALERT, "Both modify_body and stream_large_bodies are active. Streamed bodies will not be modified.")

(further suggestions welcome if you feel this is worse - I feel that directly linking this to the respective option names is useful here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like linking to the option names. One minor question the message now says that modify_body is active, but we are not checking for its presence. Are we simply assuming that the body modification could happen via a def response lifecycle event or the modify_body option?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, thanks for catching this. We should definitely check if modify_body is set, and only then emit an alert! :)

CHANGELOG.md Outdated Show resolved Hide resolved
rosydawn6 and others added 4 commits December 2, 2023 15:48
… suitable import when modify_body in use"

This reverts commit 83cd967.
Co-authored-by: Maximilian Hils <github@maximilianhils.com>
@rosydawn6
Copy link
Contributor Author

Thanks for your suggestions. I overall agree and have made your changes with one clarifying question.

…n_with_modify_body' into stream_large_bodies_warn_with_modify_body
@mhils
Copy link
Member

mhils commented Dec 4, 2023

See comment above, otherwise good to go. :)

…dify_body and stream_large_bodies are set. Needs to be checked in both addons as either option can be set first
@rosydawn6
Copy link
Contributor Author

I have added the check for both options. After some testing I saw that I need to check for both options being set in both addsons as the options can come in any order.

Copy link
Member

@mhils mhils left a comment

Choose a reason for hiding this comment

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

Thanks! 😃 🍰

@mhils mhils enabled auto-merge (squash) December 5, 2023 02:19
@mhils mhils merged commit 81fc802 into mitmproxy:main Dec 5, 2023
20 checks passed
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.

None yet

2 participants