rollbar 2.16.2 → 2.16.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef98d47074226584e6ee894d82f5a3d0c73664c9
4
- data.tar.gz: c01e80f38136f5397bb1c585fa8d31c803dee8cd
3
+ metadata.gz: b5cd5a741817deee8eeed5a026529a556fe4c1a1
4
+ data.tar.gz: 5aa9b0225c05b77c2d8d97c273293806658a4d6c
5
5
  SHA512:
6
- metadata.gz: 25a0bcec30eef59e718bad1d5857612c8938df5be9afec3b7c20251f93d11abd50f265ef1284f249202eec9d308a01ae867c737e83c86451e7bd0af717a34b71
7
- data.tar.gz: a0958ba5221c0184067b90e5aff2aa160c97d607084984a405f63542701cca7a548dc72aec5e713b613e532d3a17d28acfc65cac08cac05d85a5a655391caa03
6
+ metadata.gz: ce8a7f469fb9d0526e6f7829c3488442984aff359a8672ad86cfc120f1ef356ad7367ce496128cb77de50160bb4e55acb6f33a95ca280e41608eb34b2d3adc68
7
+ data.tar.gz: d2038279771ebbf00af8674e3e8c2fc14960adac93364c5b76ce81b2ad9688d59e588a5ea1e470a40e90c9b7533749fb2f5400dfec8754f30b38ae09f40bbc09
data/Gemfile CHANGED
@@ -42,5 +42,6 @@ gem 'redis'
42
42
  gem 'resque'
43
43
  gem 'shoryuken'
44
44
  gem 'sinatra'
45
+ gem 'byebug'
45
46
 
46
47
  gemspec
@@ -530,14 +530,15 @@ module Rollbar
530
530
  end
531
531
 
532
532
  def proxy_from_config
533
- proxy = configuration.proxy
534
- return nil unless proxy
535
-
536
- px = URI.parse(proxy[:host])
537
- px.port = proxy[:port]
538
- px.user = proxy[:user]
539
- px.password = proxy[:password]
540
- px
533
+ proxy_settings = configuration.proxy
534
+ return nil unless proxy_settings
535
+
536
+ proxy = null_proxy
537
+ proxy.host = URI.parse(proxy_settings[:host]).host
538
+ proxy.port = proxy_settings[:port]
539
+ proxy.user = proxy_settings[:user]
540
+ proxy.password = proxy_settings[:password]
541
+ proxy
541
542
  end
542
543
 
543
544
  def proxy_from_env(uri)
@@ -105,6 +105,14 @@ module Rollbar
105
105
  { name => Rollbar::Scrubbers.scrub_value(env[header]) }
106
106
  elsif name == 'X-Forwarded-For' && !Rollbar.configuration.collect_user_ip
107
107
  {}
108
+ elsif name == 'X-Forwarded-For' && Rollbar.configuration.collect_user_ip && Rollbar.configuration.anonymize_user_ip
109
+ ips = env[header].sub(" ", "").split(',')
110
+ ips = ips.map { |ip| Rollbar::Util::IPAnonymizer.anonymize_ip(ip) }
111
+ { name => ips.join(', ') }
112
+ elsif name == 'X-Real-Ip' && !Rollbar.configuration.collect_user_ip
113
+ {}
114
+ elsif name == 'X-Real-Ip' && Rollbar.configuration.collect_user_ip && Rollbar.configuration.anonymize_user_ip
115
+ { name => Rollbar::Util::IPAnonymizer.anonymize_ip(env[header]) }
108
116
  else
109
117
  { name => env[header] }
110
118
  end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = '2.16.2'
2
+ VERSION = '2.16.3'
3
3
  end
@@ -118,11 +118,12 @@ describe Rollbar::RequestDataExtractor do
118
118
  end
119
119
  end
120
120
 
121
- context 'with multiple addresses in X-Forwarded-For' do
121
+ context 'with multiple IP addresses in headers and in user ip' do
122
122
  let(:env) do
