Skip to content

Commit

Permalink
Add filtering for sensitive information in errors reported to Rollbar (
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarnett authored and weiweishi committed Sep 5, 2018
1 parent 0e6a040 commit c23755a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/pushmi_pullyu/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ def configure_rollbar
Rollbar.configure do |config|
config.enabled = false unless options[:rollbar][:token].present?
config.access_token = options[:rollbar][:token]

# 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\/(.*)/,
"http://\1/fedora/rest/prod/\2")
payload[:exception] = payload[:exception].exception(clean_message)
payload[:message] = clean_message
end

config.transform << exception_message_transformer

if options[:rollbar][:proxy_host].present?
config.proxy = {}
config.proxy[:host] = options[:rollbar][:proxy_host]
Expand Down

0 comments on commit c23755a

Please sign in to comment.