bugsnag 4.0.1 → 4.0.2

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: 3feeeeef834abcd2676f54ed08468f35d2e61cec
4
- data.tar.gz: fa7ff7ef9f2e1619d3d00142f6e7eb1c241c514e
3
+ metadata.gz: a229f778796995938a5bc4d2e1f6260e8b5ad975
4
+ data.tar.gz: 2bf93ba3af00b2aa7e1038b2863c0dcab591dbc4
5
5
  SHA512:
6
- metadata.gz: 08264576a36649e2850368e7f6d6c2190d9fe44d4489c963c464f7abcb4201a45a72b9d773a1d26eff2c98be41a0b18e953e295f06156ffe6e56de28a2601625
7
- data.tar.gz: cd2424431cae73dea1e41f0b570e241834a063be6cf9c4a59964031467c77ed9089ab8ee312de9a11570a55de019e4bd109eae6e544f2355b1b09fa761948ea5
6
+ metadata.gz: d84f962040e273a06bcc392df1b157445ef31db06772e998fb005f9477e64f5d7ebe89cd96184cc45315cb51bfb1183c84e41ca1104b39db8cc2207f1a9a3356
7
+ data.tar.gz: 4ebd9be31fe102764c9b9eec6920e8d51685b02669be624470187ee4f3b42884cee2a188a05cfbbe4445c350969169fb52556f0580779093cf4c2a7942bf3748
@@ -1,6 +1,14 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 4.0.2 (13 Apr 2016)
5
+
6
+ ### Fixes
7
+
8
+ * Fix payload rejection due to truncating duplicate stacktrace frames
9
+ | [#284](https://github.com/bugsnag/bugsnag-ruby/issues/284)
10
+ | [#291](https://github.com/bugsnag/bugsnag-ruby/pull/291)
11
+
4
12
  ## 4.0.1 (5 Apr 2016)
5
13
 
6
14
  ### Fixes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.1
1
+ 4.0.2
@@ -17,7 +17,7 @@ module Bugsnag
17
17
  end
18
18
 
19
19
  def traverse_object(obj, seen, scope)
20
- return nil unless obj
20
+ return nil if obj.nil?
21
21
 
22
22
  # Protect against recursion of recursable items
23
23
  protection = if obj.is_a?(Hash) || obj.is_a?(Array) || obj.is_a?(Set)
@@ -8,12 +8,14 @@ module Bugsnag
8
8
  MAX_STRING_LENGTH = 4096
9
9
  MAX_PAYLOAD_LENGTH = 128000
10
10
  MAX_ARRAY_LENGTH = 400
11
+ RAW_DATA_TYPES = [Numeric, TrueClass, FalseClass]
11
12
 
12
13
  # Trim the size of value if the serialized JSON value is longer than is
13
14
  # accepted by Bugsnag
14
15
  def self.trim_if_needed(value)
15
- return value unless payload_too_long?(value)
16
- reduced_value = trim_strings_in_value(value)
16
+ sanitized_value = Bugsnag::Cleaner.clean_object_encoding(value)
17
+ return sanitized_value unless payload_too_long?(sanitized_value)
18
+ reduced_value = trim_strings_in_value(sanitized_value)
17
19
  return reduced_value unless payload_too_long?(reduced_value)
18
20
  truncate_arrays_in_value(reduced_value)
19
21
  end
@@ -29,10 +31,15 @@ module Bugsnag
29
31
  end
30
32
  end
31
33
 
34
+ # Check if a value is a raw type which should not be trimmed, truncated
35
+ # or converted to a string
36
+ def self.is_json_raw_type?(value)
37
+ RAW_DATA_TYPES.detect {|klass| value.is_a?(klass)} != nil
38
+ end
39
+
32
40
  private
33
41
 
34
42
  TRUNCATION_INFO = '[TRUNCATED]'
35
- RAW_DATA_TYPES = [Numeric, TrueClass, FalseClass]
36
43
 
37
44
  # Shorten array until it fits within the payload size limit when serialized
38
45
  def self.truncate_arrays(array)
@@ -45,13 +52,13 @@ module Bugsnag
45
52
  end
46
53
 
47
54
  # Trim all strings to be less than the maximum allowed string length
48
- def self.trim_strings_in_value(value, seen=[])
55
+ def self.trim_strings_in_value(value)
49
56
  return value if is_json_raw_type?(value)
50
57
  case value
51
58
  when Hash
52
- trim_strings_in_hash(value, seen)
59
+ trim_strings_in_hash(value)
53
60
  when Array, Set
54
- trim_strings_in_array(value, seen)
61
+ trim_strings_in_array(value)
55
62
  else
56
63
  trim_as_string(value)
57
64
  end
@@ -63,21 +70,13 @@ module Bugsnag
63
70
  ::JSON.dump(value).length >= MAX_PAYLOAD_LENGTH
64
71
  end
65
72
 
66
- # Check if a value is a raw type which should not be trimmed, truncated
67
- # or converted to a string
68
- def self.is_json_raw_type?(value)
69
- RAW_DATA_TYPES.detect {|klass| value.is_a?(klass)} != nil
70
- end
71
-
72
- def self.trim_strings_in_hash(hash, seen=[])
73
- return {} if seen.include?(hash) || !hash.is_a?(Hash)
74
- result = hash.each_with_object({}) do |(key, value), reduced_hash|
75
- if reduced_value = trim_strings_in_value(value, seen)
73
+ def self.trim_strings_in_hash(hash)
74
+ return {} unless hash.is_a?(Hash)
75
+ hash.each_with_object({}) do |(key, value), reduced_hash|
76
+ if reduced_value = trim_strings_in_value(value)
76
77
  reduced_hash[key] = reduced_value
77
78
  end
78
79
  end
79
- seen << hash
80
- result
81
80
  end
82
81
 
83
82
  # If possible, convert the provided object to a string and trim to the
@@ -92,11 +91,9 @@ module Bugsnag
92
91
  text
93
92
  end
94
93
 
95
- def self.trim_strings_in_array(collection, seen=[])
96
- return [] if seen.include?(collection) || !collection.respond_to?(:map)
97
- result = collection.map {|value| trim_strings_in_value(value, seen)}
98
- seen << collection
99
- result
94
+ def self.trim_strings_in_array(collection)
95
+ return [] unless collection.respond_to?(:map)
96
+ collection.map {|value| trim_strings_in_value(value)}
100
97
  end
101
98
 
102
99
  def self.truncate_arrays_in_value(value)
@@ -7,21 +7,53 @@ describe Bugsnag::Helpers do
7
7
 
8
8
  describe "trim_if_needed" do
9
9
 
10
+ it "breaks recursion" do
11
+ a = [1, 2, 3]
12
+ b = [2, a]
13
+ a << b
14
+ value = Bugsnag::Helpers.trim_if_needed(a)
15
+ expect(value).to eq([1, 2, 3, [2, "[RECURSION]"]])
16
+ end
17
+
18
+ it "does not break equal objects without recursion" do
19
+ data = [1, [1, 2], [1, 2], "a"]
20
+ value = Bugsnag::Helpers.trim_if_needed(data)
21
+ expect(value).to eq data
22
+ end
23
+
24
+ it "preserves bool types" do
25
+ value = Bugsnag::Helpers.trim_if_needed([1, 3, true, "NO", "2", false])
26
+ expect(value[2]).to be_a(TrueClass)
27
+ expect(value[5]).to be_a(FalseClass)
28
+ end
29
+
30
+ it "preserves Numeric types" do
31
+ value = Bugsnag::Helpers.trim_if_needed([1, 3.445, true, "NO", "2", false])
32
+ expect(value[0]).to be_a(Numeric)
33
+ expect(value[1]).to be_a(Numeric)
34
+ end
35
+
36
+ it "preserves String types" do
37
+ value = Bugsnag::Helpers.trim_if_needed([1, 3, true, "NO", "2", false])
38
+ expect(value[3]).to be_a(String)
39
+ expect(value[4]).to be_a(String)
40
+ end
41
+
10
42
  context "payload length is less than allowed" do
11
43
 
12
44
  it "does not change strings" do
13
45
  value = SecureRandom.hex(4096)
14
- expect(Bugsnag::Helpers.trim_if_needed(value)).to be value
46
+ expect(Bugsnag::Helpers.trim_if_needed(value)).to eq value
15
47
  end
16
48
 
17
49
  it "does not change arrays" do
18
50
  value = 1000.times.map {|i| "#{i} - #{i + 1}" }
19
- expect(Bugsnag::Helpers.trim_if_needed(value)).to be value
51
+ expect(Bugsnag::Helpers.trim_if_needed(value)).to eq value
20
52
  end
21
53
 
22
54
  it "does not change hashes" do
23
55
  value = Hash[*1000.times.map{|i| ["#{i}", i]}.flatten]
24
- expect(Bugsnag::Helpers.trim_if_needed(value)).to be value
56
+ expect(Bugsnag::Helpers.trim_if_needed(value)).to eq value
25
57
  end
26
58
  end
27
59
 
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 10.1.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 10.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: addressable
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.3.8
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.3.8
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: Ruby notifier for bugsnag.com
@@ -103,10 +103,10 @@ extra_rdoc_files:
103
103
  - README.md
104
104
  - CHANGELOG.md
105
105
  files:
106
- - ".document"
107
- - ".gitignore"
108
- - ".rspec"
109
- - ".travis.yml"
106
+ - .document
107
+ - .gitignore
108
+ - .rspec
109
+ - .travis.yml
110
110
  - CHANGELOG.md
111
111
  - CONTRIBUTING.md
112
112
  - Gemfile
@@ -181,17 +181,17 @@ require_paths:
181
181
  - lib
182
182
  required_ruby_version: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - ">="
184
+ - - '>='
185
185
  - !ruby/object:Gem::Version
186
186
  version: 1.9.2
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  requirements:
189
- - - ">="
189
+ - - '>='
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.4.5
194
+ rubygems_version: 2.0.14.1
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Ruby notifier for bugsnag.com