123
123
  Rack::MockRequest.env_for('/',
124
124
  'HTTP_HOST' => 'localhost:81',
125
- 'HTTP_X_FORWARDED_FOR' => header_value,
125
+ 'HTTP_X_FORWARDED_FOR' => x_forwarded_for,
126
+ 'HTTP_X_REAL_IP' => x_real_ip,
126
127
  'REMOTE_ADDR' => '3.3.3.3',
127
128
  'CONTENT_TYPE' => 'application/json',
128
129
  'CONTENT_LENGTH' => 20)
@@ -131,7 +132,8 @@ describe Rollbar::RequestDataExtractor do
131
132
  end
132
133
 
133
134
  context 'with public client IP' do
134
- let(:header_value) { '2.2.2.2, 3.3.3.3' }
135
+ let(:x_forwarded_for) { '2.2.2.2, 3.3.3.3' }
136
+ let(:x_real_ip) { '2.2.2.2' }
135
137
 
136
138
  it 'extracts the correct user IP' do
137
139
  result = subject.extract_request_data_from_rack(env)
@@ -139,6 +141,18 @@ describe Rollbar::RequestDataExtractor do
139
141
  expect(result[:user_ip]).to be_eql('2.2.2.2')
140
142
  end
141
143
 
144
+ it 'extracts the correct X-Forwarded-For' do
145
+ result = subject.extract_request_data_from_rack(env)
146
+
147
+ expect(result[:headers]['X-Forwarded-For']).to be_eql('2.2.2.2, 3.3.3.3')
148
+ end
149
+
150
+ it 'extracts the correct X-Real-Ip' do
151
+ result = subject.extract_request_data_from_rack(env)
152
+
153
+ expect(result[:headers]['X-Real-Ip']).to be_eql('2.2.2.2')
154
+ end
155
+
142
156
  context 'with collect_user_ip configuration option disabled' do
143
157
  before do
144
158
  Rollbar.configuration.collect_user_ip = false
@@ -155,6 +169,12 @@ describe Rollbar::RequestDataExtractor do
155
169
 
156
170
  expect(result[:headers]['X-Forwarded-For']).to be_nil
157
171
  end
172
+
173
+ it 'does not extract user\'s IP on X-Real-Ip header' do
174
+ result = subject.extract_request_data_from_rack(env)
175
+
176
+ expect(result[:headers]['X-Real-Ip']).to be_nil
177
+ end
158
178
  end
159
179
 
160
180
  context 'with anonymize_user_ip configuration option enabled' do
@@ -167,17 +187,42 @@ describe Rollbar::RequestDataExtractor do
167
187
 
168
188
  expect(result[:user_ip]).to be_eql('2.2.2.0')
169
189
  end
190
+
191
+ it 'it anonymizes IP addresses in X-Forwarded-For' do
192
+ result = subject.extract_request_data_from_rack(env)
193
+
194
+ expect(result[:headers]['X-Forwarded-For']).to be_eql('2.2.2.0, 3.3.3.0')
195
+ end
196
+
197
+ it 'it anonymizes IP addresses in X-Real-Ip' do
198
+ result = subject.extract_request_data_from_rack(env)
199
+
200
+ expect(result[:headers]['X-Real-Ip']).to be_eql('2.2.2.0')
201
+ end
170
202
  end
171
203
  end
172
204
 
173
205
  context 'with private first client IP' do
174
- let(:header_value) { '192.168.1.1, 2.2.2.2, 3.3.3.3' }
206
+ let(:x_forwarded_for) { '192.168.1.1, 2.2.2.2, 3.3.3.3' }
207
+ let(:x_real_ip) { '2.2.2.2' }
175
208
 
176
209
  it 'extracts the correct user IP' do
177
210
  result = subject.extract_request_data_from_rack(env)
178
211
 
179
212
  expect(result[:user_ip]).to be_eql('2.2.2.2')
180
213
  end
