timber 2.0.8 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/timber/events/controller_call.rb +1 -9
- data/lib/timber/events/exception.rb +3 -2
- data/lib/timber/util/hash.rb +13 -0
- data/lib/timber/util/http_event.rb +8 -16
- data/lib/timber/util/object.rb +2 -2
- data/lib/timber/version.rb +1 -1
- data/spec/timber/events/controller_call_spec.rb +12 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77cca27158a28ec9275818a2efaba37229e2d121
|
4
|
+
data.tar.gz: 5423ac901328f3c57811bfc1a7855970d798b55c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58fb47529e061305c0d178458bf2a5bc170610986492fd4a9573f1fae52ad85b5809f12ec2e2dea7b6553441d10a5d849c63cdfff0ae1cc573bf27e3a0f0d4b
|
7
|
+
data.tar.gz: 7a9d4dcde4b68e23b15a62a2e607c76fb371dd313dd28a9d650607be12d3af3fb97e0f6e3ad273ae2ac46762025541d918c7ca065fd3ee045483b65ba75c5fb9
|
@@ -49,15 +49,7 @@ module Timber
|
|
49
49
|
|
50
50
|
def sanitize_params(params)
|
51
51
|
if params.is_a?(::Hash)
|
52
|
-
|
53
|
-
k = k.to_s.downcase
|
54
|
-
case k
|
55
|
-
when PASSWORD_NAME
|
56
|
-
h[k] = SANITIZED_VALUE
|
57
|
-
else
|
58
|
-
h[k] = v
|
59
|
-
end
|
60
|
-
end
|
52
|
+
Util::Hash.sanitize(params, [PASSWORD_NAME])
|
61
53
|
else
|
62
54
|
params
|
63
55
|
end
|
@@ -37,8 +37,9 @@ module Timber
|
|
37
37
|
def parse_backtrace_line(line)
|
38
38
|
# using split for performance reasons
|
39
39
|
file, line, function_part = line.split(":", 3)
|
40
|
-
_prefix,
|
41
|
-
|
40
|
+
_prefix, function_pre = function_part.split("`", 2)
|
41
|
+
function = Util::Object.try(function_pre, :chomp, "'")
|
42
|
+
{file: file, line: line.to_i, function: function}
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
data/lib/timber/util/hash.rb
CHANGED
@@ -2,6 +2,8 @@ module Timber
|
|
2
2
|
module Util
|
3
3
|
# @private
|
4
4
|
module Hash
|
5
|
+
SANITIZED_VALUE = '[sanitized]'.freeze
|
6
|
+
|
5
7
|
extend self
|
6
8
|
|
7
9
|
def deep_compact(hash)
|
@@ -21,6 +23,17 @@ module Timber
|
|
21
23
|
|
22
24
|
new_hash
|
23
25
|
end
|
26
|
+
|
27
|
+
def sanitize(hash, keys_to_sanitize)
|
28
|
+
hash.each_with_object({}) do |(k, v), h|
|
29
|
+
k = k.to_s.downcase
|
30
|
+
if keys_to_sanitize.include?(k)
|
31
|
+
h[k] = SANITIZED_VALUE
|
32
|
+
else
|
33
|
+
h[k] = v
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
24
37
|
end
|
25
38
|
end
|
26
39
|
end
|
@@ -3,7 +3,6 @@ module Timber
|
|
3
3
|
module HTTPEvent
|
4
4
|
AUTHORIZATION_HEADER = 'authorization'.freeze
|
5
5
|
QUERY_STRING_LIMIT = 5_000.freeze
|
6
|
-
SANITIZED_VALUE = '[sanitized]'.freeze
|
7
6
|
|
8
7
|
extend self
|
9
8
|
|
@@ -25,22 +24,15 @@ module Timber
|
|
25
24
|
|
26
25
|
def normalize_headers(headers)
|
27
26
|
if headers.is_a?(::Hash)
|
28
|
-
headers.each_with_object({}) do |(k, v), h|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
if Config.instance.header_filters && Config.instance.header_filters.include?(k)
|
35
|
-
h[k] = SANITIZED_VALUE
|
36
|
-
else
|
37
|
-
# Force the header into a valid UTF-8 string, otherwise we will encounter
|
38
|
-
# encoding issues when we convert this data to json. Moreoever, if the
|
39
|
-
# data is already valid UTF-8 we don't pay a penalty.
|
40
|
-
h[k] = Timber::Util::String.normalize_to_utf8(v)
|
41
|
-
end
|
42
|
-
end
|
27
|
+
h = headers.each_with_object({}) do |(k, v), h|
|
28
|
+
# Force the header into a valid UTF-8 string, otherwise we will encounter
|
29
|
+
# encoding issues when we convert this data to json. Moreoever, if the
|
30
|
+
# data is already valid UTF-8 we don't pay a penalty.
|
31
|
+
h[k] = Timber::Util::String.normalize_to_utf8(v)
|
43
32
|
end
|
33
|
+
|
34
|
+
keys_to_sanitize = [AUTHORIZATION_HEADER] + (Config.instance.header_filters || [])
|
35
|
+
Util::Hash.sanitize(h, keys_to_sanitize)
|
44
36
|
else
|
45
37
|
headers
|
46
38
|
end
|
data/lib/timber/util/object.rb
CHANGED
@@ -3,11 +3,11 @@ module Timber
|
|
3
3
|
# @private
|
4
4
|
module Object
|
5
5
|
# @private
|
6
|
-
def self.try(object, method)
|
6
|
+
def self.try(object, method, *args)
|
7
7
|
if object == nil
|
8
8
|
nil
|
9
9
|
else
|
10
|
-
object.send(method) rescue object
|
10
|
+
object.send(method, *args) rescue object
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/timber/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Timber::Events::ControllerCall, :rails_23 => true do
|
6
|
+
describe ".initialize" do
|
7
|
+
it "sanitizes the password param" do
|
8
|
+
event = described_class.new(controller: 'controller', action: 'action', params: {password: 'password'})
|
9
|
+
expect(event.params).to eq({'password' => '[sanitized]'})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timber Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- spec/timber/contexts_spec.rb
|
231
231
|
- spec/timber/current_context_spec.rb
|
232
232
|
- spec/timber/event_spec.rb
|
233
|
+
- spec/timber/events/controller_call_spec.rb
|
233
234
|
- spec/timber/events/custom_spec.rb
|
234
235
|
- spec/timber/events/http_server_request_spec.rb
|
235
236
|
- spec/timber/events_spec.rb
|
@@ -285,6 +286,7 @@ test_files:
|
|
285
286
|
- spec/timber/contexts_spec.rb
|
286
287
|
- spec/timber/current_context_spec.rb
|
287
288
|
- spec/timber/event_spec.rb
|
289
|
+
- spec/timber/events/controller_call_spec.rb
|
288
290
|
- spec/timber/events/custom_spec.rb
|
289
291
|
- spec/timber/events/http_server_request_spec.rb
|
290
292
|
- spec/timber/events_spec.rb
|