rollbar 2.9.1 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e042ba30e8f58da588a6120707660687171c9e3f
4
- data.tar.gz: 4d3ca325544cac64b6af94ad19da687cf797aa7c
3
+ metadata.gz: a45a6459fbc4fdc48b10d24d8f789ac3dc6c712a
4
+ data.tar.gz: a6391231fe97e651db01a382a214c3f9cf002310
5
5
  SHA512:
6
- metadata.gz: d1c0e2121b62a668e884ee7f60954b6559d917339552334f9f797aab421483b144d0dff21c924e90617c7359870c98916899f3d4a0f5a21764fd4d2351dacda4
7
- data.tar.gz: a0f60c013d3ad9d49beaeb78cd95a19f4b2fdb56afd4f45a2ae26588d62e41c77c095d04e7b7ce0d59d20c44b6cdd3d47b866cd3ba1622e49d0a1efb92ab9661
6
+ metadata.gz: 75910ee630569144378fdc9bbb3039e514273e335b4b1fca19be9f02ad60158414e396a75e3ee01b05bc3053dd5efed95bb1a3a111357a03ee22c42a41539d69
7
+ data.tar.gz: 45fe74d97b172e168127fac6478d9eeca7e155018a95cc4df7c01aa6823868156297fddedef3da6df93404532604f64d174c2ce28cf2a551dafccf977f3e1873
data/.travis.yml CHANGED
@@ -29,6 +29,8 @@ gemfile:
29
29
  - gemfiles/rails32.gemfile
30
30
  - gemfiles/rails40.gemfile
31
31
  - gemfiles/rails41.gemfile
32
+ - gemfiles/rails42.gemfile
33
+ - gemfiles/rails50.gemfile
32
34
  matrix:
33
35
  allow_failures:
34
36
  - rvm: ruby-head
@@ -72,6 +74,13 @@ matrix:
72
74
  jdk: oraclejdk7
73
75
  - rvm: 2.1.0
74
76
  jdk: oraclejdk8
77
+ - rvm: 2.2.2
78
+ jdk: openjdk6
79
+ - rvm: 2.2.2
80
+ jdk: oraclejdk7
81
+ - rvm: 2.2.2
82
+ jdk: oraclejdk8
83
+
75
84
  - rvm: ruby-head
76
85
  jdk: openjdk6
77
86
  - rvm: ruby-head
@@ -96,6 +105,8 @@ matrix:
96
105
  gemfile: gemfiles/rails41.gemfile
97
106
  - rvm: 1.8.7
98
107
  gemfile: gemfiles/rails42.gemfile
108
+ - rvm: 1.8.7
109
+ gemfile: gemfiles/rails50.gemfile
99
110
  - rvm: 1.9.2
100
111
  gemfile: gemfiles/rails31.gemfile
101
112
  - rvm: 1.9.2
@@ -106,6 +117,14 @@ matrix:
106
117
  gemfile: gemfiles/rails41.gemfile
107
118
  - rvm: 1.9.2
108
119
  gemfile: gemfiles/rails42.gemfile
120
+ - rvm: 1.9.2
121
+ gemfile: gemfiles/rails50.gemfile
122
+ - rvm: 1.9.3
123
+ gemfile: gemfiles/rails50.gemfile
124
+ - rvm: 2.0.0
125
+ gemfile: gemfiles/rails50.gemfile
126
+ - rvm: 2.1.0
127
+ gemfile: gemfiles/rails50.gemfile
109
128
  - rvm: 2.2.2
110
129
  gemfile: gemfiles/rails30.gemfile
111
130
  - rvm: 2.2.2
@@ -134,6 +153,8 @@ matrix:
134
153
  gemfile: gemfiles/rails41.gemfile
135
154
  - rvm: jruby-19mode
136
155
  gemfile: gemfiles/rails42.gemfile
156
+ - rvm: jruby-19mode
157
+ gemfile: gemfiles/rails50.gemfile
137
158
  - rvm: rbx
138
159
  gemfile: gemfiles/rails30.gemfile
139
160
  - rvm: rbx
@@ -146,10 +167,5 @@ matrix:
146
167
  gemfile: gemfiles/rails41.gemfile
147
168
  - rvm: rbx
148
169
  gemfile: gemfiles/rails42.gemfile
149
- gemfile:
150
- - gemfiles/rails30.gemfile
151
- - gemfiles/rails31.gemfile
152
- - gemfiles/rails32.gemfile
153
- - gemfiles/rails40.gemfile
154
- - gemfiles/rails41.gemfile
155
- - gemfiles/rails42.gemfile
170
+ - rvm: rbx
171
+ gemfile: gemfiles/rails50.gemfile
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.10.0
4
+
5
+ New features:
6
+
7
+ - Set the Sidekiq error context to the worker class name. See [#440](https://github.com/rollbar/rollbar-gem/pull/440).
8
+ - Secure headers support for rollbar.js integration. See [#437](https://github.com/rollbar/rollbar-gem/pull/437).
9
+ - Rails 5 support. See [#433](https://github.com/rollbar/rollbar-gem/pull/433).
10
+ - Add scrub all parameters option. See [#431](https://github.com/rollbar/rollbar-gem/pull/431).
11
+ - Add delayed_job async handler. See [#430](https://github.com/rollbar/rollbar-gem/pull/430).
12
+ - Disable logging if Rollbar is disabled. See [#425](https://github.com/rollbar/rollbar-gem/pull/425).
13
+
14
+ Bug fixes:
15
+
16
+ - Add nil check for rake.patch! for future robustness. See [#434](https://github.com/rollbar/rollbar-gem/pull/434).
17
+ - Fix two doc bugs. See [#401](https://github.com/rollbar/rollbar-gem/pull/401).
18
+
3
19
  ## 2.9.1
4
20
 
5
21
  Bug fixes:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.9.1)](https://travis-ci.org/rollbar/rollbar-gem/branches)
1
+ # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.10.0)](https://travis-ci.org/rollbar/rollbar-gem/branches)
2
2
 
3
3
  <!-- RemoveNext -->
4
4
  [Rollbar](https://rollbar.com) is an error tracking service for Ruby and other languages. The Rollbar service will alert you of problems with your code and help you understand them in a ways never possible before. We love it and we hope you will too.
@@ -377,7 +377,6 @@ By default, the notifier will "scrub" the following fields from payloads before
377
377
  - ```:password_confirmation```
378
378
  - ```:secret```
379
379
  - ```:confirm_password```
380
- - ```:password_confirmation```
381
380
  - ```:secret_token```
382
381
 
383
382
  And the following http header
@@ -434,7 +433,7 @@ If you'd like to customize this list, modify the example code in ```config/initi
434
433
 
435
434
  ```ruby
436
435
  config.exception_level_filters.merge!({
437
- 'ActiveRecord::RecordNotFound' => 'ignore',
436
+ 'ActionController::RoutingError' => 'ignore',
438
437
  'NoMethodError' => 'critical'
439
438
  })
440
439
  ```
@@ -589,7 +588,7 @@ Only versions >= 3.0 of delayed_job are supported.
589
588
 
590
589
  ## Asynchronous reporting
591
590
 
592
- By default, all messages are reported synchronously. You can enable asynchronous reporting with [girl_friday](https://github.com/mperham/girl_friday), [sucker_punch](https://github.com/brandonhilkert/sucker_punch), [Sidekiq](https://github.com/mperham/sidekiq), [Resque](https://github.com/resque/resque) or using threading.
591
+ By default, all messages are reported synchronously. You can enable asynchronous reporting with [girl_friday](https://github.com/mperham/girl_friday), [sucker_punch](https://github.com/brandonhilkert/sucker_punch), [Sidekiq](https://github.com/mperham/sidekiq), [Resque](https://github.com/resque/resque), [DelayedJob](https://github.com/collectiveidea/delayed_job) or using threading.
593
592
 
594
593
  ### Using girl_friday
595
594
 
@@ -662,6 +661,14 @@ Now you can just start a new Resque worker processing jobs in that queue:
662
661
  $ QUEUE=my_queue bundle exec resque:work
663
662
  ```
664
663
 
664
+ ### Using DelayedJob
665
+
666
+ Add the following in ```config/initializers/rollbar.rb```:
667
+
668
+ ```ruby
669
+ config.use_delayed_job
670
+ ```
671
+
665
672
  ### Using threading
666
673
 
667
674
  Add the following in ```config/initializers/rollbar.rb```:
@@ -0,0 +1,47 @@
1
+ require 'rubygems/version'
2
+
3
+ source "https://rubygems.org"
4
+
5
+ is_jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
6
+
7
+ gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
8
+ gem 'jruby-openssl', :platform => :jruby
9
+ gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
10
+ gem 'appraisal'
11
+ gem 'rubysl', '~> 2.0', :platform => :rbx
12
+ gem 'racc', :platform => :rbx
13
+ gem 'minitest', :platform => :rbx
14
+ gem 'rubinius-developer_tools', :platform => :rbx
15
+ gem 'rails', '~> 5.0.0.beta1'
16
+
17
+ gem 'rspec-core', '~> 3.5.0.beta3'
18
+ gem 'rspec-rails', '~> 3.5.0.beta3'
19
+ gem 'rspec-support', '~> 3.5.0.beta3'
20
+ gem 'rspec-expectations', '~> 3.5.0.beta3'
21
+ gem 'rspec-mocks', '~> 3.5.0.beta3'
22
+ gem 'rake'
23
+
24
+ gem 'oj', '~> 2.12.14' unless is_jruby
25
+ gem 'sidekiq', '>= 2.13.0' if RUBY_VERSION != '1.8.7'
26
+
27
+ if RUBY_VERSION.start_with?('1.9')
28
+ gem 'sucker_punch', '~> 1.0'
29
+ elsif RUBY_VERSION.start_with?('2')
30
+ gem 'sucker_punch', '~> 2.0'
31
+ end
32
+
33
+ # We need last sinatra that uses rack 2.x
34
+ gem 'sinatra', :git => 'https://github.com/sinatra/sinatra'
35
+ gem 'resque'
36
+ gem 'delayed_job', :require => false
37
+ gem 'redis'
38
+ gem 'database_cleaner', '~> 1.x'
39
+ gem 'girl_friday', '>= 0.11.1'
40
+ gem 'generator_spec'
41
+ gem 'codeclimate-test-reporter', :group => :test, :require => nil
42
+
43
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0')
44
+ gem 'mime-types', '< 3.0'
45
+ end
46
+
47
+ gemspec :path => '../'
data/lib/rollbar.rb CHANGED
@@ -25,10 +25,6 @@ require 'rollbar/exceptions'
25
25
  require 'rollbar/lazy_store'
26
26
 
27
27
  module Rollbar
28
- ATTACHMENT_CLASSES = %w[
29
- ActionDispatch::Http::UploadedFile
30
- Rack::Multipart::UploadedFile
31
- ].freeze
32
28
  PUBLIC_NOTIFIER_METHODS = %w(debug info warn warning error critical log logger
33
29
  process_payload process_from_async_handler scope send_failsafe log_info log_debug
34
30
  log_warning log_error silenced)
@@ -118,6 +118,12 @@ module Rollbar
118
118
  end
119
119
  end
120
120
 
121
+ def use_delayed_job
122
+ require 'rollbar/delay/delayed_job'
123
+ @use_async = true
124
+ @async_handler = Rollbar::Delay::DelayedJob
125
+ end
126
+
121
127
  def use_sidekiq(options = {})
122
128
  require 'rollbar/delay/sidekiq' if defined?(Sidekiq)
123
129
  @use_async = true
@@ -0,0 +1,17 @@
1
+ module Rollbar
2
+ module Delay
3
+ # This class provides the DelayedJob async handler. Users can
4
+ # use DelayedJob in order to send the reports to the Rollbar API
5
+ class DelayedJob
6
+ class << self
7
+ def call(payload)
8
+ new.delay.call(payload)
9
+ end
10
+ end
11
+
12
+ def call(payload)
13
+ Rollbar.process_from_async_handler(payload)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -9,6 +9,24 @@ module Rollbar
9
9
  def prepare
10
10
  return if prepared?
11
11
 
12
+ if secure_headers?
13
+ insert_middleware_after_secure_headers
14
+ else
15
+ insert_middleware
16
+ end
17
+
18
+ self.prepared = true
19
+ end
20
+
21
+ def insert_middleware_after_secure_headers
22
+ instance = self
23
+
24
+ Rollbar::Railtie.initializer 'rollbar.js.frameworks.rails', :after => 'secure_headers.middleware' do |_app|
25
+ instance.insert_middleware
26
+ end
27
+ end
28
+
29
+ def insert_middleware
12
30
  require 'rollbar/js/middleware'
13
31
 
14
32
  config = {
@@ -16,8 +34,10 @@ module Rollbar
16
34
  :enabled => Rollbar.configuration.js_enabled
17
35
  }
18
36
  rails_config.middleware.use(::Rollbar::Js::Middleware, config)
37
+ end
19
38
 
20
- self.prepared = true
39
+ def secure_headers?
40
+ defined?(::SecureHeaders)
21
41
  end
22
42
 
23
43
  def rails_config
@@ -27,7 +27,7 @@ module Rollbar
27
27
  def _call(env, result)
28
28
  return result unless should_add_js?(env, result[0], result[1])
29
29
 
30
- if response_string = add_js(result[2])
30
+ if response_string = add_js(env, result[2])
31
31
  env[JS_IS_INJECTED_KEY] = true
32
32
  response = ::Rack::Response.new(response_string, result[0], result[1])
33
33
 
@@ -67,7 +67,7 @@ module Rollbar
67
67
  env['action_controller.instance'].class.included_modules.include?(ActionController::Live)
68
68
  end
69
69
 
70
- def add_js(response)
70
+ def add_js(env, response)
71
71
  body = join_body(response)
72
72
  close_old_response(response)
73
73
 
@@ -78,9 +78,9 @@ module Rollbar
78
78
 
79
79
  if head_open_end
80
80
  body = body[0..head_open_end] <<
81
- config_js_tag <<
82
- snippet_js_tag <<
83
- body[head_open_end..-1]
81
+ config_js_tag(env) <<
82
+ snippet_js_tag(env) <<
83
+ body[head_open_end + 1..-1]
84
84
  end
85
85
 
86
86
  body
@@ -91,7 +91,7 @@ module Rollbar
91
91
 
92
92
  def find_end_of_head_open(body)
93
93
  head_open = body.index(/<head\W/)
94
- body.index('>', head_open) + 1 if head_open
94
+ body.index('>', head_open) if head_open
95
95
  end
96
96
 
97
97
  def join_body(response)
@@ -104,20 +104,27 @@ module Rollbar
104
104
  response.close if response.respond_to?(:close)
105
105
  end
106
106
 
107
- def config_js_tag
108
- script_tag("var _rollbarConfig = #{config[:options].to_json};")
107
+ def config_js_tag(env)
108
+ script_tag("var _rollbarConfig = #{config[:options].to_json};", env)
109
109
  end
110
110
 
111
- def snippet_js_tag
112
- script_tag(js_snippet)
111
+ def snippet_js_tag(env)
112
+ script_tag(js_snippet, env)
113
113
  end
114
114
 
115
115
  def js_snippet
116
116
  SNIPPET
117
117
  end
118
118
 
119
- def script_tag(content)
120
- html_safe_if_needed("\n<script type=\"text/javascript\">#{content}</script>")
119
+ def script_tag(content, env)
120
+ if defined?(::SecureHeaders)
121
+ nonce = ::SecureHeaders.content_security_policy_script_nonce(::Rack::Request.new(env))
122
+ script_tag_content = "\n<script type=\"text/javascript\" nonce=\"#{nonce}\">#{content}</script>"
123
+ else
124
+ script_tag_content = "\n<script type=\"text/javascript\">#{content}</script>"
125
+ end
126
+
127
+ html_safe_if_needed(script_tag_content)
121
128
  end
122
129
 
123
130
  def html_safe_if_needed(string)
@@ -23,6 +23,8 @@ module Rollbar
23
23
  end
24
24
 
25
25
  def log(level, message)
26
+ return unless Rollbar.configuration.enabled
27
+
26
28
  @object.send(level, message)
27
29
  rescue
28
30
  puts "[Rollbar] Error logging #{level}:"
data/lib/rollbar/rake.rb CHANGED
@@ -20,7 +20,9 @@ module Rollbar
20
20
  end
21
21
 
22
22
  def self.patch?
23
- major, minor, *_ = rake_version.split('.').map(&:to_i)
23
+ return false unless rake_version
24
+
25
+ major, minor, = rake_version.split('.').map(&:to_i)
24
26
 
25
27
  major > 0 || major == 0 && minor > 8
26
28
  end
@@ -1,15 +1,15 @@
1
1
  require 'rack'
2
2
  require 'tempfile'
3
3
 
4
+ require 'rollbar/scrubbers'
4
5
  require 'rollbar/scrubbers/url'
6
+ require 'rollbar/scrubbers/params'
5
7
  require 'rollbar/util/ip_obfuscator'
6
8
 
7
9
  module Rollbar
8
10
  module RequestDataExtractor
9
- SKIPPED_CLASSES = [Tempfile]
10
-
11
11
  def extract_person_data_from_controller(env)
12
- if env.has_key? 'rollbar.person_data'
12
+ if env.has_key?('rollbar.person_data')
13
13
  person_data = env['rollbar.person_data'] || {}
14
14
  else
15
15
  controller = env['action_controller.instance']
@@ -47,24 +47,16 @@ module Rollbar
47
47
  :cookies => cookies,
48
48
  :session => session,
49
49
  :method => rollbar_request_method(env),
50
- :route => route_params,
50
+ :route => route_params
51
51
  }
52
52
 
53
- if env["action_dispatch.request_id"]
54
- data[:request_id] = env["action_dispatch.request_id"]
53
+ if env['action_dispatch.request_id']
54
+ data[:request_id] = env['action_dispatch.request_id']
55
55
  end
56
56
 
57
57
  data
58
58
  end
59
59
 
60
- def rollbar_scrubbed(value)
61
- if Rollbar.configuration.randomize_scrub_length
62
- random_filtered_value
63
- else
64
- '*' * (value.length rescue 8)
65
- end
66
- end
67
-
68
60
  private
69
61
 
70
62
  def mergeable_raw_body_params(rack_req)
@@ -89,7 +81,7 @@ module Rollbar
89
81
  if name == 'Cookie'
90
82
  {}
91
83
  elsif sensitive_headers_list.include?(name)
92
- { name => rollbar_scrubbed(env[header]) }
84
+ { name => Rollbar::Scrubbers.scrub_value(env[header]) }
93
85
  else
94
86
  { name => env[header] }
95
87
  end
@@ -108,8 +100,8 @@ module Rollbar
108
100
 
109
101
  port = env['HTTP_X_FORWARDED_PORT']
110
102
  if port && !(scheme.downcase == 'http' && port.to_i == 80) && \
111
- !(scheme.downcase == 'https' && port.to_i == 443) && \
112
- !(host.include? ':')
103
+ !(scheme.downcase == 'https' && port.to_i == 443) && \
104
+ !(host.include? ':')
113
105
  host = host + ':' + port
114
106
  end
115
107
 
@@ -151,7 +143,7 @@ module Rollbar
151
143
 
152
144
  def json_request?(rack_req)
153
145
  !!(rack_req.env['CONTENT_TYPE'] =~ %r{application/json} ||
154
- rack_req.env['ACCEPT'] =~ /\bjson\b/)
146
+ rack_req.env['ACCEPT'] =~ /\bjson\b/)
155
147
  end
156
148
 
157
149
  def rollbar_request_params(env)
@@ -189,59 +181,15 @@ module Rollbar
189
181
  end
190
182
 
191
183
  def rollbar_filtered_params(sensitive_params, params)
192
- sensitive_params_regexp = Regexp.new(sensitive_params.map{ |val| Regexp.escape(val.to_s).to_s }.join('|'), true)
193
-
194
- return {} unless params
195
-
196
- params.to_hash.inject({}) do |result, (key, value)|
197
- if sensitive_params_regexp =~ Rollbar::Encoding.encode(key).to_s
198
- result[key] = rollbar_scrubbed(value)
199
- elsif value.is_a?(Hash)
200
- result[key] = rollbar_filtered_params(sensitive_params, value)
201
- elsif value.is_a?(Array)
202
- result[key] = value.map do |v|
203
- v.is_a?(Hash) ? rollbar_filtered_params(sensitive_params, v) : rollbar_filtered_param_value(v)
204
- end
205
- elsif skip_value?(value)
206
- result[key] = "Skipped value of class '#{value.class.name}'"
207
- else
208
- result[key] = rollbar_filtered_param_value(value)
209
- end
210
-
211
- result
212
- end
213
- end
214
-
215
- def rollbar_filtered_param_value(value)
216
- if ATTACHMENT_CLASSES.include?(value.class.name)
217
- begin
218
- {
219
- :content_type => value.content_type,
220
- :original_filename => value.original_filename,
221
- :size => value.tempfile.size
222
- }
223
- rescue
224
- 'Uploaded file'
225
- end
226
- else
227
- value
228
- end
184
+ Rollbar::Scrubbers::Params.call(params, sensitive_params)
229
185
  end
230
186
 
231
187
  def sensitive_params_list(env)
232
- Array(Rollbar.configuration.scrub_fields) | Array(env['action_dispatch.parameter_filter'])
188
+ Array(env['action_dispatch.parameter_filter'])
233
189
  end
234
190
 
235
191
  def sensitive_headers_list
236
192
  Rollbar.configuration.scrub_headers || []
237
193
  end
238
-
239
- def random_filtered_value
240
- '*' * (rand(5) + 3)
241
- end
242
-
243
- def skip_value?(value)
244
- SKIPPED_CLASSES.any? { |klass| value.is_a?(klass) }
245
- end
246
194
  end
247
195
  end