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: let the callback addon modify response data #103

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Jul 4, 2024

Not currently used in tests. With integreation tests.

The next step is to allow the callback addon to implement the last remaining feature of the status_code addon, which is the ability to block requests from reaching the server. Currently, the hook in callback is in the "response" flow, which means it has already reached the server. This will require some rejigging to call the callback server earlier if it has been configured that way.

Once that is done, the status_code addon can be removed and callback can be used everywhere.

Related:

Not currently used in tests. With tests.
@kegsay kegsay requested a review from andybalaam July 4, 2024 12:19
func (cd CallbackData) String() string {
return fmt.Sprintf("%s %s (token=%s) req_len=%d => HTTP %v", cd.Method, cd.URL, cd.AccessToken, len(cd.RequestBody), cd.ResponseCode)
}

// NewCallbackServer runs a local HTTP server that can read callbacks from mitmproxy.
// Returns the URL of the callback server for use with WithMITMOptions, along with a close function
// which should be called when the test finishes to shut down the HTTP server.
func NewCallbackServer(t *testing.T, hostnameRunningComplement string, cb func(CallbackData)) (callbackURL string, close func()) {
func NewCallbackServer(t *testing.T, hostnameRunningComplement string, cb func(CallbackData) *CallbackResponse) (callbackURL string, close func()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the important bit as it changes the API for the callback server to return an optional CallbackResponse.

@kegsay kegsay merged commit 9b17d5d 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.

2 participants