rollbar 2.15.6 → 2.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +2 -2
- data/THANKS.md +1 -0
- data/docs/configuration.md +4 -0
- data/lib/generators/rollbar/templates/initializer.rb +6 -4
- data/lib/rollbar/configuration.rb +6 -2
- data/lib/rollbar/request_data_extractor.rb +4 -0
- data/lib/rollbar/scrubbers/params.rb +2 -2
- data/lib/rollbar/tasks/rollbar.cap +13 -3
- data/lib/rollbar/util/ip_anonymizer.rb +32 -0
- data/lib/rollbar/version.rb +1 -1
- data/spec/controllers/home_controller_spec.rb +32 -6
- data/spec/dummyapp/config/initializers/rollbar.rb +6 -4
- data/spec/rollbar/request_data_extractor_spec.rb +24 -0
- data/spec/rollbar/util/ip_anonymizer_spec.rb +30 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11bd20d68ff24396b75b8518ea2ffbe641cfd8fc
|
4
|
+
data.tar.gz: c3838b31c21856ad31abe72f82b96edeff3a8eda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea80cb9c0b5d102bdd16b784e531efbb7c74ba771da22a63d64d2b34c8ada1dec0ad95db2974267ec33c6cee4ad49c24450b39f4c1859391ab8483aa6dd7efd
|
7
|
+
data.tar.gz: ac2f51581aeca7f5af213f79651a1123e4e8a5810ac9bf8e6298b05cb57bf205de773246b717d554ace0b42d02b8a4aa3e0e14d78a9d9a6555d0351f3ec2104f
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
- Add documentation note for usage of `Rollbar.scope!` to `README.md` [#653](https://github.com/rollbar/rollbar-gem/issues/653)
|
11
11
|
- Add example of using `Grape` to deal with `500` responses status [#645](https://github.com/rollbar/rollbar-gem/issues/645)
|
12
12
|
- Always report errors from `delayed_job` to deal with `dj_threshold > 0` edge case [#615](https://github.com/rollbar/rollbar-gem/issues/615)
|
13
|
+
- Fix "Empty message" items for exceptions reported from JRuby [#658]
|
13
14
|
|
14
15
|
## 2.15.5
|
15
16
|
|
data/README.md
CHANGED
@@ -379,8 +379,8 @@ If the methods to extract the ```id```, ```username```, and ```email``` from the
|
|
379
379
|
```ruby
|
380
380
|
Rollbar.configure do |config|
|
381
381
|
config.person_id_method = "user_id" # default is "id"
|
382
|
-
config.person_username_method = "user_name" # default is
|
383
|
-
config.person_email_method = "email_address" # default is
|
382
|
+
config.person_username_method = "user_name" # default is `nil`
|
383
|
+
config.person_email_method = "email_address" # default is `nil`
|
384
384
|
end
|
385
385
|
```
|
386
386
|
|
data/THANKS.md
CHANGED
@@ -25,6 +25,7 @@ Huge thanks to the following contributors (by github username). For the most up-
|
|
25
25
|
- [jeremyvdw](https://github.com/jeremyvdw)
|
26
26
|
- [jjb](https://github.com/jjb)
|
27
27
|
- [johnknott](https://github.com/johnknott)
|
28
|
+
- [johnsyweb](https://github.com/johnsyweb)
|
28
29
|
- [jonah-williams](https://github.com/jonah-williams)
|
29
30
|
- [jondeandres](https://github.com/jondeandres)
|
30
31
|
- [JoshuaOSHickman](https://github.com/JoshuaOSHickman)
|
data/docs/configuration.md
CHANGED
@@ -174,12 +174,16 @@ if `person_method` not present.
|
|
174
174
|
|
175
175
|
### person_username_method
|
176
176
|
|
177
|
+
**Default** `nil`
|
178
|
+
|
177
179
|
A string or symbol giving the name of the method on the user instance that
|
178
180
|
returns the person's username. Gets called on the result of `person_method`.
|
179
181
|
Ignored if `person_method` not present.
|
180
182
|
|
181
183
|
### person_email_method
|
182
184
|
|
185
|
+
**Default** `nil`
|
186
|
+
|
183
187
|
A string or symbol giving the name of the method on the user instance that
|
184
188
|
returns the person's email. Gets called on the result of `person_method`.
|
185
189
|
Ignored if `person_method` not present.
|
@@ -19,12 +19,14 @@ Rollbar.configure do |config|
|
|
19
19
|
<%- end -%>
|
20
20
|
|
21
21
|
# By default, Rollbar will try to call the `current_user` controller method
|
22
|
-
# to fetch the logged-in user object, and then call that object's `id
|
23
|
-
#
|
22
|
+
# to fetch the logged-in user object, and then call that object's `id`
|
23
|
+
# method to fetch this property. To customize:
|
24
24
|
# config.person_method = "my_current_user"
|
25
25
|
# config.person_id_method = "my_id"
|
26
|
-
|
27
|
-
#
|
26
|
+
|
27
|
+
# Additionally, you may specify the following:
|
28
|
+
# config.person_username_method = "username"
|
29
|
+
# config.person_email_method = "email"
|
28
30
|
|
29
31
|
# If you want to attach custom data to all exception and message reports,
|
30
32
|
# provide a lambda like the following. It should return a hash.
|
@@ -43,6 +43,8 @@ module Rollbar
|
|
43
43
|
attr_accessor :scrub_fields
|
44
44
|
attr_accessor :scrub_user
|
45
45
|
attr_accessor :scrub_password
|
46
|
+
attr_accessor :collect_user_ip
|
47
|
+
attr_accessor :anonymize_user_ip
|
46
48
|
attr_accessor :user_ip_obfuscator_secret
|
47
49
|
attr_accessor :randomize_scrub_length
|
48
50
|
attr_accessor :uncaught_exception_level
|
@@ -90,8 +92,8 @@ module Rollbar
|
|
90
92
|
@payload_options = {}
|
91
93
|
@person_method = 'current_user'
|
92
94
|
@person_id_method = 'id'
|
93
|
-
@person_username_method =
|
94
|
-
@person_email_method =
|
95
|
+
@person_username_method = nil
|
96
|
+
@person_email_method = nil
|
95
97
|
@project_gems = []
|
96
98
|
@populate_empty_backtraces = false
|
97
99
|
@report_dj_data = true
|
@@ -120,6 +122,8 @@ module Rollbar
|
|
120
122
|
@project_gem_paths = []
|
121
123
|
@use_exception_level_filters_default = false
|
122
124
|
@proxy = nil
|
125
|
+
@collect_user_ip = true
|
126
|
+
@anonymize_user_ip = false
|
123
127
|
end
|
124
128
|
|
125
129
|
def initialize_copy(orig)
|
@@ -5,6 +5,7 @@ require 'rollbar/scrubbers'
|
|
5
5
|
require 'rollbar/scrubbers/url'
|
6
6
|
require 'rollbar/scrubbers/params'
|
7
7
|
require 'rollbar/util/ip_obfuscator'
|
8
|
+
require 'rollbar/util/ip_anonymizer'
|
8
9
|
require 'rollbar/json'
|
9
10
|
|
10
11
|
module Rollbar
|
@@ -131,8 +132,11 @@ module Rollbar
|
|
131
132
|
end
|
132
133
|
|
133
134
|
def rollbar_user_ip(env)
|
135
|
+
return nil unless Rollbar.configuration.collect_user_ip
|
134
136
|
user_ip_string = (env['action_dispatch.remote_ip'] || env['HTTP_X_REAL_IP'] || x_forwarded_for_client(env['HTTP_X_FORWARDED_FOR']) || env['REMOTE_ADDR']).to_s
|
135
137
|
|
138
|
+
user_ip_string = Rollbar::Util::IPAnonymizer.anonymize_ip(user_ip_string)
|
139
|
+
|
136
140
|
Rollbar::Util::IPObfuscator.obfuscate_ip(user_ip_string)
|
137
141
|
rescue
|
138
142
|
nil
|
@@ -3,9 +3,9 @@ require 'rollbar/scrubbers'
|
|
3
3
|
|
4
4
|
module Rollbar
|
5
5
|
module Scrubbers
|
6
|
-
# This class contains the logic to scrub the
|
6
|
+
# This class contains the logic to scrub the received parameters. It will
|
7
7
|
# scrub the parameters matching Rollbar.configuration.scrub_fields Array.
|
8
|
-
# Also, if that configuration option is
|
8
|
+
# Also, if that configuration option is set to :scrub_all, it will scrub all
|
9
9
|
# received parameters
|
10
10
|
class Params
|
11
11
|
SKIPPED_CLASSES = [::Tempfile]
|
@@ -32,7 +32,7 @@ namespace :rollbar do
|
|
32
32
|
desc 'Upload sourcemaps to Rollbar.'
|
33
33
|
task :sourcemap do
|
34
34
|
on primary fetch(:rollbar_role) do
|
35
|
-
info "Uploading source maps
|
35
|
+
info "Uploading source maps"
|
36
36
|
warn("You need to upgrade capistrano to '>= 3.1' version in order to correctly upload sourcemaps to Rollbar. (On 3.0, the reported revision will be incorrect.)") if Capistrano::VERSION =~ /^3\.0/
|
37
37
|
url_base = fetch(:rollbar_sourcemaps_minified_url_base)
|
38
38
|
unless url_base
|
@@ -42,11 +42,21 @@ namespace :rollbar do
|
|
42
42
|
url_base = "http://#{url_base}" unless url_base.index(/https?:\/\//)
|
43
43
|
within release_path do
|
44
44
|
within 'public' do
|
45
|
-
source_maps = capture(:find, '-name', "'*.js.map'").split("\n")
|
45
|
+
source_maps = capture(:find, '-L', '.', '-name', "'*.js.map'").split("\n")
|
46
46
|
source_maps = source_maps.map { |file| file.gsub(/^\.\//, '') }
|
47
47
|
source_maps.each do |source_map|
|
48
48
|
minified_url = File.join(url_base, source_map)
|
49
|
-
|
49
|
+
args = *%W(--silent https://api.rollbar.com/api/1/sourcemap -F access_token=#{fetch(:rollbar_token)} -F version=#{fetch(:rollbar_revision)} -F minified_url=#{minified_url} -F source_map=@./#{source_map})
|
50
|
+
info "curl #{args.join(' ')}" # log the command, since capture doesn't output anything
|
51
|
+
api_response_body = capture(:curl, args)
|
52
|
+
begin
|
53
|
+
api_response_json = JSON.parse(api_response_body)
|
54
|
+
if api_response_json["err"] != 0
|
55
|
+
warn "Error uploading sourcemaps: #{api_response_json["message"] || 'Unknown Error'}"
|
56
|
+
end
|
57
|
+
rescue JSON::ParserError => e
|
58
|
+
warn "Error parsing response: #{e.message}. Response body: #{api_response_body}"
|
59
|
+
end
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Rollbar
|
2
|
+
module Util
|
3
|
+
module IPAnonymizer
|
4
|
+
require 'ipaddr'
|
5
|
+
|
6
|
+
def self.anonymize_ip(ip_string)
|
7
|
+
return ip_string unless Rollbar.configuration.anonymize_user_ip
|
8
|
+
ip = IPAddr.new(ip_string)
|
9
|
+
return anonymize_ipv6 ip if ip.ipv6?
|
10
|
+
return anonymize_ipv4 ip if ip.ipv4?
|
11
|
+
rescue
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.anonymize_ipv4(ip)
|
16
|
+
ip_parts = ip.to_s.split '.'
|
17
|
+
|
18
|
+
ip_parts[ip_parts.count - 1] = '0'
|
19
|
+
|
20
|
+
IPAddr.new(ip_parts.join('.')).to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.anonymize_ipv6(ip)
|
24
|
+
ip_parts = ip.to_s.split ':'
|
25
|
+
|
26
|
+
ip_string = ip_parts[0..2].join(':') + ':0000:0000:0000:0000:0000'
|
27
|
+
|
28
|
+
IPAddr.new(ip_string).to_s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/rollbar/version.rb
CHANGED
@@ -335,14 +335,40 @@ describe HomeController do
|
|
335
335
|
|
336
336
|
before { cookies[:session_id] = user.id }
|
337
337
|
|
338
|
-
|
339
|
-
put '/report_exception', *wrap_process_args(
|
338
|
+
subject(:person_data) do
|
339
|
+
put '/report_exception', *wrap_process_args('foo' => 'bar')
|
340
340
|
|
341
|
-
|
341
|
+
Rollbar.last_report[:person]
|
342
|
+
end
|
342
343
|
|
343
|
-
|
344
|
-
|
345
|
-
|
344
|
+
context 'default' do
|
345
|
+
it 'sends the current user data excluding personally identifiable information' do
|
346
|
+
expect(person_data).to eq(:id => user.id,
|
347
|
+
:email => nil,
|
348
|
+
:username => nil)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
context 'without EU GDPR subjects' do
|
353
|
+
context 'configured to send email addresses' do
|
354
|
+
before { Rollbar.configure { |config| config.person_email_method = 'email' } }
|
355
|
+
|
356
|
+
it 'sends the current user data including email address' do
|
357
|
+
expect(person_data).to eq(:id => user.id,
|
358
|
+
:email => 'foo@bar.com',
|
359
|
+
:username => nil)
|
360
|
+
end
|
361
|
+
|
362
|
+
context 'configured to send email addresses and username' do
|
363
|
+
before { Rollbar.configure { |config| config.person_username_method = 'username' } }
|
364
|
+
|
365
|
+
it 'sends the current user data including email address and username' do
|
366
|
+
expect(person_data).to eq(:id => user.id,
|
367
|
+
:email => 'foo@bar.com',
|
368
|
+
:username => 'the_username')
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
346
372
|
end
|
347
373
|
end
|
348
374
|
end
|
@@ -7,12 +7,14 @@ Rollbar.configure do |config|
|
|
7
7
|
:foo => :bar
|
8
8
|
}
|
9
9
|
# By default, Rollbar will try to call the `current_user` controller method
|
10
|
-
# to fetch the logged-in user object, and then call that object's `id
|
11
|
-
#
|
10
|
+
# to fetch the logged-in user object, and then call that object's `id`
|
11
|
+
# method to fetch this property. To customize:
|
12
12
|
# config.person_method = "my_current_user"
|
13
13
|
# config.person_id_method = "my_id"
|
14
|
-
|
15
|
-
#
|
14
|
+
|
15
|
+
# Additionally, you may specify the following:
|
16
|
+
# config.person_username_method = "username"
|
17
|
+
# config.person_email_method = "email"
|
16
18
|
|
17
19
|
# Add exception class names to the exception_level_filters hash to
|
18
20
|
# change the level that exception is reported at. Note that if an exception
|
@@ -138,6 +138,30 @@ describe Rollbar::RequestDataExtractor do
|
|
138
138
|
|
139
139
|
expect(result[:user_ip]).to be_eql('2.2.2.2')
|
140
140
|
end
|
141
|
+
|
142
|
+
context 'with collect_user_ip configuration option disabled' do
|
143
|
+
before do
|
144
|
+
Rollbar.configuration.collect_user_ip = false
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'does not extract user\'s IP' do
|
148
|
+
result = subject.extract_request_data_from_rack(env)
|
149
|
+
|
150
|
+
expect(result[:user_ip]).to be_nil
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'with anonymize_user_ip configuration option enabled' do
|
155
|
+
before do
|
156
|
+
Rollbar.configuration.anonymize_user_ip = true
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'it anonymizes the IPv4 address' do
|
160
|
+
result = subject.extract_request_data_from_rack(env)
|
161
|
+
|
162
|
+
expect(result[:user_ip]).to be_eql('2.2.2.0')
|
163
|
+
end
|
164
|
+
end
|
141
165
|
end
|
142
166
|
|
143
167
|
context 'with private first client IP' do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rollbar/util/ip_anonymizer'
|
3
|
+
|
4
|
+
describe Rollbar::Util::IPAnonymizer do
|
5
|
+
|
6
|
+
before do
|
7
|
+
Rollbar.configuration.anonymize_user_ip = true
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'with IPv4 address' do
|
11
|
+
let(:ip) { '127.0.0.1' }
|
12
|
+
|
13
|
+
it 'anonymizes the IP by replacing the last octet with 0' do
|
14
|
+
anonymized_ip = described_class.anonymize_ip(ip)
|
15
|
+
|
16
|
+
expect(anonymized_ip).to be_eql(IPAddr.new('127.0.0.0').to_s)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with IPv6 address' do
|
21
|
+
let(:ip) { '2001:0db8:85a3:0000:0000:8a2e:0370:7334' }
|
22
|
+
|
23
|
+
it 'anonymizes the IP by replacing the last 80 bits with 0' do
|
24
|
+
|
25
|
+
anonymized_ip = described_class.anonymize_ip(ip)
|
26
|
+
|
27
|
+
expect(anonymized_ip).to be_eql(IPAddr.new('2001:db8:85a3::').to_s)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
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.
|
4
|
+
version: 2.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rollbar, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/rollbar/truncation/strings_strategy.rb
|
134
134
|
- lib/rollbar/util.rb
|
135
135
|
- lib/rollbar/util/hash.rb
|
136
|
+
- lib/rollbar/util/ip_anonymizer.rb
|
136
137
|
- lib/rollbar/util/ip_obfuscator.rb
|
137
138
|
- lib/rollbar/version.rb
|
138
139
|
- lib/tasks/tasks.rake
|
@@ -248,6 +249,7 @@ files:
|
|
248
249
|
- spec/rollbar/truncation/strings_strategy_spec.rb
|
249
250
|
- spec/rollbar/truncation_spec.rb
|
250
251
|
- spec/rollbar/util/hash_spec.rb
|
252
|
+
- spec/rollbar/util/ip_anonymizer_spec.rb
|
251
253
|
- spec/rollbar/util_spec.rb
|
252
254
|
- spec/rollbar_bc_spec.rb
|
253
255
|
- spec/rollbar_spec.rb
|
@@ -282,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
284
|
version: '0'
|
283
285
|
requirements: []
|
284
286
|
rubyforge_project:
|
285
|
-
rubygems_version: 2.
|
287
|
+
rubygems_version: 2.5.1
|
286
288
|
signing_key:
|
287
289
|
specification_version: 4
|
288
290
|
summary: Reports exceptions to Rollbar
|
@@ -398,6 +400,7 @@ test_files:
|
|
398
400
|
- spec/rollbar/truncation/strings_strategy_spec.rb
|
399
401
|
- spec/rollbar/truncation_spec.rb
|
400
402
|
- spec/rollbar/util/hash_spec.rb
|
403
|
+
- spec/rollbar/util/ip_anonymizer_spec.rb
|
401
404
|
- spec/rollbar/util_spec.rb
|
402
405
|
- spec/rollbar_bc_spec.rb
|
403
406
|
- spec/rollbar_spec.rb
|