Strip sensitive info from HTTP errors #3878
Merged
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 of Changes
reqwestincludes the full URL in its errors, including query params. This is unfortunate, as query params can contain sensitive info like API tokens. It's difficult for modules to clean these themselves, as they see errors as strings, losing the structure ofreqwest::Error.In this commit, we strip query parts out of URLs in errors before returning them to modules. I've also audited all of the error return paths in the
http_requestmethod and left comments justifying why the unchanged ones are safe.API and ABI breaking changes
Only if you consider the format of error messages part of our API, which I don't. Procedure APIs aren't stable yet anyways.
Expected complexity level and risk
1
Testing
None yet - accepting input from reviewers about desired tests if we feel that's necessary.