sentry-raven 0.12.0 → 0.12.1
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.
Potentially problematic release.
This version of sentry-raven might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/raven/base.rb +3 -8
- data/lib/raven/configuration.rb +1 -0
- data/lib/raven/event.rb +2 -1
- data/lib/raven/{rack.rb → integrations/rack.rb} +2 -0
- data/lib/raven/{railtie.rb → integrations/rails.rb} +5 -5
- data/lib/raven/{rails → integrations/rails}/controller_methods.rb +1 -1
- data/lib/raven/{rails → integrations/rails}/middleware/debug_exceptions_catcher.rb +1 -1
- data/lib/raven/{rake.rb → integrations/rake.rb} +3 -3
- data/lib/raven/{sidekiq.rb → integrations/sidekiq.rb} +1 -0
- data/lib/raven/{tasks.rb → integrations/tasks.rb} +0 -0
- data/lib/raven/interfaces/http.rb +2 -2
- data/lib/raven/okjson.rb +29 -26
- data/lib/raven/processor.rb +1 -2
- data/lib/raven/processor/sanitizedata.rb +18 -24
- data/lib/raven/processor/utf8conversion.rb +1 -1
- data/lib/raven/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdf4bb6934f77389e7393fc2408408020cdfd923
|
4
|
+
data.tar.gz: dc076e2fd742caa665e84ac3d7fedd1bed8ad6cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed202296b99e4622def0e9be5ba2150075723e90deea84fbd1e5f7e66e39235b2d656d4a301896f381ebae8d05f745511055ec5e845b247c6ff13f026e0e8917
|
7
|
+
data.tar.gz: e4730690c60b5902804d6bd0f8c98d18379350d7ca263e6fe84ac95c5c9a042150e2f481f2f323339e2eafc2eae08d1ad89708de4cc0fae4337a180b9ff6142f
|
data/lib/raven/base.rb
CHANGED
@@ -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
|
-
|
211
|
-
|
212
|
-
require
|
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
|
data/lib/raven/configuration.rb
CHANGED
data/lib/raven/event.rb
CHANGED
@@ -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
|
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
|
File without changes
|
@@ -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
|
data/lib/raven/okjson.rb
CHANGED
@@ -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 = '
|
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
|
68
|
-
when Array then arrenc(x
|
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
|
73
|
+
def valenc(x)
|
76
74
|
case x
|
77
|
-
when Hash then objenc(x
|
78
|
-
when Array then arrenc(x
|
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
|
-
|
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
|
431
|
-
|
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
|
438
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
data/lib/raven/processor.rb
CHANGED
@@ -6,36 +6,30 @@ module Raven
|
|
6
6
|
VALUES_RE = /^\d{16}$/
|
7
7
|
|
8
8
|
def process(value)
|
9
|
-
|
9
|
+
value.inject(value) { |memo,(k,v)| memo[k] = sanitize(k,v); memo }
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
32
|
-
|
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
|
data/lib/raven/version.rb
CHANGED
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.
|
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-
|
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
|