Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit c23755a

Browse files
mbarnettweiweishi
authored andcommitted
Add filtering for sensitive information in errors reported to Rollbar (#167)
1 parent 0e6a040 commit c23755a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/pushmi_pullyu/cli.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ def configure_rollbar
6060
Rollbar.configure do |config|
6161
config.enabled = false unless options[:rollbar][:token].present?
6262
config.access_token = options[:rollbar][:token]
63+
64+
# add a filter after Rollbar has built the error payload but before it is delivered to the API,
65+
# in order to strip sensitive information out of certain error messages
66+
exception_message_transformer = proc do |payload|
67+
clean_message = payload[:exception].message.sub(/http:\/\/.+:.+@(.+)\/fedora\/rest\/prod\/(.*)/,
68+
"http://\1/fedora/rest/prod/\2")
69+
payload[:exception] = payload[:exception].exception(clean_message)
70+
payload[:message] = clean_message
71+
end
72+
73+
config.transform << exception_message_transformer
74+
6375
if options[:rollbar][:proxy_host].present?
6476
config.proxy = {}
6577
config.proxy[:host] = options[:rollbar][:proxy_host]

0 commit comments

Comments
 (0)