rollbar 2.27.1 → 3.1.2

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.
@@ -75,6 +75,7 @@ module Rollbar
75
75
  attr_accessor :files_processed_enabled
76
76
  attr_accessor :files_processed_duration # seconds
77
77
  attr_accessor :files_processed_size # bytes
78
+ attr_accessor :use_payload_access_token
78
79
 
79
80
  attr_reader :project_gem_paths
80
81
  attr_accessor :configured_options
@@ -85,8 +86,10 @@ module Rollbar
85
86
  DEFAULT_WEB_BASE = 'https://rollbar.com'.freeze
86
87
 
87
88
  def initialize
89
+ @access_token = nil
88
90
  @async_handler = nil
89
91
  @before_process = []
92
+ @branch = nil
90
93
  @capture_uncaught = nil
91
94
  @code_version = nil
92
95
  @custom_data_method = nil
@@ -110,6 +113,7 @@ module Rollbar
110
113
  @failover_handlers = []
111
114
  @framework = 'Plain'
112
115
  @ignored_person_ids = []
116
+ @host = nil
113
117
  @payload_options = {}
114
118
  @person_method = 'current_user'
115
119
  @person_id_method = 'id'
@@ -121,6 +125,7 @@ module Rollbar
121
125
  @open_timeout = 3
122
126
  @request_timeout = 3
123
127
  @net_retries = 3
128
+ @root = nil
124
129
  @js_enabled = false
125
130
  @js_options = {}
126
131
  @locals = {}
@@ -150,6 +155,7 @@ module Rollbar
150
155
  @log_payload = false
151
156
  @collect_user_ip = true
152
157
  @anonymize_user_ip = false
158
+ @user_ip_obfuscator_secret = nil
153
159
  @backtrace_cleaner = nil
154
160
  @hooks = {
155
161
  :on_error_response => nil, # params: response
@@ -157,10 +163,12 @@ module Rollbar
157
163
  }
158
164
 
159
165
  @write_to_file = false
166
+ @filepath = nil
160
167
  @files_with_pid_name_enabled = false
161
168
  @files_processed_enabled = false
162
169
  @files_processed_duration = 60
163
170
  @files_processed_size = 5 * 1000 * 1000
171
+ @use_payload_access_token = false
164
172
 
165
173
  @configured_options = ConfiguredOptions.new(self)
166
174
  end
data/lib/rollbar/item.rb CHANGED
@@ -40,7 +40,7 @@ module Rollbar
40
40
  class << self
41
41
  def build_with(payload, options = {})
42
42
  new(options).tap do |item|
43
- item.payload = payload
43
+ item.payload = item.add_access_token_to_payload(payload)
44
44
  end
45
45
  end
46
46
  end
@@ -64,9 +64,7 @@ module Rollbar
64
64
 
65
65
  def build
66
66
  data = build_data
67
- self.payload = {
68
- 'data' => data
69
- }
67
+ self.payload = add_access_token_to_payload({'data' => data})
70
68
 
71
69
  enforce_valid_utf8
72
70
  transform
@@ -166,6 +164,21 @@ module Rollbar
166
164
  configuration.ignored_person_ids.include?(person_id)
167
165
  end
168
166
 
167
+ def add_access_token_to_payload(payload)
168
+ # Some use cases remain where the token is needed in the payload. For example:
169
+ #
170
+ # When using async senders, if the access token is changed dynamically in
171
+ # the main process config, the sender process won't see that change.
172
+ #
173
+ # Until the delayed sender interface is changed to allow passing dynamic config options,
174
+ # this workaround allows the main process to set the token by adding it to the payload.
175
+ if (configuration && configuration.use_payload_access_token)
176
+ payload['access_token'] ||= configuration.access_token
177
+ end
178
+
179
+ payload
180
+ end
181
+
169
182
  private
170
183
 
171
184
  def build_environment
@@ -1,4 +1,3 @@
1
- require 'rollbar/notifier'
2
1
  require 'rollbar/scrubbers/params'
3
2
  require 'rollbar/util'
4
3
 
