-
Notifications
You must be signed in to change notification settings - Fork 69
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
Redact request url #117
Redact request url #117
Conversation
463ffdc
to
935774f
Compare
935774f
to
7b8ef0c
Compare
Please review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tgwizard,
Thanks for submitting the PR. I've discussed with the team and this seems like something we should support. The code looks mostly good, my comments are mainly stylistic. I think we can live with the URL looking different in the dashboard, but it would be good to limit this discrepancy as much as possible. See the inline comments for a suggested approach that hopefully won't require us to rewrite Encode
.
request_extractor.go
Outdated
var rawQuery string | ||
parsedQuery, err := url.ParseQuery(req.URL.RawQuery) | ||
if err != nil { | ||
rawQuery = req.URL.RawQuery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the sanitizeURL
func is extracted, we can return here, and avoid a level of indentation when doing the parameter filtering below (no need for the else
).
Thanks for the review @kinbiko! I've pushed a commit addressing most of your comments, please have another look. I'd be happy to squash the commits at merge time. |
@kinbiko please review again :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tgwizard,
Thank you for your patience. I think this is pretty close to being done, the main remaining point is on achieving the consistency of [FILTERED]
.
Your efforts are much appreciated, and we'll try and get this in a new release shortly.
I've addressed all but one of your comments, which I commented on why. Please have another look @kinbiko. |
e3ceac5
to
58d5e56
Compare
The tests fail for some seemingly unrelated reason - a timeout in the Martini tests. |
@kinbiko please have another look, it should now all be fixed. |
Hi @tgwizard, Sorry about the wait -- I was struggling to find the time to come back and re-review this. I've taken this branch for a spin now, and it looks really good; only one minor issue. Unfortunately, not filtering empty URL params leads to a pretty confusing Request tab; The URL displays an empty value but the I've had a chat with another of the maintainers here and we believe it's best to be consistent and use That being said, we do see the benefit of being able to tell if such fields are absent. If this is something you need for your particular use case you may use an Other than this, I believe this change is good to go. Thank you ever so much for your patience. I realise I've been making you jump through a lot of hoops. You are free to address this if you so wish, otherwise I'll merge and address myself as soon as I find the time. |
No worries @kinbiko, I'm happy to make this right. The code is much better now than in my initial PR, which also makes me happy 😸 . I've added a commit to also add |
@kinbiko bump 😺 |
Just as @snmaynard mentioned, we were having some CI issues that I needed to fix before this could go in. This is why your latest build failed (nothing to do with your changes), but the PR looks good now so it's going in our next release (most likely shipping Monday). 🚢 Thanks again for your work on this @tgwizard! |
Goal
Currently, when the Bugsnag client extracts the URL from the request, it includes the full query parameters, without any filtering/redaction. This will leak any sensitive keys sent as query parameters, like access tokens.
This PR changes that so that we go through each query parameter and filter out sensitive ones (similar to how we do for request headers).
This PR also adds
access_token
as a default sensitive parameter, since it's very unlikely users want to include those in Bugsnag reports.Changeset
Changed
extractRequestInfoFromReq
Tests
I've added tests for the function.
Discussion
Alternative Approaches
Outstanding Questions
One drawback of this change is that the URL query parameters sent to Bugsnag will no longer be in the order that the client sent them, but sorted alphabetically by key. This is because
url.ParseQuery
returns a (type-aliased)map[string][]string
, and the correspondingEncode
sorts on key.We could attempt a custom implementation of the
Encode
function to sort according to the original order, but I'm not sure it's worth it.Linked issues
Review
For the submitter, initial self-review:
For the pull request reviewer(s), this changeset has been reviewed for: