-
Notifications
You must be signed in to change notification settings - Fork 3
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
modifying the filtering tranformation to filter out unwanted info #175
Conversation
# add a filter after Rollbar has built the error payload but before it is delivered to the API, | ||
# in order to strip sensitive information out of certain error messages | ||
exception_message_transformer = proc do |payload| | ||
clean_message = payload[:exception].message.sub(/http:\/\/.+:.+@(.+)\/fedora\/rest\/prod\/(.*)/, | ||
clean_message = payload[:exception][:message].sub(/http:\/\/.+:.+@(.+)\/fedora\/rest\/prod\/(.*)/, |
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.
According to Rollbar, the payload json structured like this:
"exception": {
"message": "http://****:*****r@mycombe.library.ualberta.ca:8080/fedora/rest/prod/8c/ff/bb/0f/8cffbb0f-8cb8-4061-b6fe-3122a595d181/list_source: 404",
"class": "IOError"
}
So we will need to replace the value in payload[:exception][:message] with the scrubbed version.
lib/pushmi_pullyu/cli.rb
Outdated
|
||
config.exception_level_filters.merge!({ | ||
'IOError' => 'ignore' | ||
}) |
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.
Layout/IndentHash: Indent the right brace the same as the first position after the preceding left parenthesis.
lib/pushmi_pullyu/cli.rb
Outdated
@@ -59,13 +59,15 @@ def configure_rollbar | |||
Rollbar.configure do |config| | |||
config.enabled = false unless options[:rollbar][:token].present? | |||
config.access_token = options[:rollbar][:token] | |||
|
|||
config.exception_level_filters.merge!({ | |||
'IOError' => 'ignore' |
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.
Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
lib/pushmi_pullyu/cli.rb
Outdated
@@ -59,13 +59,15 @@ def configure_rollbar | |||
Rollbar.configure do |config| | |||
config.enabled = false unless options[:rollbar][:token].present? | |||
config.access_token = options[:rollbar][:token] | |||
|
|||
config.exception_level_filters.merge!({ |
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.
Performance/RedundantMerge: Use config.exception_level_filters['IOError'] = 'ignore' instead of config.exception_level_filters.merge!({
Style/BracesAroundHashParameters: Redundant curly braces around a hash parameter.
lib/pushmi_pullyu/cli.rb
Outdated
@@ -38,7 +38,7 @@ def run | |||
end | |||
# rubocop:disable Lint/RescueException | |||
rescue Exception => e | |||
Rollbar.error(e) | |||
Rollbar.error(e, :use_exception_level_filters => true) |
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.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax. (https://github.com/bbatsov/ruby-style-guide#hash-literals)
lib/pushmi_pullyu/cli.rb
Outdated
@@ -59,13 +59,15 @@ def configure_rollbar | |||
Rollbar.configure do |config| | |||
config.enabled = false unless options[:rollbar][:token].present? | |||
config.access_token = options[:rollbar][:token] | |||
|
|||
config.exception_level_filters.merge!({ |
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.
Add IOError as to be ignored so this particular error message will not be sent to Rollbar.
lib/pushmi_pullyu/cli.rb
Outdated
@@ -38,7 +38,7 @@ def run | |||
end | |||
# rubocop:disable Lint/RescueException | |||
rescue Exception => e | |||
Rollbar.error(e) | |||
Rollbar.error(e, use_exception_level_filters: true) |
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.
We can probably make this global? Not sure how many Rollbar.error
calls we doing in pushmi_pullyu (might just be this one, but if someone ever decides to come in and add another one, they don't have to forgot adding this use_exception_level_filters: true
call).
Can add it right to the config:
Rollbar.configure do |config|
config.use_exception_level_filters = true
end
So that all Rollbar.error
or Rollbar.warning
calls receive this
(oddly this is not in the documentation, but heres a PR for the commit: rollbar/rollbar-gem#588)
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.
Ah the PR example is wrong?
Correct usage is use_exception_level_filters_default = true
@@ -59,13 +59,13 @@ def configure_rollbar | |||
Rollbar.configure do |config| | |||
config.enabled = false unless options[:rollbar][:token].present? | |||
config.access_token = options[:rollbar][:token] | |||
|
|||
config.exception_level_filters['IOError'] = 'ignore' |
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.
Maybe use their provided syntax? If we decide to filter another exception in the future, someone doesn't just come in and copy and paste this line, they can add it to the merge call:
config.exception_level_filters.merge!({
'IOError' => 'ignore'
})
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.
Arrgh. I think Rubocop changed it to its current syntax with rubocop -a
. I will revert it back.
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.
Did we also want to ignore all IOErrors and not report them to rollbar? (as we throw IOErrors if things can't be found, for example if no file list exists:
# Note: raises IOError if can't find |
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.
LGTM 👍
Left some minor comments to future proof the code a bit more.
Co-Authored-By: weiweishi <weiwei.shi@ualberta.ca>
Generated by 🚫 Danger |
…into rollbar_filter
…i_pullyu into rollbar_filter
"exception": {
"message": "http://****:******@mycombe.library.ualberta.ca:8080/fedora/rest/prod/8c/ff/bb/0f/8cffbb0f-8cb8-4061-b6fe-3122a595d181/list_source: 404",
"class": "IOError"
}
This should be considered as a WIP PR, as I don't have a good way to test the code changes, and I'd like to hear from others, which seems to be a better/more reliable solution, to avoid having our fedora password get into Rollbar again.