@@ -10,10 +10,6 @@ module Rollbar
10
10
  mod.const_get(target, inherit)
11
11
  end
12
12
 
13
- def ruby_19?
14
- version?('1.9')
15
- end
16
-
17
13
  def version?(version)
18
14
  numbers = version.split('.')
19
15
 
@@ -21,8 +17,6 @@ module Rollbar
21
17
  end
22
18
 
23
19
  def timeout_exceptions
24
- return [] if ruby_19?
25
-
26
20
  [Net::ReadTimeout, Net::OpenTimeout]
27
21
  end
28
22
  end
@@ -41,8 +41,6 @@ module Rollbar
41
41
  raw[key] = value
42
42
 
43
43
  loaded_data.delete(key)
44
-
45
- value
46
44
  end
47
45
 
48
46
  def data
@@ -76,8 +74,8 @@ module Rollbar
76
74
  super
77
75
  end
78
76
 
79
- def respond_to?(method_sym)
80
- super || raw.respond_to?(method_sym)
77
+ def respond_to_missing?(method_sym, include_all)
78
+ raw.respond_to?(method_sym, include_all)
81
79
  end
82
80
  end
83
81
  end
@@ -183,7 +183,6 @@ module Rollbar
183
183
  req.respond_to?(:content_security_policy) &&
184
184
  req.content_security_policy &&
185
185
  req.content_security_policy.directives['script-src'] &&
186
- !req.content_security_policy.directives['script-src'].include?("'unsafe-inline'") &&
187
186
  req.content_security_policy_nonce
188
187
  end
189
188
 
@@ -224,16 +223,12 @@ module Rollbar
224
223
  end
225
224
 
226
225
  def csp_needs_nonce?(csp)
227
- !opt_out?(csp) && !unsafe_inline?(csp)
226
+ !opt_out?(csp)
228
227
  end
229
228
 
230
229
  def opt_out?(_csp)
231
230
  raise NotImplementedError
232
231
  end
233
-
234
- def unsafe_inline?(csp)
235
- csp[:script_src].to_a.include?("'unsafe-inline'")
236
- end
237
232
  end
238
233
 
239
234
  class SecureHeadersFalse < SecureHeadersResolver
@@ -640,7 +640,11 @@ module Rollbar
640
640
  request = Net::HTTP::Post.new(uri.request_uri)
641
641
 
642
642
  request.body = pack_ruby260_bytes(body)
643
- request.add_field('X-Rollbar-Access-Token', access_token)
643
+
644
+ # Ensure the payload token will be used if the option is set.
645
+ unless (configuration.use_payload_access_token)
646
+ request.add_field('X-Rollbar-Access-Token', access_token)
647
+ end
644
648
 
645
649
  handle_net_retries { http.request(request) }
646
650
  end
@@ -698,8 +702,6 @@ module Rollbar
698
702
  end
699
703
 
700
704
  def handle_net_retries
701
- return yield if skip_retries?
702
-
703
705
  retries = configuration.net_retries - 1
704
706
 
705
707
  begin
@@ -713,10 +715,6 @@ module Rollbar
713
715
  end
714
716
  end
715
717
 
716
- def skip_retries?
717
- Rollbar::LanguageSupport.ruby_19?
718
- end
719
-
720
718
  def handle_response(response)
721
719
  if response.code == '200'
722
720
  log_info '[Rollbar] Success'
@@ -1,13 +1,14 @@
1
1
  Rollbar.plugins.define('thread') do
2
- execute do
3
- Thread.class_eval do
4
- def initialize_with_rollbar(*args, &block)
2
+ module Rollbar
3
+ module ThreadPlugin
4
+ def initialize(*args)
5
5
  self[:_rollbar_notifier] ||= Rollbar.notifier.scope
6
- initialize_without_rollbar(*args, &block)
6
+ super
7
7
  end
8
-
9
- alias_method :initialize_without_rollbar, :initialize
10
- alias_method :initialize, :initialize_with_rollbar
11
8
  end
12
9
  end
10
+
11
+ execute do
12
+ Thread.send(:prepend, Rollbar::ThreadPlugin) # rubocop:disable Lint/SendWithMixinArgument
13
+ end
13
14
  end
@@ -13,7 +13,7 @@ module Rollbar
13
13
  end
14
14
 
15
15
  def call(options = {})
16
- url = options[:url]
16
+ url = ascii_encode(options[:url])
17
17
 
18
18
  filter(url,
19
19
  build_regex(options[:scrub_fields]),
@@ -29,6 +29,20 @@ module Rollbar
29
29
 
30
30
  private
31
31
 
32
+ def ascii_encode(url)
33
+ # In some cases non-ascii characters won't be properly encoded, so we do it here.
34
+ #
35
+ # The standard encoders (the CGI and URI methods) are not reliable when the query string
36
+ # is already embedded in the full URL, but the inconsistencies are limited to issues
37
+ # with characters in the ascii range. (For example, the '#' if it appears in an unexpected place.)
38
+ # For escaping non-ascii, they are all OK, so we'll take care to skip the ascii chars.
39
+
40
+ return url if url.ascii_only?
41
+
42
+ # Iterate each char and only escape non-ascii characters.
43
+ url.each_char.map { |c| c.ascii_only? ? c : CGI.escape(c) }.join
44
+ end
45
+
32
46
  def build_whitelist_regex(whitelist)
33
47
  fields = whitelist.find_all { |f| f.is_a?(String) || f.is_a?(Symbol) }
34
48
  return unless fields.any?
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.27.1'.freeze
2
+ VERSION = '3.1.2'.freeze
3
3
  end
data/rollbar.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.files += ['spec/support/rollbar_api.rb'] # useful helper for app spec/tests.
17
17
  gem.name = 'rollbar'
18
18
  gem.require_paths = ['lib']
19
- gem.required_ruby_version = '>= 1.9.3'
19
+ gem.required_ruby_version = '>= 2.0.0'
20
20
  gem.version = Rollbar::VERSION
21
21
 
22
22
  if gem.respond_to?(:metadata)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.27.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-28 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easy and powerful exception tracking for Ruby
14
14
  email:
@@ -20,10 +20,10 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - ".codeclimate.yml"
22
22
  - ".github/pull_request_template.md"
23
+ - ".github/workflows/ci.yml"
23
24
  - ".gitignore"
24
25
  - ".gitmodules"
25
26
  - ".rubocop.yml"
26
- - ".travis.yml"
27
27
  - Appraisals
28
28
  - CHANGELOG.md
29
29
  - Gemfile
@@ -47,6 +47,7 @@ files:
47
47
  - gemfiles/rails51.gemfile
48
48
  - gemfiles/rails52.gemfile
49
49
  - gemfiles/rails60.gemfile
50
+ - gemfiles/rails61.gemfile
50
51
  - lib/generators/rollbar/rollbar_generator.rb
51
52
  - lib/generators/rollbar/templates/initializer.rb
52
53
  - lib/rails/rollbar_runner.rb
@@ -153,14 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
154
  requirements:
154
155
  - - ">="
155
156
  - !ruby/object:Gem::Version
156
- version: 1.9.3
157
+ version: 2.0.0
157
158
  required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  requirements:
159
160
  - - ">="
160
161
  - !ruby/object:Gem::Version
161
162
  version: '0'
162
163
  requirements: []
163
- rubygems_version: 3.1.2
164
+ rubygems_version: 3.2.3
164
165
  signing_key:
165
166
  specification_version: 4
166
167
  summary: Reports exceptions to Rollbar
data/.travis.yml DELETED
@@ -1,284 +0,0 @@
1
- sudo: false
2
- dist: trusty
3
- services:
4
- - redis-server
5
- language: ruby
6
-
7
- rvm:
8
- - 1.9.3
9
- - 2.0.0
10
- - 2.1.0
11
- - 2.2.2
12
- - 2.3.8
13
- - 2.4.5
14
- - 2.5.3
15
- - 2.6.5
16
- - 2.7.0
17
- - rbx
18
- # Travis's own rvm installer is failing on JRuby builds, TODO: reenable when fixed.
19
- # - jruby-9.1.9.0
20
-
21
- #
22
- # # About legacy JRuby
23
- #
24
- # Legacy JRubies (jruby-18mode, jruby-19mode) have been disabled for some time by
25
- # listing all possible targets in either the exclude or allow_failures sections.
26
- # I have taken a look at getting them running, and have found that no valid
27
- # combination of dependencies is possible for Rails 3.0 and higher. It appears
28
- # Rails 2.2 is meant to work, though I haven't tried it.
29
- #
30
- # For Rails 3.0, it is possible to get a working bundle with all gem dependencies,
31
- # but the JDBC adapter gem needs an earlier version of ActiveSupport, and it will
32
- # fail at runtime.
33
- #
34
- # For Rails 3.1 and 3.2, Rack 1.3.x and higher require Ruby 2.x, while Rails 3.x will
35
- # not accept any 1.2.x version of Rack. Even if this could be resolved, one would
36
- # hit the above runtime issue amyway.
37
- #
38
- # # About current JRuby
39
- #
40
- # While current JRuby builds aim to be Ruby 2.5.x compatible, the JDBC adapter
41
- # gem is constrained to only Rails 5.0, 5.1 and 5.2 at this time. (Old versions
42
- # of the gem allow >= Rails 2.2, but in practice it will not work with Rails 3.0
43
- # and higher because of the ActiveSupport issue described above.) For as long as
44
- # the test suite relies on Rails and SqlLite, it is not possible to include
45
- # earlier Rails for JRuby.
46
-
47
- jdk:
48
- # These are the JDKs currently supported on Travis (Trusty - Ubuntu 14.04)
49
- - openjdk7
50
- - openjdk8
51
- - oraclejdk8
52
- - oraclejdk9
53
- gemfile:
54
- - gemfiles/rails30.gemfile
55
- - gemfiles/rails31.gemfile
56
- - gemfiles/rails32.gemfile
57
- - gemfiles/rails40.gemfile
58
- - gemfiles/rails41.gemfile
59
- - gemfiles/rails42.gemfile
60
- - gemfiles/rails50.gemfile
61
- - gemfiles/rails51.gemfile
62
- - gemfiles/rails52.gemfile
63
- - gemfiles/rails60.gemfile
64
- matrix:
65
- include: []
66
-
67
- allow_failures:
68
- - rvm: ruby-head
69
- - rvm: jruby-head
70
- # oraclejdk9 has a dependency issue that needs to be investigated
71
- - jdk: oraclejdk9
72
-
73
- exclude:
74
- # Don't run tests for non-jruby environments with the JDK.
75
- # NOTE: openjdk7 is missing from these exclusions so that Travis will run at least 1 build for the given rvm.
76
- - rvm: 1.9.3
77
- jdk: openjdk8
78
- - rvm: 1.9.3
79
- jdk: oraclejdk8
80
- - rvm: 1.9.3
81
- jdk: oraclejdk9
82
- - rvm: 2.0.0
83
- jdk: openjdk8
84
- - rvm: 2.0.0
85
- jdk: oraclejdk8
86
- - rvm: 2.0.0
87
- jdk: oraclejdk9
88
- - rvm: 2.1.0
89
- jdk: openjdk8
90
- - rvm: 2.1.0
91
- jdk: oraclejdk8
92
- - rvm: 2.1.0
93
- jdk: oraclejdk9
94
- - rvm: 2.2.2
95
- jdk: openjdk8
96
- - rvm: 2.2.2
97
- jdk: oraclejdk8
98
- - rvm: 2.2.2
99
- jdk: oraclejdk9
100
- - rvm: 2.3.8
101
- jdk: openjdk8
102
- - rvm: 2.3.8
103
- jdk: oraclejdk8
104
- - rvm: 2.3.8
105
- jdk: oraclejdk9
106
- - rvm: 2.4.5
107
- jdk: openjdk8
108
- - rvm: 2.4.5
109
- jdk: oraclejdk8
110
- - rvm: 2.4.5
111
- jdk: oraclejdk9
112
- - rvm: 2.5.3
113
- jdk: openjdk8
114
- - rvm: 2.5.3
115
- jdk: oraclejdk8
116
- - rvm: 2.5.3
117
- jdk: oraclejdk9
118
- - rvm: 2.6.5
119
- jdk: openjdk8
120
- - rvm: 2.6.5
121
- jdk: oraclejdk8
122
- - rvm: 2.6.5
123
- jdk: oraclejdk9
124
- - rvm: 2.7.0
125
- jdk: openjdk8
126
- - rvm: 2.7.0
127
- jdk: oraclejdk8
128
- - rvm: 2.7.0
129
- jdk: oraclejdk9
130
-
131
- - rvm: ruby-head
132
- jdk: openjdk8
133
- - rvm: ruby-head
134
- jdk: oraclejdk8
135
- - rvm: ruby-head
136
- jdk: oraclejdk9
137
- - rvm: rbx
138
- jdk: openjdk8
139
- - rvm: rbx
140
- jdk: oraclejdk8
141
- - rvm: rbx
142
- jdk: oraclejdk9
143
-
144
- # Rails 6.x requires Ruby 2.5.0 or higher
145
- - rvm: 2.2.2
146
- gemfile: gemfiles/rails60.gemfile
147
- - rvm: 2.3.8
148
- gemfile: gemfiles/rails60.gemfile
149
- - rvm: 2.4.5
150
- gemfile: gemfiles/rails60.gemfile
151
- # Rails 5.x requires Ruby 2.2.2 or higher
152
- - rvm: 1.9.3
153
- gemfile: gemfiles/rails50.gemfile
154
- - rvm: 1.9.3
155
- gemfile: gemfiles/rails51.gemfile
156
- - rvm: 1.9.3
157
- gemfile: gemfiles/rails52.gemfile
158
- - rvm: 1.9.3
159
- gemfile: gemfiles/rails60.gemfile
160
- # Rails 5.x requires Ruby 2.2.2 or higher
161
- - rvm: 2.0.0
162
- gemfile: gemfiles/rails50.gemfile
163
- - rvm: 2.0.0
164
- gemfile: gemfiles/rails51.gemfile
165
- - rvm: 2.0.0
166
- gemfile: gemfiles/rails52.gemfile
167
- - rvm: 2.0.0
168
- gemfile: gemfiles/rails60.gemfile
169
- # Rails 5.x requires Ruby 2.2.2 or higher
170
- - rvm: 2.1.0
171
- gemfile: gemfiles/rails50.gemfile
172
- - rvm: 2.1.0
173
- gemfile: gemfiles/rails51.gemfile
174
- - rvm: 2.1.0
175
- gemfile: gemfiles/rails52.gemfile
176
- - rvm: 2.1.0
177
- gemfile: gemfiles/rails60.gemfile
178
- # MRI 2.2.2 supports Rails 3.2.x and higher, except Rails 5.2.4 and higher*
179
- # * ActionDispatch 5.2.4 uses Ruby 3.x safe navigation operator.
180
- - rvm: 2.2.2
181
- gemfile: gemfiles/rails30.gemfile
182
- - rvm: 2.2.2
183
- gemfile: gemfiles/rails31.gemfile
184
- - rvm: 2.2.2
185
- gemfile: gemfiles/rails52.gemfile
186
- # MRI 2.3.x supports Rails 4.0.x and higher
187
- - rvm: 2.3.8
188
- gemfile: gemfiles/rails30.gemfile
189
- - rvm: 2.3.8
190
- gemfile: gemfiles/rails31.gemfile
191
- - rvm: 2.3.8
192
- gemfile: gemfiles/rails32.gemfile
193
- - rvm: 2.3.8
194
- gemfile: gemfiles/rails40.gemfile
195
- - rvm: 2.3.8
196
- gemfile: gemfiles/rails41.gemfile
197
- # MRI 2.4.x and higher (e.g. 2.5.x, 2.6.x, etc) supports Rails 4.2.8 and higher
198
- # Rails lower than 4.2.8 is incompatible with Ruby 2.4 Integer class
199
- - rvm: 2.4.5
200
- gemfile: gemfiles/rails30.gemfile
201
- - rvm: 2.4.5
202
- gemfile: gemfiles/rails31.gemfile
203
- - rvm: 2.4.5
204
- gemfile: gemfiles/rails32.gemfile
205
- - rvm: 2.4.5
206
- gemfile: gemfiles/rails40.gemfile
207
- - rvm: 2.4.5
208
- gemfile: gemfiles/rails41.gemfile
209
- - rvm: 2.5.3
210
- gemfile: gemfiles/rails30.gemfile
211
- - rvm: 2.5.3
212
- gemfile: gemfiles/rails31.gemfile
213
- - rvm: 2.5.3
214
- gemfile: gemfiles/rails32.gemfile
215
- - rvm: 2.5.3
216
- gemfile: gemfiles/rails40.gemfile
217
- - rvm: 2.5.3
218
- gemfile: gemfiles/rails41.gemfile
219
- - rvm: 2.6.5
220
- gemfile: gemfiles/rails30.gemfile
221
- - rvm: 2.6.5
222
- gemfile: gemfiles/rails31.gemfile
223
- - rvm: 2.6.5
224
- gemfile: gemfiles/rails32.gemfile
225
- - rvm: 2.6.5
226
- gemfile: gemfiles/rails40.gemfile
227
- - rvm: 2.6.5
228
- gemfile: gemfiles/rails41.gemfile
229
- - rvm: 2.6.5
230
- gemfile: gemfiles/rails42.gemfile
231
- # Rails 6.x tries to be compatible with Ruby 2.7, though
232
- # it still throws a lot of warnings. No point testing earlier
233
- # Rails with Ruby 2.7.
234
- - rvm: 2.7.0
235
- gemfile: gemfiles/rails30.gemfile
236
- - rvm: 2.7.0
237
- gemfile: gemfiles/rails31.gemfile
238
- - rvm: 2.7.0
239
- gemfile: gemfiles/rails32.gemfile
240
- - rvm: 2.7.0
241
- gemfile: gemfiles/rails40.gemfile
242
- - rvm: 2.7.0
243
- gemfile: gemfiles/rails41.gemfile
244
- - rvm: 2.7.0
245
- gemfile: gemfiles/rails42.gemfile
246
- - rvm: 2.7.0
247
- gemfile: gemfiles/rails50.gemfile
248
- - rvm: 2.7.0
249
- gemfile: gemfiles/rails51.gemfile
250
- - rvm: 2.7.0
251
- gemfile: gemfiles/rails52.gemfile
252
- # JRuby JDBC Adapter is only compatible with Rails >= 5.x
253
- - rvm: jruby-9.1.9.0
254
- gemfile: gemfiles/rails30.gemfile
255
- - rvm: jruby-9.1.9.0
256
- gemfile: gemfiles/rails31.gemfile
257
- - rvm: jruby-9.1.9.0
258
- gemfile: gemfiles/rails32.gemfile
259
- - rvm: jruby-9.1.9.0
260
- gemfile: gemfiles/rails40.gemfile
261
- - rvm: jruby-9.1.9.0
262
- gemfile: gemfiles/rails41.gemfile
263
- - rvm: jruby-9.1.9.0
264
- gemfile: gemfiles/rails42.gemfile
265
- - rvm: rbx
266
- gemfile: gemfiles/rails30.gemfile
267
- - rvm: rbx
268
- gemfile: gemfiles/rails31.gemfile
269
- - rvm: rbx
270
- gemfile: gemfiles/rails32.gemfile
271
- - rvm: rbx
272
- gemfile: gemfiles/rails40.gemfile
273
- - rvm: rbx
274
- gemfile: gemfiles/rails41.gemfile
275
- - rvm: rbx
276
- gemfile: gemfiles/rails42.gemfile
277
- - rvm: rbx
278
- gemfile: gemfiles/rails50.gemfile
279
- - rvm: rbx
280
- gemfile: gemfiles/rails51.gemfile
281
- - rvm: rbx
282
- gemfile: gemfiles/rails52.gemfile
283
- - rvm: rbx
284
- gemfile: gemfiles/rails60.gemfile