rollbar 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +81 -34
- data/Gemfile +8 -8
- data/gemfiles/rails30.gemfile +10 -12
- data/gemfiles/rails31.gemfile +10 -12
- data/gemfiles/rails32.gemfile +3 -5
- data/gemfiles/rails40.gemfile +2 -4
- data/gemfiles/rails41.gemfile +2 -5
- data/gemfiles/rails42.gemfile +4 -9
- data/gemfiles/rails50.gemfile +7 -9
- data/gemfiles/rails51.gemfile +6 -8
- data/gemfiles/rails52.gemfile +5 -5
- data/gemfiles/rails60.gemfile +3 -4
- data/gemfiles/rails61.gemfile +3 -3
- data/lib/generators/rollbar/rollbar_generator.rb +18 -14
- data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
- data/lib/rails/rollbar_runner.rb +12 -5
- data/lib/rollbar/capistrano.rb +16 -8
- data/lib/rollbar/capistrano3.rb +8 -2
- data/lib/rollbar/capistrano_tasks.rb +16 -7
- data/lib/rollbar/configuration.rb +113 -91
- data/lib/rollbar/delay/shoryuken.rb +4 -3
- data/lib/rollbar/delay/sidekiq.rb +3 -1
- data/lib/rollbar/delay/sucker_punch.rb +1 -2
- data/lib/rollbar/delay/thread.rb +3 -2
- data/lib/rollbar/deploy.rb +6 -7
- data/lib/rollbar/encoding/encoder.rb +7 -3
- data/lib/rollbar/exception_reporter.rb +17 -8
- data/lib/rollbar/item/backtrace.rb +10 -8
- data/lib/rollbar/item/frame.rb +6 -5
- data/lib/rollbar/item/locals.rb +3 -1
- data/lib/rollbar/item.rb +47 -38
- data/lib/rollbar/json.rb +1 -1
- data/lib/rollbar/lazy_store.rb +1 -3
- data/lib/rollbar/logger.rb +2 -0
- data/lib/rollbar/logger_proxy.rb +3 -1
- data/lib/rollbar/middleware/js.rb +32 -20
- data/lib/rollbar/middleware/rack/builder.rb +3 -3
- data/lib/rollbar/middleware/rack/test_session.rb +3 -3
- data/lib/rollbar/middleware/rack.rb +4 -4
- data/lib/rollbar/middleware/rails/rollbar.rb +9 -6
- data/lib/rollbar/middleware/rails/show_exceptions.rb +8 -4
- data/lib/rollbar/notifier/trace_with_bindings.rb +4 -2
- data/lib/rollbar/notifier.rb +179 -133
- data/lib/rollbar/plugin.rb +8 -8
- data/lib/rollbar/plugins/active_job.rb +11 -2
- data/lib/rollbar/plugins/delayed_job/plugin.rb +10 -3
- data/lib/rollbar/plugins/goalie.rb +27 -16
- data/lib/rollbar/plugins/rails/controller_methods.rb +18 -14
- data/lib/rollbar/plugins/rails/railtie30.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie32.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +2 -2
- data/lib/rollbar/plugins/rails.rb +5 -2
- data/lib/rollbar/plugins/rake.rb +2 -1
- data/lib/rollbar/plugins/sidekiq/plugin.rb +5 -5
- data/lib/rollbar/plugins/thread.rb +1 -1
- data/lib/rollbar/plugins/validations.rb +3 -1
- data/lib/rollbar/rake_tasks.rb +0 -1
- data/lib/rollbar/request_data_extractor.rb +38 -17
- data/lib/rollbar/rollbar_test.rb +3 -1
- data/lib/rollbar/scrubbers/params.rb +13 -7
- data/lib/rollbar/scrubbers/url.rb +37 -17
- data/lib/rollbar/scrubbers.rb +1 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +4 -1
- data/lib/rollbar/truncation/remove_extra_strategy.rb +3 -1
- data/lib/rollbar/util/hash.rb +14 -7
- data/lib/rollbar/util/ip_anonymizer.rb +1 -1
- data/lib/rollbar/util.rb +19 -13
- data/lib/rollbar/version.rb +1 -1
- data/lib/rollbar.rb +12 -7
- data/lib/tasks/benchmark.rake +2 -1
- data/rollbar.gemspec +3 -1
- metadata +3 -3
@@ -11,29 +11,40 @@ Rollbar.plugins.define('goalie') do
|
|
11
11
|
begin
|
12
12
|
controller = env['action_controller.instance']
|
13
13
|
request_data = begin
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
controller.rollbar_request_data
|
15
|
+
rescue StandardError
|
16
|
+
nil
|
17
|
+
end
|
18
18
|
person_data = begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
exception_data = Rollbar.scope(
|
19
|
+
controller.rollbar_person_data
|
20
|
+
rescue StandardError
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
exception_data = Rollbar.scope(
|
24
|
+
:request => request_data,
|
25
|
+
:person => person_data
|
26
|
+
).error(exception, :use_exception_level_filters => true)
|
24
27
|
rescue StandardError => e
|
25
|
-
|
28
|
+
message = "[Rollbar] Exception while reporting exception to Rollbar: #{e}"
|
29
|
+
Rollbar.log_warning(message)
|
26
30
|
end
|
27
31
|
|
28
32
|
# if an exception was reported, save uuid in the env
|
29
33
|
# so it can be displayed to the user on the error page
|
30
|
-
|
34
|
+
case exception_data
|
35
|
+
when Hash
|
31
36
|
env['rollbar.exception_uuid'] = exception_data[:uuid]
|
32
|
-
Rollbar.log_info
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
Rollbar.log_info
|
37
|
+
Rollbar.log_info(
|
38
|
+
"[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
|
39
|
+
)
|
40
|
+
when 'disabled'
|
41
|
+
Rollbar.log_info(
|
42
|
+
'[Rollbar] Exception not reported because Rollbar is disabled'
|
43
|
+
)
|
44
|
+
when 'ignored'
|
45
|
+
Rollbar.log_info(
|
46
|
+
'[Rollbar] Exception not reported because it was ignored'
|
47
|
+
)
|
37
48
|
end
|
38
49
|
|
39
50
|
# now continue as normal
|
@@ -7,30 +7,34 @@ module Rollbar
|
|
7
7
|
include RequestDataExtractor
|
8
8
|
|
9
9
|
def rollbar_person_data
|
10
|
-
|
10
|
+
user = nil
|
11
|
+
unless Rollbar::Util.method_in_stack_twice(:rollbar_person_data, __FILE__)
|
12
|
+
user = send(Rollbar.configuration.person_method)
|
13
|
+
end
|
14
|
+
|
11
15
|
# include id, username, email if non-empty
|
12
16
|
if user
|
13
17
|
{
|
14
18
|
:id => (begin
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
user.send(Rollbar.configuration.person_id_method)
|
20
|
+
rescue StandardError
|
21
|
+
nil
|
22
|
+
end),
|
19
23
|
:username => (begin
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
user.send(Rollbar.configuration.person_username_method)
|
25
|
+
rescue StandardError
|
26
|
+
nil
|
27
|
+
end),
|
24
28
|
:email => (begin
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
user.send(Rollbar.configuration.person_email_method)
|
30
|
+
rescue StandardError
|
31
|
+
nil
|
32
|
+
end)
|
29
33
|
}
|
30
34
|
else
|
31
35
|
{}
|
32
36
|
end
|
33
|
-
rescue
|
37
|
+
rescue NameError
|
34
38
|
{}
|
35
39
|
end
|
36
40
|
|
@@ -11,7 +11,8 @@ module Rollbar
|
|
11
11
|
|
12
12
|
app.config.middleware.insert_after ActionDispatch::ShowExceptions,
|
13
13
|
Rollbar::Middleware::Rails::RollbarMiddleware
|
14
|
-
ActionDispatch::ShowExceptions.send(:include,
|
14
|
+
ActionDispatch::ShowExceptions.send(:include,
|
15
|
+
Rollbar::Middleware::Rails::ShowExceptions)
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -11,7 +11,8 @@ module Rollbar
|
|
11
11
|
|
12
12
|
app.config.middleware.insert_after ActionDispatch::DebugExceptions,
|
13
13
|
Rollbar::Middleware::Rails::RollbarMiddleware
|
14
|
-
ActionDispatch::DebugExceptions.send(:include,
|
14
|
+
ActionDispatch::DebugExceptions.send(:include,
|
15
|
+
Rollbar::Middleware::Rails::ShowExceptions)
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -16,9 +16,9 @@ module Rollbar
|
|
16
16
|
config.framework = "Rails: #{::Rails::VERSION::STRING}"
|
17
17
|
config.filepath ||= begin
|
18
18
|
if ::Rails.application.class.respond_to?(:module_parent_name)
|
19
|
-
::Rails.application.class.module_parent_name
|
19
|
+
"#{::Rails.application.class.module_parent_name}.rollbar"
|
20
20
|
else
|
21
|
-
::Rails.application.class.parent_name
|
21
|
+
"#{::Rails.application.class.parent_name}.rollbar"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -39,7 +39,8 @@ Rollbar.plugins.define('rails-rollbar.js') do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def after_secure_headers(&block)
|
42
|
-
Rollbar::Railtie.initializer('rollbar.js.frameworks.rails',
|
42
|
+
Rollbar::Railtie.initializer('rollbar.js.frameworks.rails',
|
43
|
+
:after => 'secure_headers.middleware', &block)
|
43
44
|
end
|
44
45
|
|
45
46
|
def plugin_execute_proc_body(plugin)
|
@@ -52,7 +53,8 @@ Rollbar.plugins.define('rails-rollbar.js') do
|
|
52
53
|
:options => Rollbar.configuration.js_options,
|
53
54
|
:enabled => Rollbar.configuration.js_enabled
|
54
55
|
}
|
55
|
-
::Rails.configuration.middleware.use(::Rollbar::Middleware::Js,
|
56
|
+
::Rails.configuration.middleware.use(::Rollbar::Middleware::Js,
|
57
|
+
config)
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
@@ -62,6 +64,7 @@ Rollbar.plugins.define('rails-rollbar.js') do
|
|
62
64
|
begin
|
63
65
|
require 'secure_headers'
|
64
66
|
rescue LoadError
|
67
|
+
# Skip loading
|
65
68
|
end
|
66
69
|
|
67
70
|
defined?(::SecureHeaders::Middleware)
|
data/lib/rollbar/plugins/rake.rb
CHANGED
@@ -40,7 +40,8 @@ Rollbar.plugins.define('rake') do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.skip_patch
|
43
|
-
warn('[Rollbar] Rollbar is disabled for Rake tasks since your Rake
|
43
|
+
warn('[Rollbar] Rollbar is disabled for Rake tasks since your Rake ' \
|
44
|
+
'version is under 0.9.x. Please upgrade to 0.9.x or higher.')
|
44
45
|
end
|
45
46
|
|
46
47
|
def self.patch?
|
@@ -5,12 +5,12 @@ module Rollbar
|
|
5
5
|
PARAM_BLACKLIST = %w[backtrace error_backtrace error_message error_class].freeze
|
6
6
|
|
7
7
|
class ResetScope
|
8
|
-
def call(_worker, msg, _queue)
|
8
|
+
def call(_worker, msg, _queue, &block)
|
9
9
|
Rollbar.reset_notifier! # clears scope
|
10
10
|
|
11
11
|
return yield unless Rollbar.configuration.sidekiq_use_scoped_block
|
12
12
|
|
13
|
-
Rollbar.scoped(Rollbar::Sidekiq.job_scope(msg))
|
13
|
+
Rollbar.scoped(Rollbar::Sidekiq.job_scope(msg), &block)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -57,13 +57,13 @@ module Rollbar
|
|
57
57
|
end
|
58
58
|
|
59
59
|
# see https://github.com/mperham/sidekiq/wiki/Middleware#server-middleware
|
60
|
-
def call(_worker, msg, _queue)
|
60
|
+
def call(_worker, msg, _queue, &block)
|
61
61
|
Rollbar.reset_notifier! # clears scope
|
62
62
|
|
63
63
|
return yield unless Rollbar.configuration.sidekiq_use_scoped_block
|
64
64
|
|
65
|
-
Rollbar.scoped(Rollbar::Sidekiq.job_scope(msg))
|
66
|
-
rescue Exception => e
|
65
|
+
Rollbar.scoped(Rollbar::Sidekiq.job_scope(msg), &block)
|
66
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
67
67
|
Rollbar::Sidekiq.handle_exception(msg, e)
|
68
68
|
raise
|
69
69
|
end
|
@@ -17,7 +17,9 @@ Rollbar.plugins.define('active_model') do
|
|
17
17
|
module ActiveRecordExtension
|
18
18
|
def report_validation_errors_to_rollbar
|
19
19
|
errors.full_messages.each do |error|
|
20
|
-
Rollbar.log_info
|
20
|
+
Rollbar.log_info(
|
21
|
+
"[Rollbar] Reporting form validation error: #{error} for #{self}"
|
22
|
+
)
|
21
23
|
Rollbar.warning("Form Validation Error: #{error} for #{self}")
|
22
24
|
end
|
23
25
|
end
|
data/lib/rollbar/rake_tasks.rb
CHANGED
@@ -19,10 +19,10 @@ module Rollbar
|
|
19
19
|
else
|
20
20
|
controller = env['action_controller.instance']
|
21
21
|
person_data = begin
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
controller.rollbar_person_data
|
23
|
+
rescue StandardError
|
24
|
+
{}
|
25
|
+
end
|
26
26
|
end
|
27
27
|
|
28
28
|
person_data
|
@@ -34,7 +34,8 @@ module Rollbar
|
|
34
34
|
|
35
35
|
get_params = scrub_params(rollbar_get_params(rack_req), sensitive_params)
|
36
36
|
post_params = scrub_params(rollbar_post_params(rack_req), sensitive_params)
|
37
|
-
raw_body_params = scrub_params(mergeable_raw_body_params(rack_req),
|
37
|
+
raw_body_params = scrub_params(mergeable_raw_body_params(rack_req),
|
38
|
+
sensitive_params)
|
38
39
|
cookies = scrub_params(rollbar_request_cookies(rack_req), sensitive_params)
|
39
40
|
session = scrub_params(rollbar_request_session(env), sensitive_params)
|
40
41
|
route_params = scrub_params(rollbar_route_params(env), sensitive_params)
|
@@ -54,7 +55,10 @@ module Rollbar
|
|
54
55
|
:method => rollbar_request_method(env)
|
55
56
|
}
|
56
57
|
|
57
|
-
|
58
|
+
if env['action_dispatch.request_id']
|
59
|
+
data[:request_id] =
|
60
|
+
env['action_dispatch.request_id']
|
61
|
+
end
|
58
62
|
|
59
63
|
data
|
60
64
|
end
|
@@ -87,9 +91,10 @@ module Rollbar
|
|
87
91
|
def mergeable_raw_body_params(rack_req)
|
88
92
|
raw_body_params = rollbar_raw_body_params(rack_req)
|
89
93
|
|
90
|
-
|
94
|
+
case raw_body_params
|
95
|
+
when Hash
|
91
96
|
raw_body_params
|
92
|
-
|
97
|
+
when Array
|
93
98
|
{ 'body.multi' => raw_body_params }
|
94
99
|
else
|
95
100
|
{ 'body.value' => raw_body_params }
|
@@ -109,13 +114,17 @@ module Rollbar
|
|
109
114
|
{ name => Rollbar::Scrubbers.scrub_value(env[header]) }
|
110
115
|
elsif name == 'X-Forwarded-For' && !Rollbar.configuration.collect_user_ip
|
111
116
|
{}
|
112
|
-
elsif name == 'X-Forwarded-For' &&
|
117
|
+
elsif name == 'X-Forwarded-For' &&
|
118
|
+
Rollbar.configuration.collect_user_ip &&
|
119
|
+
Rollbar.configuration.anonymize_user_ip
|
113
120
|
ips = env[header].sub(' ', '').split(',')
|
114
121
|
ips = ips.map { |ip| Rollbar::Util::IPAnonymizer.anonymize_ip(ip) }
|
115
122
|
{ name => ips.join(', ') }
|
116
123
|
elsif name == 'X-Real-Ip' && !Rollbar.configuration.collect_user_ip
|
117
124
|
{}
|
118
|
-
elsif name == 'X-Real-Ip' &&
|
125
|
+
elsif name == 'X-Real-Ip' &&
|
126
|
+
Rollbar.configuration.collect_user_ip &&
|
127
|
+
Rollbar.configuration.anonymize_user_ip
|
119
128
|
{ name => Rollbar::Util::IPAnonymizer.anonymize_ip(env[header]) }
|
120
129
|
else
|
121
130
|
{ name => env[header] }
|
@@ -131,16 +140,15 @@ module Rollbar
|
|
131
140
|
host = host.split(',').first.strip unless host.empty?
|
132
141
|
|
133
142
|
path = env['ORIGINAL_FULLPATH'] || env['REQUEST_URI']
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
143
|
+
query = env['QUERY_STRING'].to_s.empty? ? nil : "?#{env['QUERY_STRING']}"
|
144
|
+
path ||= "#{env['SCRIPT_NAME']}#{env['PATH_INFO']}#{query}"
|
145
|
+
path = "/#{path}" if !(path.nil? || path.empty?) && (path.to_s.slice(0, 1) != '/')
|
138
146
|
|
139
147
|
port = env['HTTP_X_FORWARDED_PORT']
|
140
148
|
if port && !(!scheme.nil? && scheme.casecmp('http').zero? && port.to_i == 80) && \
|
141
149
|
!(!scheme.nil? && scheme.casecmp('https').zero? && port.to_i == 443) && \
|
142
150
|
!(host.include? ':')
|
143
|
-
host = host
|
151
|
+
host = "#{host}:#{port}"
|
144
152
|
end
|
145
153
|
|
146
154
|
[scheme, '://', host, path].join
|
@@ -149,7 +157,11 @@ module Rollbar
|
|
149
157
|
def rollbar_user_ip(env)
|
150
158
|
return nil unless Rollbar.configuration.collect_user_ip
|
151
159
|
|
152
|
-
user_ip_string = (
|
160
|
+
user_ip_string = (user_ip_at_configured_key(env) ||
|
161
|
+
env['action_dispatch.remote_ip'] ||
|
162
|
+
env['HTTP_X_REAL_IP'] ||
|
163
|
+
x_forwarded_for_client(env['HTTP_X_FORWARDED_FOR']) ||
|
164
|
+
env['REMOTE_ADDR']).to_s
|
153
165
|
|
154
166
|
user_ip_string = Rollbar::Util::IPAnonymizer.anonymize_ip(user_ip_string)
|
155
167
|
|
@@ -158,6 +170,12 @@ module Rollbar
|
|
158
170
|
nil
|
159
171
|
end
|
160
172
|
|
173
|
+
def user_ip_at_configured_key(env)
|
174
|
+
return nil unless Rollbar.configuration.user_ip_rack_env_key
|
175
|
+
|
176
|
+
env[Rollbar.configuration.user_ip_rack_env_key]
|
177
|
+
end
|
178
|
+
|
161
179
|
def x_forwarded_for_client(header_value)
|
162
180
|
return nil unless header_value
|
163
181
|
|
@@ -248,7 +266,10 @@ module Rollbar
|
|
248
266
|
end
|
249
267
|
|
250
268
|
def sensitive_headers_list
|
251
|
-
|
269
|
+
unless Rollbar.configuration.scrub_headers &&
|
270
|
+
Rollbar.configuration.scrub_headers.is_a?(Array)
|
271
|
+
return []
|
272
|
+
end
|
252
273
|
|
253
274
|
# Normalize into the expected matching format
|
254
275
|
Rollbar.configuration.scrub_headers.map do |header|
|
data/lib/rollbar/rollbar_test.rb
CHANGED
@@ -27,7 +27,9 @@ module RollbarTest # :nodoc:
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.error_message
|
30
|
-
'Test failed! You may have a configuration issue, or you could be using a
|
30
|
+
'Test failed! You may have a configuration issue, or you could be using a ' \
|
31
|
+
'gem that\'s blocking the test. Contact support@rollbar.com if you need ' \
|
32
|
+
'help troubleshooting.'
|
31
33
|
end
|
32
34
|
|
33
35
|
def self.success_message
|
@@ -10,7 +10,8 @@ module Rollbar
|
|
10
10
|
# configuration array even if :scrub_all is true.
|
11
11
|
class Params
|
12
12
|
SKIPPED_CLASSES = [::Tempfile].freeze
|
13
|
-
ATTACHMENT_CLASSES = %w[ActionDispatch::Http::UploadedFile
|
13
|
+
ATTACHMENT_CLASSES = %w[ActionDispatch::Http::UploadedFile
|
14
|
+
Rack::Multipart::UploadedFile].freeze
|
14
15
|
SCRUB_ALL = :scrub_all
|
15
16
|
|
16
17
|
def self.call(*args)
|
@@ -21,7 +22,7 @@ module Rollbar
|
|
21
22
|
params = options[:params]
|
22
23
|
return {} unless params
|
23
24
|
|
24
|
-
@
|
25
|
+
@scrubbed_objects = {}.compare_by_identity
|
25
26
|
|
26
27
|
config = options[:config]
|
27
28
|
extra_fields = options[:extra_fields]
|
@@ -52,16 +53,20 @@ module Rollbar
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def build_whitelist_regex(whitelist)
|
55
|
-
fields = whitelist.find_all
|
56
|
+
fields = whitelist.find_all do |f|
|
57
|
+
f.is_a?(String) || f.is_a?(Symbol) || f.is_a?(Regexp)
|
58
|
+
end
|
56
59
|
return unless fields.any?
|
57
60
|
|
58
|
-
Regexp.new(fields.map
|
61
|
+
Regexp.new(fields.map do |val|
|
62
|
+
val.is_a?(Regexp) ? val : /\A#{Regexp.escape(val.to_s)}\z/
|
63
|
+
end.join('|'))
|
59
64
|
end
|
60
65
|
|
61
66
|
def scrub(params, options)
|
62
|
-
return params if @
|
67
|
+
return params if @scrubbed_objects[params]
|
63
68
|
|
64
|
-
@
|
69
|
+
@scrubbed_objects[params] = true
|
65
70
|
|
66
71
|
fields_regex = options[:fields_regex]
|
67
72
|
scrub_all = options[:scrub_all]
|
@@ -71,7 +76,8 @@ module Rollbar
|
|
71
76
|
|
72
77
|
params.to_hash.inject({}) do |result, (key, value)|
|
73
78
|
encoded_key = Rollbar::Encoding.encode(key).to_s
|
74
|
-
result[key] = if (fields_regex === encoded_key) &&
|
79
|
+
result[key] = if (fields_regex === encoded_key) &&
|
80
|
+
!(whitelist_regex === encoded_key)
|
75
81
|
scrub_value(value)
|
76
82
|
elsif value.is_a?(Hash)
|
77
83
|
scrub(value, options)
|
@@ -23,7 +23,9 @@ module Rollbar
|
|
23
23
|
options[:scrub_fields].include?(SCRUB_ALL),
|
24
24
|
build_whitelist_regex(options[:whitelist] || []))
|
25
25
|
rescue StandardError => e
|
26
|
-
|
26
|
+
message = '[Rollbar] There was an error scrubbing the url: ' \
|
27
|
+
"#{e}, options: #{options.inspect}"
|
28
|
+
Rollbar.logger.error(message)
|
27
29
|
url
|
28
30
|
end
|
29
31
|
|
@@ -32,10 +34,11 @@ module Rollbar
|
|
32
34
|
def ascii_encode(url)
|
33
35
|
# In some cases non-ascii characters won't be properly encoded, so we do it here.
|
34
36
|
#
|
35
|
-
# The standard encoders (the CGI and URI methods) are not reliable when
|
36
|
-
# is already embedded in the full URL, but the inconsistencies
|
37
|
-
# with characters in the ascii range. (For example,
|
38
|
-
#
|
37
|
+
# The standard encoders (the CGI and URI methods) are not reliable when
|
38
|
+
# the query string is already embedded in the full URL, but the inconsistencies
|
39
|
+
# are limited to issues with characters in the ascii range. (For example,
|
40
|
+
# the '#' if it appears in an unexpected place.) For escaping non-ascii,
|
41
|
+
# they are all OK, so we'll take care to skip the ascii chars.
|
39
42
|
|
40
43
|
return url if url.ascii_only?
|
41
44
|
|
@@ -50,12 +53,15 @@ module Rollbar
|
|
50
53
|
Regexp.new(fields.map { |val| /\A#{Regexp.escape(val.to_s)}\z/ }.join('|'))
|
51
54
|
end
|
52
55
|
|
53
|
-
def filter(url, regex, scrub_user, scrub_password, randomize_scrub_length,
|
56
|
+
def filter(url, regex, scrub_user, scrub_password, randomize_scrub_length,
|
57
|
+
scrub_all, whitelist)
|
54
58
|
uri = URI.parse(url)
|
55
59
|
|
56
60
|
uri.user = filter_user(uri.user, scrub_user, randomize_scrub_length)
|
57
|
-
uri.password = filter_password(uri.password, scrub_password,
|
58
|
-
|
61
|
+
uri.password = filter_password(uri.password, scrub_password,
|
62
|
+
randomize_scrub_length)
|
63
|
+
uri.query = filter_query(uri.query, regex, randomize_scrub_length, scrub_all,
|
64
|
+
whitelist)
|
59
65
|
|
60
66
|
uri.to_s
|
61
67
|
end
|
@@ -73,7 +79,12 @@ module Rollbar
|
|
73
79
|
end
|
74
80
|
|
75
81
|
def filter_password(password, scrub_password, randomize_scrub_length)
|
76
|
-
scrub_password && password
|
82
|
+
if scrub_password && password
|
83
|
+
filtered_value(password,
|
84
|
+
randomize_scrub_length)
|
85
|
+
else
|
86
|
+
password
|
87
|
+
end
|
77
88
|
end
|
78
89
|
|
79
90
|
def filter_query(query, regex, randomize_scrub_length, scrub_all, whitelist)
|
@@ -81,7 +92,8 @@ module Rollbar
|
|
81
92
|
|
82
93
|
params = decode_www_form(query)
|
83
94
|
|
84
|
-
encode_www_form(filter_query_params(params, regex, randomize_scrub_length,
|
95
|
+
encode_www_form(filter_query_params(params, regex, randomize_scrub_length,
|
96
|
+
scrub_all, whitelist))
|
85
97
|
end
|
86
98
|
|
87
99
|
def decode_www_form(query)
|
@@ -95,14 +107,22 @@ module Rollbar
|
|
95
107
|
def restore_square_brackets(query)
|
96
108
|
# We want this to rebuild array params like foo[]=1&foo[]=2
|
97
109
|
#
|
98
|
-
# URI.encode_www_form follows the spec at
|
110
|
+
# URI.encode_www_form follows the spec at
|
111
|
+
# https://url.spec.whatwg.org/#concept-urlencoded-serializer
|
99
112
|
# and percent encodes square brackets. Here we change them back.
|
100
113
|
query.gsub('%5B', '[').gsub('%5D', ']')
|
101
114
|
end
|
102
115
|
|
103
|
-
def filter_query_params(params, regex, randomize_scrub_length, scrub_all,
|
116
|
+
def filter_query_params(params, regex, randomize_scrub_length, scrub_all,
|
117
|
+
whitelist)
|
104
118
|
params.map do |key, value|
|
105
|
-
[key,
|
119
|
+
[key,
|
120
|
+
if filter_key?(key, regex, scrub_all,
|
121
|
+
whitelist)
|
122
|
+
filtered_value(value, randomize_scrub_length)
|
123
|
+
else
|
124
|
+
value
|
125
|
+
end]
|
106
126
|
end
|
107
127
|
end
|
108
128
|
|
@@ -115,10 +135,10 @@ module Rollbar
|
|
115
135
|
random_filtered_value
|
116
136
|
else
|
117
137
|
'*' * (begin
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
138
|
+
value.length
|
139
|
+
rescue StandardError
|
140
|
+
8
|
141
|
+
end)
|
122
142
|
end
|
123
143
|
end
|
124
144
|
|
data/lib/rollbar/scrubbers.rb
CHANGED
@@ -91,7 +91,10 @@ module Rollbar
|
|
91
91
|
def extract_title(body)
|
92
92
|
return body['message']['body'] if body['message'] && body['message']['body']
|
93
93
|
return extract_title_from_trace(body['trace']) if body['trace']
|
94
|
-
|
94
|
+
|
95
|
+
return unless body['trace_chain'] && body['trace_chain'][0]
|
96
|
+
|
97
|
+
extract_title_from_trace(body['trace_chain'][0])
|
95
98
|
end
|
96
99
|
|
97
100
|
def extract_title_from_trace(trace)
|
@@ -24,7 +24,9 @@ module Rollbar
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def delete_trace_chain_extra(body)
|
27
|
-
|
27
|
+
return unless body['trace_chain'] && body['trace_chain'][0]['extra']
|
28
|
+
|
29
|
+
body['trace_chain'][0].delete('extra')
|
28
30
|
end
|
29
31
|
|
30
32
|
def delete_trace_extra(body)
|
data/lib/rollbar/util/hash.rb
CHANGED
@@ -2,9 +2,10 @@ module Rollbar
|
|
2
2
|
module Util
|
3
3
|
module Hash # :nodoc:
|
4
4
|
def self.deep_stringify_keys(hash, seen = {})
|
5
|
-
|
5
|
+
seen.compare_by_identity
|
6
|
+
return if seen[hash]
|
6
7
|
|
7
|
-
seen[hash
|
8
|
+
seen[hash] = true
|
8
9
|
replace_seen_children(hash, seen)
|
9
10
|
|
10
11
|
hash.reduce({}) do |h, (key, value)|
|
@@ -19,10 +20,10 @@ module Rollbar
|
|
19
20
|
when ::Hash
|
20
21
|
send(meth, thing, seen)
|
21
22
|
when Array
|
22
|
-
if seen[thing
|
23
|
+
if seen[thing]
|
23
24
|
thing
|
24
25
|
else
|
25
|
-
seen[thing
|
26
|
+
seen[thing] = true
|
26
27
|
replace_seen_children(thing, seen)
|
27
28
|
thing.map { |v| map_value(v, meth, seen) }
|
28
29
|
end
|
@@ -34,12 +35,18 @@ module Rollbar
|
|
34
35
|
def self.replace_seen_children(thing, seen)
|
35
36
|
case thing
|
36
37
|
when ::Hash
|
37
|
-
thing.keys.each do |key|
|
38
|
-
|
38
|
+
thing.keys.each do |key| # rubocop:disable Style/HashEachMethods
|
39
|
+
if seen[thing[key]]
|
40
|
+
thing[key] =
|
41
|
+
"removed circular reference: #{thing[key]}"
|
42
|
+
end
|
39
43
|
end
|
40
44
|
when Array
|
41
45
|
thing.each_with_index do |_, i|
|
42
|
-
|
46
|
+
if seen[thing[i]]
|
47
|
+
thing[i] =
|
48
|
+
"removed circular reference: #{thing[i]}"
|
49
|
+
end
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
@@ -24,7 +24,7 @@ module Rollbar
|
|
24
24
|
def self.anonymize_ipv6(ip)
|
25
25
|
ip_parts = ip.to_s.split ':'
|
26
26
|
|
27
|
-
ip_string = ip_parts[0..2].join(':')
|
27
|
+
ip_string = "#{ip_parts[0..2].join(':')}:0000:0000:0000:0000:0000"
|
28
28
|
|
29
29
|
IPAddr.new(ip_string).to_s
|
30
30
|
end
|