214
+
215
+ it 'extracts the correct X-Forwarded-For' do
216
+ result = subject.extract_request_data_from_rack(env)
217
+
218
+ expect(result[:headers]['X-Forwarded-For']).to be_eql('192.168.1.1, 2.2.2.2, 3.3.3.3')
219
+ end
220
+
221
+ it 'extracts the correct X-Real-Ip' do
222
+ result = subject.extract_request_data_from_rack(env)
223
+
224
+ expect(result[:headers]['X-Real-Ip']).to be_eql('2.2.2.2')
225
+ end
181
226
  end
182
227
  end
183
228
 
@@ -1043,18 +1043,20 @@ describe Rollbar do
1043
1043
  end
1044
1044
 
1045
1045
  context 'via environment variables' do
1046
+ before do
1047
+ @uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
1048
+ end
1049
+
1046
1050
  it 'honors proxy settings in the environment' do
1047
1051
  ENV['http_proxy'] = 'http://user:pass@example.com:80'
1048
1052
  ENV['https_proxy'] = 'http://user:pass@example.com:80'
1049
1053
 
1050
- uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
1051
- expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, 'example.com', 80, 'user', 'pass').and_call_original
1054
+ expect(Net::HTTP).to receive(:new).with(@uri.host, @uri.port, 'example.com', 80, 'user', 'pass').and_call_original
1052
1055
  Rollbar.info("proxy this")
1053
1056
  end
1054
1057
 
1055
1058
  it 'does not use a proxy if no proxy settings in environemnt' do
1056
- uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
1057
- expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, nil, nil, nil, nil).and_call_original
1059
+ expect(Net::HTTP).to receive(:new).with(@uri.host, @uri.port, nil, nil, nil, nil).and_call_original
1058
1060
  Rollbar.info("proxy this")
1059
1061
  end
1060
1062
  end
@@ -1069,11 +1071,12 @@ describe Rollbar do
1069
1071
  :password => 'bar'
1070
1072
  }
1071
1073
  end
1074
+
1075
+ @uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
1072
1076
  end
1073
1077
 
1074
1078
  it 'honors proxy settings in the config file' do
1075
- uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
1076
- expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, 'config.com', 8080, 'foo', 'bar').and_call_original
1079
+ expect(Net::HTTP).to receive(:new).with(@uri.host, @uri.port, 'config.com', 8080, 'foo', 'bar').and_call_original
1077
1080
  Rollbar.info("proxy this")
1078
1081
  end
1079
1082
 
@@ -1081,8 +1084,16 @@ describe Rollbar do
1081
1084
  ENV['http_proxy'] = 'http://user:pass@example.com:80'
1082
1085
  ENV['https_proxy'] = 'http://user:pass@example.com:80'
1083
1086
 
1084
- uri = URI.parse(Rollbar::Configuration::DEFAULT_ENDPOINT)
1085
- expect(Net::HTTP).to receive(:new).with(uri.host, uri.port, 'config.com', 8080, 'foo', 'bar').and_call_original
1087
+ expect(Net::HTTP).to receive(:new).with(@uri.host, @uri.port, 'config.com', 8080, 'foo', 'bar').and_call_original
1088
+ Rollbar.info("proxy this")
1089
+ end
1090
+
1091
+ it 'allows @-signs in passwords' do
1092
+ Rollbar.configure do |config|
1093
+ config.proxy[:password] = "manh@tan"
1094
+ end
1095
+
1096
+ expect(Net::HTTP).to receive(:new).with(@uri.host, @uri.port, 'config.com', 8080, 'foo', 'manh@tan').and_call_original
1086
1097
  Rollbar.info("proxy this")
1087
1098
  end
1088
1099
  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.16.2
4
+ version: 2.16.3
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-06-05 00:00:00.000000000 Z
11
+ date: 2018-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  version: '0'
285
285
  requirements: []
286
286
  rubyforge_project:
287
- rubygems_version: 2.6.10
287
+ rubygems_version: 2.5.1
288
288
  signing_key:
289
289
  specification_version: 4
290
290
  summary: Reports exceptions to Rollbar