bugsnag 5.3.2 → 5.3.3

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: ef6284041ebdca482f26c88e3c7567c66202c257
4
- data.tar.gz: 08db78478dce28720b87e375bb4442ef67a59d13
3
+ metadata.gz: f0f59a73d8f4b8c5594828664573e892ecf8bd49
4
+ data.tar.gz: ec14896b7774fac186b1db8e42c5e41b233e4555
5
5
  SHA512:
6
- metadata.gz: 8176288fe2c5a68ec57f47fc8b6ae8d654eba29753e2da0bc397a16709ce2b004f715d14ac25850b53215c20460bcdde805d0667e64df75a4b8c8018b4e5d543
7
- data.tar.gz: ae3709d8217bcc5b8fa6654cbf8ca39d2cbb6585689a4ffd5dfa7e11ae782244680630dd307497e766b40361ba31150dfc00b9484f45538eb8d035ba39456f42
6
+ metadata.gz: 4a20576b59c6a146d2290a6a65a8ac13d30c75aaa76f0b2cfd216d0c7505b36af8a10b4f0269bc869e926b50c844cf435bd10634fc5c118e251f85b9d8bd3d59
7
+ data.tar.gz: 52fbb7da5f06de0f178c3c0d3b37c84cdbdcd79421923764a26dd6753b400fd509df3efe62862d51fe55a888d2b5db39eb711812e5470df82588d49b1bb03d05
@@ -1,6 +1,11 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 5.3.3 (16 June 2017)
5
+
6
+ * [Rails] Fix failure to report when encountering objects which throw in `to_s`
7
+ [#361](https://github.com/bugsnag/bugsnag-ruby/pull/361)
8
+
4
9
  ## 5.3.2 (27 April 2017)
5
10
 
6
11
  ### Bug fixes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.3.2
1
+ 5.3.3
@@ -6,6 +6,7 @@ module Bugsnag
6
6
  FILTERED = '[FILTERED]'.freeze
7
7
  RECURSION = '[RECURSION]'.freeze
8
8
  OBJECT = '[OBJECT]'.freeze
9
+ RAISED = '[RAISED]'.freeze
9
10
 
10
11
  def initialize(filters)
11
12
  @filters = Array(filters)
@@ -43,7 +44,7 @@ module Bugsnag
43
44
  when String
44
45
  clean_string(obj)
45
46
  else
46
- str = obj.to_s
47
+ str = obj.to_s rescue RAISED
47
48
  # avoid leaking potentially sensitive data from objects' #inspect output
48
49
  if str =~ /#<.*>/
49
50
  OBJECT
@@ -1,5 +1,7 @@
1
1
  module Bugsnag::Middleware
2
2
  class RackRequest
3
+ SPOOF = "[SPOOF]".freeze
4
+
3
5
  def initialize(bugsnag)
4
6
  @bugsnag = bugsnag
5
7
  end
@@ -11,7 +13,7 @@ module Bugsnag::Middleware
11
13
  request = ::Rack::Request.new(env)
12
14
 
13
15
  params = request.params rescue {}
14
-
16
+ client_ip = request.ip.to_s rescue SPOOF
15
17
  session = env["rack.session"]
16
18
 
17
19
  # Set the context
@@ -51,7 +53,7 @@ module Bugsnag::Middleware
51
53
  :httpMethod => request.request_method,
52
54
  :params => params.to_hash,
53
55
  :referer => request.referer,
54
- :clientIp => request.ip,
56
+ :clientIp => client_ip,
55
57
  :headers => headers
56
58
  })
57
59
 
@@ -1,5 +1,7 @@
1
1
  module Bugsnag::Middleware
2
2
  class Rails3Request
3
+ SPOOF = "[SPOOF]".freeze
4
+
3
5
  def initialize(bugsnag)
4
6
  @bugsnag = bugsnag
5
7
  end
@@ -8,6 +10,7 @@ module Bugsnag::Middleware
8
10
  if notification.request_data[:rack_env]
9
11
  env = notification.request_data[:rack_env]
10
12
  params = env["action_dispatch.request.parameters"]
13
+ client_ip = env["action_dispatch.remote_ip"].to_s rescue SPOOF
11
14
 
12
15
  if params
13
16
  # Set the context
