-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
Add better documentation for sanitizing data #1140
Comments
👍 on this. I'm attempting to migrate from |
I had the same issue, for me the best solution is to do something like : config.before_send = lambda do |event, _hint|
Rails.application.config.filter_parameters.each do |filter_parameter|
event[filter_parameter] = nil
end
event
end |
sorry for the late reply, here's an example: config.before_send = lambda do |event, _hint|
# note: if you have config.async configured, the event here will be a Hash instead of an Event object
request_data = event.request.data
mask = "*****".freeze
Rails.application.config.filter_parameters.each do |filter_parameter|
if sensitive_data = request_data[filter_parameter]
request_data[filter_parameter] = mask
end
end
event.request.data = request_data
event
end if you want to replicate how we also recommend you to use server-side data scrubbing whenever possible. |
Why was this feature dropped? This makes it very difficult to upgrade. The functionality in sanitizedata.rb is not exactly trivial and something to be copy-pasted into before_send. I'd rather rely on the gem and their own tests rather than having to re-implement this feature along with tests |
@mcclymont This decision was made already some time ago when we moved SDKs to be unified. |
Client-side sanitisation is much preferred over server-side scrubbing for obvious security reasons. If we don't send sensitive data to Sentry, we don't need to trust Sentry to scrub it properly. The documentation even says this
So I don't believe sanitization in the SDK is an "edge case" |
@st0012 Unfortunately this code sample does not work nearly as well as the old functionality in sentry-raven
|
@mcclymont if you're using Rails, I think something like this should match the old behavior the best. filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
config.before_send = lambda do |event, hint|
event.request.data = filter.filter(event.request.data)
event
end (I'm still improving this example though) |
Thanks @st0012, that's a good idea. Unfortunately, it still doesn't measure up to the functionality of the sentry-raven processor:
|
@mcclymont as we've stated before, we don't intend to provide either a feature nor a code snippet that matches the exact same behavior of we'll improve our examples overtime to reduce the migration cost, but you should be the one to adjust them to fit your own use cases 🙂 |
@st0012 that's not particularly helpful, and I don't think what people are asking for. It's not really a "migration guide" if you don't actually provide a way to migrate. It's not like this is casual data we're sending, ensuring that PII is covered is a legal and privacy requirement. I don't have time to study all of the stuff Sentry was doing under the hood to sanitize in order to replicate the behavior and then possibly still get it wrong and get into legal trouble. This is really disappointing position to take. |
@bbugh the new SDK also provides an option to not sending any PII at all config.send_default_pii = false # this is actually the default just use it and that'll save you from the trouble 🙂 if you want part of the PII but don't want the rest of the parts, you'll need to scrub them yourself. because we don't know what you want and what you don't want. guessing a general pattern of sensitive data means it'll always accidentally scrub something else and it's a never-ending work, which eventually will become slow and buggy. |
Hello, everyone! I've made a try to add missing sanitization feature (in memory of You can try it and check, if it fits your requirements. For my project it did fit. I hope, this would help. Note: works only with |
@mrexox I guess you mean also thanks for building the new SDK's first community plugin 🎉 |
@st0012 yep, thank you, fixed it! You're welcome! Hope, it is useful :) |
I ended up doing this with async config:
I never saw a "data" key under I also added |
Me as well! : It have to work with Rails < 6.0 config.before_send = lambda do |event, _hint|
mask = '*****'.freeze
if event.dig('request', 'data')
Rails.application.config.filter_parameters.each do |filter_parameter|
event['request']['data'][filter_parameter.to_s] &&= mask
end
end
event
end |
A part of this issue I think is not really discussed enough (but mentioned by @mcclymont earlier in the tread) is that query params is not filtered by Obviously they are somewhat likely to contain pii or other sensitive info, especially stuff like password reset tokens (which if unique to a single user could be pii under gdpr) often go there. Obviously the same could be said for the rest of the request url as well, but I think query params is the most likely offended here. This does imo make the naming of |
@anderscarling thanks for bringing up the reset token example. based on such cases, I think it's a bug that Related PR: #1302 |
Update: I think this should work better (and is simpler) than focus on filtering request data filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
config.before_send = lambda do |event, hint|
filter.filter(event.to_hash)
end |
@st0012 EDIT: I am stupid, this does. 🤦 |
I've updated the documentation several times for better sanitization guidance. And I think using Rails' parameter filter generally works well, so I'm closing this for now. But feel free to drop new comments or new issues if you think we can improve it further, thanks 🙂 |
Describe the bug
sanitize_fields
has been removed, but there is no description of how to use the data scrubbing features https://docs.sentry.io/platforms/ruby/data-management/sensitive-data/#scrubbing-data and https://docs.sentry.io/platforms/ruby/configuration/filtering/It would be good if this was a concrete example showing how to replicate the sanitize_fields functionality, it is unclear what
value
is here and how to access request parameters from the event.The text was updated successfully, but these errors were encountered: