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

mitmproxy addon: refactor the callback addon #100

Merged
merged 4 commits into from
Jul 4, 2024
Merged

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Jul 4, 2024

Whilst debugging duplicate OTK upload tests, I noticed that some requests were being tarpitted when they should not have been.

It turns out this was due to the callback addon itself not handling concurrent request/responses very well. To fix this, use aiohttp as per https://github.com/mitmproxy/mitmproxy/blob/main/examples/addons/nonblocking.py

This also adds tests which just test the callback addon itself, which will eventually fix #3.

--- PASS: TestCallbackAddon (17.06s)
    --- PASS: TestCallbackAddon/works (0.02s)
    --- PASS: TestCallbackAddon/can_be_filtered_by_path (0.03s)
    --- PASS: TestCallbackAddon/can_be_filtered_by_method (0.02s)
    --- PASS: TestCallbackAddon/can_be_filtered_by_access_token (0.03s)
    --- PASS: TestCallbackAddon/can_be_filtered_by_combinations_of_method_path_and_access_token (0.02s)
    --- PASS: TestCallbackAddon/processes_callbacks_concurrently (1.02s)

Longer term, the status_code addon will be obsoleted by the callback addon because it will sprout the ability to modify the HTTP response.

kegsay added 2 commits July 4, 2024 09:29
Whilst debugging duplicate OTK upload tests, I noticed that
some requests were being tarpitted when they should not have been.

It turns out this was due to the callback addon itself not handling
concurrent request/responses very well. To fix this, use `aiohttp`
as per https://github.com/mitmproxy/mitmproxy/blob/main/examples/addons/nonblocking.py

This also adds tests which just test the callback addon itself,
which will eventually fix #3.

Longer term, the `status_code` addon will be obsoleted by the
`callback` addon because it will sprout the ability to modify
the HTTP response.
@kegsay kegsay requested a review from andybalaam July 4, 2024 08:36
Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

One question but if you're happy with it, looks good.

tests/mitmproxy_addons/callback.py Outdated Show resolved Hide resolved
@kegsay kegsay merged commit df72cee into main Jul 4, 2024
4 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.

Tests for mitmproxy addons
2 participants