@@ -22,11 +25,11 @@ module Bugsnag::Middleware
22
25
 
23
26
  # Use action_dispatch.remote_ip for IP address fields and send request id
24
27
  notification.add_tab(:request, {
25
- :clientIp => env["action_dispatch.remote_ip"],
28
+ :clientIp => client_ip,
26
29
  :requestId => env["action_dispatch.request_id"]
27
30
  })
28
31
 
29
- notification.user_id = env["action_dispatch.remote_ip"]
32
+ notification.user_id = client_ip
30
33
 
31
34
  # Add the rails version
32
35
  if notification.configuration.send_environment
@@ -82,6 +82,15 @@ describe Bugsnag::Cleaner do
82
82
  params = {:request => {:params => {:foo => {:bar => "baz"}}}}
83
83
  expect(described_class.new([/^foo\.bar/]).clean_object(params)).to eq({:request => {:params => {:foo => {:bar => '[FILTERED]'}}}})
84
84
  end
85
+
86
+ it "filters objects which can't be stringified" do
87
+ class StringRaiser
88
+ def to_s
89
+ raise 'Oh no you do not!'
90
+ end
91
+ end
92
+ expect(subject.clean_object({ :foo => StringRaiser.new })).to eq({ :foo => '[RAISED]' })
93
+ end
85
94
  end
86
95
 
87
96
  describe "#clean_url" do
@@ -39,6 +39,19 @@ describe Bugsnag::Helpers do
39
39
  expect(value[4]).to be_a(String)
40
40
  end
41
41
 
42
+ context "an object will throw if `to_s` is called" do
43
+ class StringRaiser
44
+ def to_s
45
+ raise 'Oh no you do not!'
46
+ end
47
+ end
48
+
49
+ it "uses the string '[RAISED]' instead" do
50
+ value = Bugsnag::Helpers.trim_if_needed([1, 3, StringRaiser.new])
51
+ expect(value[2]).to eq "[RAISED]"
52
+ end
53
+ end
54
+
42
55
  context "payload length is less than allowed" do
43
56
 
44
57
  it "does not change strings" do
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bugsnag::Middleware::Rails3Request do
4
+ before(:each) do
5
+ Bugsnag.configuration.middleware.use(described_class)
6
+ end
7
+
8
+ describe "#call" do
9
+ it "sets request metadata" do
10
+ Bugsnag.configuration.set_request_data(:rack_env, {
11
+ "action_dispatch.remote_ip" => "10.2.2.224",
12
+ "action_dispatch.request_id" => "5",
13
+ })
14
+ Bugsnag.notify(BugsnagTestException.new('Grimbles'))
15
+
16
+ expect(Bugsnag).to have_sent_notification { |payload|
17
+ event = get_event_from_payload(payload)
18
+ puts event["metaData"].inspect
19
+ expect(event["metaData"]["request"]).to eq({
20
+ "clientIp" => "10.2.2.224",
21
+ "requestId" => "5"
22
+ })
23
+ }
24
+ end
25
+
26
+ context "the Remote IP will throw when serialized" do
27
+
28
+ it "sets the client IP metdata to [SPOOF]" do
29
+ class SpecialIP
30
+ def to_s
31
+ raise BugsnagTestException.new('oh no')
32
+ end
33
+ end
34
+ Bugsnag.configuration.set_request_data(:rack_env, {
35
+ "action_dispatch.remote_ip" => SpecialIP.new,
36
+ "action_dispatch.request_id" => "5",
37
+ })
38
+
39
+ Bugsnag.notify(BugsnagTestException.new('Grimbles'))
40
+
41
+ expect(Bugsnag).to have_sent_notification { |payload|
42
+ event = get_event_from_payload(payload)
43
+ puts event["metaData"].inspect
44
+ expect(event["metaData"]["request"]).to eq({
45
+ "clientIp" => "[SPOOF]",
46
+ "requestId" => "5"
47
+ })
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.2
4
+ version: 5.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -171,6 +171,7 @@ files:
171
171
  - spec/middleware_spec.rb
172
172
  - spec/notification_spec.rb
173
173
  - spec/rack_spec.rb
174
+ - spec/rails3_request_spec.rb
174
175
  - spec/spec_helper.rb
175
176
  homepage: http://github.com/bugsnag/bugsnag-ruby
176
177
  licenses: