sentry-raven 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sentry-raven might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fbeb1ae8141697af3bf06f4c2167f97af8a7e58
4
- data.tar.gz: 3431f08512c915bce224d07fb8ad77d5f04fe62a
3
+ metadata.gz: bdf4bb6934f77389e7393fc2408408020cdfd923
4
+ data.tar.gz: dc076e2fd742caa665e84ac3d7fedd1bed8ad6cf
5
5
  SHA512:
6
- metadata.gz: 869b6bb29a4a351c8694de220ea6513bafea70554488fd1086b3fcced14510cae903621e37c9f86dedab1e12d40da51fb73c138a12a9b460afddba1485f7fd71
7
- data.tar.gz: ef80ba9d906d81621e4add41b76368ee2549c7bbef3053bf9c280f10b8c3808a1cff39019bc20b01d70201f37bdf28585f65f977dcd76d1f9fc0863d005d26cb
6
+ metadata.gz: ed202296b99e4622def0e9be5ba2150075723e90deea84fbd1e5f7e66e39235b2d656d4a301896f381ebae8d05f745511055ec5e845b247c6ff13f026e0e8917
7
+ data.tar.gz: e4730690c60b5902804d6bd0f8c98d18379350d7ca263e6fe84ac95c5c9a042150e2f481f2f323339e2eafc2eae08d1ad89708de4cc0fae4337a180b9ff6142f
@@ -5,7 +5,6 @@ require 'raven/context'
5
5
  require 'raven/client'
6
6
  require 'raven/event'
7
7
  require 'raven/logger'
8
- require 'raven/rack'
9
8
  require 'raven/interfaces/message'
10
9
  require 'raven/interfaces/exception'
11
10
  require 'raven/interfaces/stack_trace'
@@ -207,13 +206,9 @@ module Raven
207
206
 
208
207
  # Injects various integrations
209
208
  def inject
210
- require 'raven/integrations/delayed_job' if defined?(::Delayed::Plugin)
211
- require 'raven/railtie' if defined?(::Rails::Railtie)
212
- require 'raven/sidekiq' if defined?(Sidekiq)
213
- if defined?(Rake)
214
- require 'raven/rake'
215
- require 'raven/tasks'
216
- end
209
+ available_integrations = %w[delayed_job rails sidekiq rack rake]
210
+ integrations_to_load = available_integrations & Gem.loaded_specs.keys
211
+ integrations_to_load.each { |integration| require "raven/integrations/#{integration}" }
217
212
  end
218
213
 
219
214
  # For cross-language compat
@@ -1,4 +1,5 @@
1
1
  require 'logger'
2
+ require 'uri'
2
3
 
3
4
  module Raven
4
5
  class Configuration
@@ -52,7 +52,8 @@ module Raven
52
52
  @extra = options[:extra] || {}
53
53
  @extra.merge!(context.extra)
54
54
 
55
- @tags = @configuration.tags
55
+ @tags = {}
56
+ @tags.merge!(@configuration.tags)
56
57
  @tags.merge!(options[:tags] || {})
57
58
  @tags.merge!(context.tags)
58
59
 
@@ -1,4 +1,5 @@
1
1
  require 'time'
2
+ require 'rack'
2
3
 
3
4
  module Raven
4
5
  # Middleware for Rack applications. Any errors raised by the upstream
@@ -20,6 +21,7 @@ module Raven
20
21
  #
21
22
  # Use a standard Raven.configure call to configure your server credentials.
22
23
  class Rack
24
+
23
25
  def self.capture_exception(exception, env, options = {})
24
26
  if env['requested_at']
25
27
  options[:time_spent] = Time.now - env['requested_at']
@@ -2,14 +2,14 @@ require 'raven'
2
2
  require 'rails'
3
3
 
4
4
  module Raven
5
- class Railtie < ::Rails::Railtie
5
+ class Rails < ::Rails::Railtie
6
6
  initializer "raven.use_rack_middleware" do |app|
7
7
  app.config.middleware.insert 0, "Raven::Rack"
8
8
  end
9
9
 
10
10
  initializer 'raven.action_controller' do
11
11
  ActiveSupport.on_load :action_controller do
12
- require 'raven/rails/controller_methods'
12
+ require 'raven/integrations/rails/controller_methods'
13
13
  include Raven::Rails::ControllerMethods
14
14
  end
15
15
  end
@@ -22,17 +22,17 @@ module Raven
22
22
 
23
23
  if Raven.configuration.catch_debugged_exceptions
24
24
  if defined?(::ActionDispatch::DebugExceptions)
25
- require 'raven/rails/middleware/debug_exceptions_catcher'
25
+ require 'raven/integrations/rails/middleware/debug_exceptions_catcher'
26
26
  ::ActionDispatch::DebugExceptions.send(:include, Raven::Rails::Middleware::DebugExceptionsCatcher)
27
27
  elsif defined?(::ActionDispatch::ShowExceptions)
28
- require 'raven/rails/middleware/debug_exceptions_catcher'
28
+ require 'raven/integrations/rails/middleware/debug_exceptions_catcher'
29
29
  ::ActionDispatch::ShowExceptions.send(:include, Raven::Rails::Middleware::DebugExceptionsCatcher)
30
30
  end
31
31
  end
32
32
  end
33
33
 
34
34
  rake_tasks do
35
- require 'raven/tasks'
35
+ require 'raven/integrations/tasks'
36
36
  end
37
37
  end
38
38
  end
@@ -1,5 +1,5 @@
1
1
  module Raven
2
- module Rails
2
+ class Rails
3
3
  module ControllerMethods
4
4
  def capture_message(message, options = {})
5
5
  Raven::Rack.capture_message(message, request.env, options)
@@ -1,5 +1,5 @@
1
1
  module Raven
2
- module Rails
2
+ class Rails
3
3
  module Middleware
4
4
  module DebugExceptionsCatcher
5
5
  def self.included(base)
@@ -1,5 +1,6 @@
1
- require 'raven'
1
+ require 'rake'
2
2
  require 'rake/task'
3
+ require 'raven/integrations/tasks'
3
4
 
4
5
  module Rake
5
6
  class Application
@@ -9,5 +10,4 @@ module Rake
9
10
  orig_display_error_messsage(ex)
10
11
  end
11
12
  end
12
- end
13
-
13
+ end
@@ -1,4 +1,5 @@
1
1
  require 'time'
2
+ require 'sidekiq'
2
3
 
3
4
  module Raven
4
5
  class Sidekiq
@@ -19,12 +19,12 @@ module Raven
19
19
  end
20
20
 
21
21
  def from_rack(env)
22
- require 'rack'
23
22
  req = ::Rack::Request.new(env)
24
- self.url = req.url.split('?').first
23
+ self.url = req.scheme && req.url.split('?').first
25
24
  self.method = req.request_method
26
25
  self.query_string = req.query_string
27
26
  env.each_pair do |key, value|
27
+ key = key.to_s #rack env can contain symbols
28
28
  next unless key.upcase == key # Non-upper case stuff isn't either
29
29
  if key.start_with?('HTTP_')
30
30
  # Header
@@ -28,9 +28,8 @@ require 'stringio'
28
28
  # http://golang.org/src/pkg/json/decode.go and
29
29
  # http://golang.org/src/pkg/utf8/utf8.go
30
30
  module Raven
31
-
32
31
  module OkJson
33
- Upstream = '42'
32
+ Upstream = '43'
34
33
  extend self
35
34
 
36
35
 
@@ -62,20 +61,19 @@ module OkJson
62
61
  # is not a String.
63
62
  # Strings contained in x must be valid UTF-8.
64
63
  def encode(x)
65
- visited = []
66
64
  case x
67
- when Hash then objenc(x, visited)
68
- when Array then arrenc(x, visited)
65
+ when Hash then objenc(x)
66
+ when Array then arrenc(x)
69
67
  else
70
68
  raise Error, 'root value must be an Array or a Hash'
71
69
  end
72
70
  end
73
71
 
74
72
 
75
- def valenc(x, visited)
73
+ def valenc(x)
76
74
  case x
77
- when Hash then objenc(x, visited)
78
- when Array then arrenc(x, visited)
75
+ when Hash then objenc(x)
76
+ when Array then arrenc(x)
79
77
  when String then strenc(x)
80
78
  when Symbol then strenc(x.to_s)
81
79
  when Numeric then numenc(x)
@@ -83,7 +81,7 @@ module OkJson
83
81
  when false then "false"
84
82
  when nil then "null"
85
83
  else
