-
-
Notifications
You must be signed in to change notification settings - Fork 521
Adding suppport for sanitizing query parameters. #275
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
Conversation
lib/raven/processor/sanitizedata.rb
Outdated
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.
Can you kindly use CGI::parse here? I think the code as written will break with keys that have several values + url encoding.
|
Modified to use standard library functions. Please note that I had to modify the array sanitizer to pass the key down. Otherwise elements in arrays wouldn't be sanitized as desired. Looks like there are failures I'll take a look. |
…e escaped by the backported uri encoding.
|
Phew, okay now that the builds are passing... I added in a backport of URI from the rack gem to support If the above changes seem excessive we could always drop back to my original solution. I believe it will handle odd encodings and several values but I'm not 100% certain. I attempted several odd encodings and special character combinations and it seemed to work fine. |
|
Wow! That's some awesome work! Thank you so much for taking the time to do all of this - I was considering just doing a "if >1.8 do" sort of branch, but you've made it work. I'm sure the people running 1.8 will appreciate it. @pcorliss Can you write a test for the case of multiple values to a key and for url encoding? Just two more test assertions is all, nothing crazy. I know both of these cases are common in Rails so I want make sure we get that right. |
|
Tests added. A few notes, because of the way this is implemented the query string can mutate a bit. This is due to the decoding and subsequent re-encoding of the content of the strings. Simple stuff like |
|
@pcorliss thanks so much again. This is some very classy work. I think the gain here (sanitizing query strings) is better than the loss (query strings which were not url encoded in the original request will appear url encoded in Sentry). Ideally you will always have your actual application logs to check against any discrepancy. |
Adding suppport for sanitizing query parameters.
Paired with @kjperry
For GET requests and POST requests with query parameters the query_string remains unsanitized. While GET requests with sensitive data is rare for our application we wanted to be sure that bad requests would be sanitized as expected.