Skip to content
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

Merged
merged 10 commits into from
Nov 29, 2018
10 changes: 6 additions & 4 deletions lib/pushmi_pullyu/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

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)

raise e
end
# rubocop:enable Lint/RescueException
Expand All @@ -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!({

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.

Copy link
Contributor Author

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.

'IOError' => 'ignore'

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.

})

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.

# 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\/(.*)/,
Copy link
Contributor Author

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.

"http://\1/fedora/rest/prod/\2")
payload[:exception] = payload[:exception].exception(clean_message)
payload[:exception][:message] = clean_message
payload[:message] = clean_message
end

Expand Down