86
- strenc((x.inspect rescue $!.to_s))
84
+ raise Error, "cannot encode #{x.class}: #{x.inspect}"
87
85
  end
88
86
  end
89
87
 
@@ -134,6 +132,10 @@ private
134
132
  ts = eat('{', ts)
135
133
  obj = {}
136
134
 
135
+ unless ts[0]
136
+ raise Error, "unexpected end of object"
137
+ end
138
+
137
139
  if ts[0][0] == '}'
138
140
  return obj, ts[1..-1]
139
141
  end
@@ -177,6 +179,10 @@ private
177
179
  ts = eat('[', ts)
178
180
  arr = []
179
181
 
182
+ unless ts[0]
183
+ raise Error, "unexpected end of array"
184
+ end
185
+
180
186
  if ts[0][0] == ']'
181
187
  return arr, ts[1..-1]
182
188
  end
@@ -427,18 +433,13 @@ private
427
433
  end
428
434
 
429
435
 
430
- def objenc(x, visited)
431
- return '"{...}"' if visited.include?(x.__id__)
432
- visited += [x.__id__]
433
- '{' + x.map{|k,v| keyenc(k) + ':' + valenc(v, visited)}.join(',') + '}'
436
+ def objenc(x)
437
+ '{' + x.map{|k,v| keyenc(k) + ':' + valenc(v)}.join(',') + '}'
434
438
  end
435
439
 
436
440
 
437
- def arrenc(a, visited)
438
- return '"[...]"' if visited.include?(a.__id__)
439
- visited += [a.__id__]
440
-
441
- '[' + a.map{|x| valenc(x, visited)}.join(',') + ']'
441
+ def arrenc(a)
442
+ '[' + a.map{|x| valenc(x)}.join(',') + ']'
442
443
  end
443
444
 
444
445
 
@@ -447,7 +448,7 @@ private
447
448
  when String then strenc(k)
448
449
  when Symbol then strenc(k.to_s)
449
450
  else
450
- strenc(k.inspect)
451
+ raise Error, "Hash key is not a string: #{k.inspect}"
451
452
  end
452
453
  end
453
454
 
@@ -471,11 +472,16 @@ private
471
472
  # In ruby >= 1.9, s[r] is a codepoint, not a byte.
472
473
  if rubydoesenc?
473
474
  begin
474
- c.ord # will raise an error if c is invalid UTF-8
475
+ # c.ord will raise an error if c is invalid UTF-8
476
+ if c.ord < Spc.ord
477
+ c = "\\u%04x" % [c.ord]
478
+ end
475
479
  t.write(c)
476
480
  rescue
477
481
  t.write(Ustrerr)
478
482
  end
483
+ elsif c < Spc
484
+ t.write("\\u%04x" % c)
479
485
  elsif Spc <= c && c <= ?~
480
486
  t.putc(c)
481
487
  else
@@ -491,10 +497,8 @@ private
491
497
 
492
498
 
493
499
  def numenc(x)
494
- if (x.nan? rescue false)
495
- '"NaN"'
496
- elsif (x.infinite? rescue false)
497
- '"Infinite"'
500
+ if ((x.nan? || x.infinite?) rescue false)
501
+ raise Error, "Numeric cannot be represented: #{x}"
498
502
  end
499
503
  "#{x}"
500
504
  end
@@ -605,5 +609,4 @@ private
605
609
  Spc = ' '[0]
606
610
  Unesc = {?b=>?\b, ?f=>?\f, ?n=>?\n, ?r=>?\r, ?t=>?\t}
607
611
  end
608
-
609
- end
612
+ end
@@ -17,8 +17,7 @@ module Raven
17
17
 
18
18
  def parse_json_or_nil(string)
19
19
  begin
20
- result = OkJson.decode(string)
21
- result.is_a?(String) ? nil : result
20
+ OkJson.decode(string)
22
21
  rescue Raven::OkJson::Error
23
22
  nil
24
23
  end
@@ -6,36 +6,30 @@ module Raven
6
6
  VALUES_RE = /^\d{16}$/
7
7
 
8
8
  def process(value)
9
- fields_re = /(#{(DEFAULT_FIELDS + @sanitize_fields).join("|")})/i
9
+ value.inject(value) { |memo,(k,v)| memo[k] = sanitize(k,v); memo }
10
+ end
10
11
 
11
- value.inject(value) do |value,(k,v)|
12
- v = k if v.nil?
13
- if v.is_a?(Hash) || v.is_a?(Array)
14
- process(v)
15
- elsif v.is_a?(String) && (json = parse_json_or_nil(v))
16
- #if this string is actually a json obj, convert and sanitize
17
- value = modify_in_place(value, [k,v], process(json).to_json)
18
- elsif v.is_a?(Integer) && (VALUES_RE.match(v.to_s) || fields_re.match(k.to_s))
19
- value = modify_in_place(value, [k,v], INT_MASK)
20
- elsif VALUES_RE.match(v.to_s) || fields_re.match(k.to_s)
21
- value = modify_in_place(value, [k,v], STRING_MASK)
22
- else
23
- value
24
- end
12
+ def sanitize(k,v)
13
+ if v.is_a?(Hash)
14
+ process(v)
15
+ elsif v.is_a?(Array)
16
+ v.map{|a| sanitize(nil, a)}
17
+ elsif v.is_a?(String) && (json = parse_json_or_nil(v))
18
+ #if this string is actually a json obj, convert and sanitize
19
+ json.is_a?(Hash) ? process(json).to_json : v
20
+ elsif v.is_a?(Integer) && (VALUES_RE.match(v.to_s) || fields_re.match(k.to_s))
21
+ INT_MASK
22
+ elsif v.is_a?(String) && (VALUES_RE.match(v.to_s) || fields_re.match(k.to_s))
23
+ STRING_MASK
24
+ else
25
+ v
25
26
  end
26
- value
27
27
  end
28
28
 
29
29
  private
30
30
 
31
- def modify_in_place(original_parent, original_child, new_child)
32
- if original_parent.is_a?(Array)
33
- index = original_parent.index(original_child[0])
34
- original_parent[index] = new_child
35
- elsif original_parent.is_a?(Hash)
36
- original_parent[original_child[0]] = new_child
37
- end
38
- original_parent
31
+ def fields_re
32
+ @fields_re ||= /(#{(DEFAULT_FIELDS + @sanitize_fields).join("|")})/i
39
33
  end
40
34
  end
41
35
  end
@@ -16,7 +16,7 @@ module Raven
16
16
  def clean_invalid_utf8_bytes(obj)
17
17
  if obj.respond_to?(:to_utf8)
18
18
  obj.to_utf8
19
- elsif obj.respond_to?(:encoding)
19
+ elsif obj.respond_to?(:encoding) && obj.is_a?(String)
20
20
  obj.encode('UTF-16', :invalid => :replace, :undef => :replace, :replace => '').encode('UTF-8')
21
21
  else
22
22
  obj
@@ -1,3 +1,3 @@
1
1
  module Raven
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  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: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-10 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -117,6 +117,13 @@ files:
117
117
  - lib/raven/error.rb
118
118
  - lib/raven/event.rb
119
119
  - lib/raven/integrations/delayed_job.rb
120
+ - lib/raven/integrations/rack.rb
121
+ - lib/raven/integrations/rails.rb
122
+ - lib/raven/integrations/rails/controller_methods.rb
123
+ - lib/raven/integrations/rails/middleware/debug_exceptions_catcher.rb
124
+ - lib/raven/integrations/rake.rb
125
+ - lib/raven/integrations/sidekiq.rb
126
+ - lib/raven/integrations/tasks.rb
120
127
  - lib/raven/interfaces.rb
121
128
  - lib/raven/interfaces/exception.rb
122
129
  - lib/raven/interfaces/http.rb
@@ -130,13 +137,6 @@ files:
130
137
  - lib/raven/processor/removestacktrace.rb
131
138
  - lib/raven/processor/sanitizedata.rb
132
139
  - lib/raven/processor/utf8conversion.rb
133
- - lib/raven/rack.rb
134
- - lib/raven/rails/controller_methods.rb
135
- - lib/raven/rails/middleware/debug_exceptions_catcher.rb
136
- - lib/raven/railtie.rb
137
- - lib/raven/rake.rb
138
- - lib/raven/sidekiq.rb
139
- - lib/raven/tasks.rb
140
140
  - lib/raven/transports.rb
141
141
  - lib/raven/transports/http.rb
142
142
  - lib/raven/transports/udp.rb