Repository navigation
Don't let server replay override a response set by an earlier addon - #8563
Open
Thanatos9404 wants to merge 6 commits into
Open
Thanatos9404 wants to merge 6 commits into
Thanatos9404 wants to merge 6 commits into
Conversation
Server replay applied server_replay_extra, or a matching recorded response, to flows that a script or another addon had already answered. With kill, the client was disconnected while the flow still showed the script's response. Skip flows that already have a response or an error, or are not live, as MapLocal and MapRemote do. Fixes mitmproxy#6113
…addon-response # Conflicts: # CHANGELOG.md
…addon-response # Conflicts: # CHANGELOG.md
…addon-response # Conflicts: # CHANGELOG.md
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #6113.
ServerPlayback.request()ran even when a script or an earlier addon had already answered the flow. Withserver_replay_extra=kill, the client was disconnected while the flow still showed the script's response, which is the case from the issue. With a status code, the response was silently replaced. If a recorded flow matched, its response replaced the script's too.It now returns early when the flow already has a response or an error, or isn't live. That is the same guard MapLocal and MapRemote use.
The same applies to default addons that answer earlier: ProxyAuth's 407, BlockList and Onboarding. For example, with a matching recording on
main, a client that fails proxy auth gets the recorded response instead of the 407.One behaviour change to note: when a flow is already answered, a matching recording is no longer used up. Later identical requests in non-reuse mode therefore get the recordings one step earlier than before. If you would rather keep the guard to the
server_replay_extrabranches, as in your comment on the issue, I can narrow it.New tests in
test_serverplayback.py:kill,204and404;main,killraises "Flow is not killable").All of them fail on
main. The full test suite passes, andruffandmypyare clean. This should rebase cleanly with #8365, since the guard runs before the branch that PR moves.Checklist