sentry-raven 2.4.0 → 2.5.0

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: cb65022aed8ddc08bcb526c2c71d0b53b6cda940
4
- data.tar.gz: '079e7ee3652a38722ebf913095cfd45be86d79d7'
3
+ metadata.gz: fb8e99d6cd40b4a9bcebae0aa4c2b6a9ae92c65f
4
+ data.tar.gz: f0b34e2f0061b92c0b94dbfce8409b415850a756
5
5
  SHA512:
6
- metadata.gz: 4aafa4ea87fc78346f7050cddfc71f445e6a9deccc5990c1cebfaf8b62882178a8160d40bf9267ec014c826ffa8a1a2bc8b3cea13a6f748ccca6b2c4feda3e5b
7
- data.tar.gz: 00000f1fe367791b055f763e3100223bc3f71827a41d60c2dcfcbe63baf4ec25214e3c3a21383901c56e5d4c4c0d72b6be07b1534cf0ecc6b5c5fe1eb0f3bb13
6
+ metadata.gz: 89cd1bda236dfc17bde728a9b69ddcc0d2f4bbffdd2a8697969662c977addf14f180285132987b20cfa53f9398cf3b80309bc781bd502700ce6a4b20a663ccde
7
+ data.tar.gz: 11d7601a11bd66e3881f457f60c9db1bb253a4a93fa35b32bb61447d938f74019b7fa219a3f4cf8d797cac48835e8d795a2417f5b9b4d793a97596203516286c
data/README.md CHANGED
@@ -143,7 +143,7 @@ For more information, see [Context](https://docs.sentry.io/clients/ruby/context/
143
143
  ## More Information
144
144
 
145
145
  * [Documentation](https://docs.getsentry.com/hosted/clients/ruby/)
146
- * [Bug Tracker](https://github.com/getsentry/raven-ruby/issues>)
147
- * [Code](https://github.com/getsentry/raven-ruby>)
148
- * [Mailing List](https://groups.google.com/group/getsentry>)
146
+ * [Bug Tracker](https://github.com/getsentry/raven-ruby/issues)
147
+ * [Code](https://github.com/getsentry/raven-ruby)
148
+ * [Mailing List](https://groups.google.com/group/getsentry)
149
149
  * [IRC](irc://irc.freenode.net/sentry>) (irc.freenode.net, #sentry)
@@ -64,7 +64,7 @@ module Raven
64
64
 
65
65
  def encode(event)
66
66
  hash = @processors.reduce(event.to_hash) { |a, e| e.process(a) }
67
- encoded = JSON.generate(hash)
67
+ encoded = JSON.fast_generate(hash)
68
68
 
69
69
  case configuration.encoding
70
70
  when 'gzip'
@@ -51,7 +51,7 @@ module Raven
51
51
  # this will change in the future:
52
52
  # https://github.com/mperham/sidekiq/pull/3161
53
53
  def culprit_from_context(context)
54
- classname = (context["class"] || (context["job"] && context["job"]["class"]))
54
+ classname = (context["class"] || (context["job"] && (context["job"]["wrapped"] || context["job"]["class"])))
55
55
  if classname
56
56
  "Sidekiq/#{classname}"
57
57
  elsif context["event"]
@@ -37,7 +37,7 @@ module Raven
37
37
  end
38
38
 
39
39
  def filename
40
- return nil if abs_path.nil?
40
+ return if abs_path.nil?
41
41
 
42
42
  prefix =
43
43
  if under_project_root? && in_app
@@ -60,7 +60,7 @@ module Raven
60
60
  end
61
61
 
62
62
  def longest_load_path
63
- $LOAD_PATH.select { |s| abs_path.start_with?(s.to_s) }.sort_by { |s| s.to_s.length }.last
63
+ $LOAD_PATH.select { |s| abs_path.start_with?(s) }.max_by(&:length)
64
64
  end
65
65
 
66
66
  def to_hash(*args)
@@ -1,14 +1,16 @@
1
1
  module Raven
2
2
  class Processor::RemoveCircularReferences < Processor
3
- def process(v, visited = [])
4
- return "(...)" if visited.include?(v.__id__)
5
- visited += [v.__id__]
6
- if v.is_a?(Hash)
7
- v.each_with_object({}) { |(k, v_), memo| memo[k] = process(v_, visited) }
8
- elsif v.is_a?(Array)
9
- v.map { |v_| process(v_, visited) }
3
+ def process(value, visited = [])
4
+ return "(...)" if visited.include?(value.__id__)
5
+ visited << value.__id__ if value.is_a?(Array) || value.is_a?(Hash)
6
+
7
+ case value
8
+ when Hash
9
+ !value.frozen? ? value.merge!(value) { |_, v| process v, visited } : value.merge(value) { |_, v| process v, visited }
10
+ when Array
11
+ !value.frozen? ? value.map! { |v| process v, visited } : value.map { |v| process v, visited }
10
12
  else
11
- v
13
+ value
12
14
  end
13
15
  end
14
16
  end
@@ -14,31 +14,27 @@ module Raven
14
14
  self.sanitize_credit_cards = client.configuration.sanitize_credit_cards
15
15
  end
16
16
 
17
- def process(value)
18
- return value if value.frozen?
19
- value.each_with_object(value) { |(k, v), memo| memo[k] = sanitize(k, v) }
20
- end
21
-
22
- def sanitize(k, v)
23
- if v.is_a?(Hash)
24
- process(v)
25
- elsif v.is_a?(Array)
26
- v.map { |a| sanitize(k, a) }
27
- elsif k.to_s == 'query_string'
28
- sanitize_query_string(v)
29
- elsif v.is_a?(Integer) && matches_regexes?(k, v)
30
- INT_MASK
31
- elsif v.is_a?(String)
32
- if fields_re.match(v.to_s) && (json = parse_json_or_nil(v))
17
+ def process(value, key = nil)
18
+ case value
19
+ when Hash
20
+ !value.frozen? ? value.merge!(value) { |k, v| process v, k } : value.merge(value) { |k, v| process v, k }
21
+ when Array
22
+ !value.frozen? ? value.map! { |v| process v, key } : value.map { |v| process v, key }
23
+ when Integer
24
+ matches_regexes?(key, value.to_s) ? INT_MASK : value
25
+ when String
26
+ if value =~ fields_re && (json = parse_json_or_nil(value))
33
27
  # if this string is actually a json obj, convert and sanitize
34
- json.is_a?(Hash) ? process(json).to_json : v
35
- elsif matches_regexes?(k, v)
28
+ process(json).to_json
29
+ elsif matches_regexes?(key, value)
36
30
  STRING_MASK
31
+ elsif key == 'query_string' || key == :query_string
32
+ sanitize_query_string(value)
37
33
  else
38
- v
34
+ value
39
35
  end
40
36
  else
41
- v
37
+ value
42
38
  end
43
39
  end
44
40
 
@@ -51,8 +47,8 @@ module Raven
51
47
  end
52
48
 
53
49
  def matches_regexes?(k, v)
54
- (sanitize_credit_cards && CREDIT_CARD_RE.match(v.to_s)) ||
55
- fields_re.match(k.to_s)
50
+ (sanitize_credit_cards && v =~ CREDIT_CARD_RE) ||
51
+ k =~ fields_re
56
52
  end
57
53
 
58
54
  def fields_re
@@ -70,6 +66,7 @@ module Raven
70
66
  end
71
67
 
72
68
  def parse_json_or_nil(string)
69
+ return unless string.start_with?("[", "{")
73
70
  JSON.parse(string)
74
71
  rescue JSON::ParserError, NoMethodError
75
72
  nil
@@ -1,29 +1,28 @@
1
1
  module Raven
2
2
  class Processor::UTF8Conversion < Processor
3
3
  def process(value)
4
- if value.is_a? Array
5
- value.map { |v| process v }
6
- elsif value.is_a? Hash
7
- value.merge(value) { |_, v| process v }
8
- elsif value.is_a?(Exception) && !value.message.valid_encoding?
4
+ case value
5
+ when Array
6
+ !value.frozen? ? value.map! { |v| process v } : value.map { |v| process v }
7
+ when Hash
8
+ !value.frozen? ? value.merge!(value) { |_, v| process v } : value.merge(value) { |_, v| process v }
9
+ when Exception
10
+ return value if value.message.valid_encoding?
9
11
  clean_exc = value.class.new(clean_invalid_utf8_bytes(value.message))
10
12
  clean_exc.set_backtrace(value.backtrace)
11
13
  clean_exc
12
- else
14
+ when String
15
+ return value if value.valid_encoding?
13
16
  clean_invalid_utf8_bytes(value)
17
+ else
18
+ value
14
19
  end
15
20
  end
16
21
 
17
22
  private
18
23
 
19
24
  def clean_invalid_utf8_bytes(obj)
20
- if obj.respond_to?(:to_utf8)
21
- obj.to_utf8
22
- elsif obj.respond_to?(:encoding) && obj.is_a?(String)
23
- obj.encode('UTF-16', :invalid => :replace, :undef => :replace, :replace => '').encode('UTF-8')
24
- else
25
- obj
26
- end
25
+ obj.encode('UTF-16', :invalid => :replace, :undef => :replace, :replace => '').encode('UTF-8')
27
26
  end
28
27
  end
29
28
  end
@@ -27,7 +27,7 @@ module Raven
27
27
  req.headers['X-Sentry-Auth'] = auth_header
28
28
  req.body = data
29
29
  end
30
- rescue Faraday::ClientError => ex
30
+ rescue Faraday::Error => ex
31
31
  error_info = ex.message
32
32
  if ex.response && ex.response[:headers]['x-sentry-error']
33
33
  error_info += " Error in headers is: #{ex.response[:headers]['x-sentry-error']}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Raven
3
3
  # Freezing this constant breaks in 1.9.x
4
- VERSION = "2.4.0" # rubocop:disable Style/MutableConstant
4
+ VERSION = "2.5.0" # rubocop:disable Style/MutableConstant
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-raven
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-07 00:00:00.000000000 Z
11
+ date: 2017-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.6.8
196
+ rubygems_version: 2.6.11
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: A gem that provides a client interface for the Sentry error logger