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

Conversation

weiweishi
Copy link
Contributor

@weiweishi weiweishi commented Nov 29, 2018

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.

# 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.


config.exception_level_filters.merge!({
'IOError' => 'ignore'
})

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.

@@ -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'

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.

@@ -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.

@@ -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)

@@ -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!({
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.

@@ -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)
Copy link
Contributor

@murny murny Nov 29, 2018

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)

Copy link
Contributor

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

https://github.com/rollbar/rollbar-gem/blob/master/docs/configuration.md#use_exception_level_filters_default

@@ -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'
Copy link
Contributor

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'
})

Copy link
Contributor Author

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.

Copy link
Contributor

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
)

murny
murny previously approved these changes Nov 29, 2018
Copy link
Contributor

@murny murny left a 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.

murny
murny previously approved these changes Nov 29, 2018
murny
murny previously approved these changes Nov 29, 2018
lib/pushmi_pullyu/cli.rb Outdated Show resolved Hide resolved
Co-Authored-By: weiweishi <weiwei.shi@ualberta.ca>
@ualbertalib-bot
Copy link

1 Warning
⚠️ Please rebase to get rid of the merge commits in this PR

Generated by 🚫 Danger

@weiweishi weiweishi merged commit 3d15b35 into master Nov 29, 2018
@murny murny deleted the rollbar_filter branch November 29, 2018 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants