sentry-sanitizer 0.1.1 → 0.1.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04b5f5cd976e0d3946f7d1d8791b4d9c8530eebe09a772b78098ae335feffaf0
|
4
|
+
data.tar.gz: 84fa68c96490549641f44a0bee8e53a11a1ec25953cde17d39dea14e9462b852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fcfba576d61cd2f0f57c46bdbdc1bde94ee09cda03e296ba501473668d4b482c0615309af6b78aab96b82fcdc0fd469f6cd34a51e8fc1facf77c83b98e98497
|
7
|
+
data.tar.gz: b3603c13482ab3f8bc6b780e836ec448337059d11754e5dc5a2855e97320d3b19846a6ff7865c25d9021704d3f9db7740e0aacf4820686a6fae7a966c2645549
|
@@ -29,8 +29,8 @@ module Sentry
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def sanitize_request(request)
|
32
|
-
request.data = sanitize_hash(request.data)
|
33
|
-
request.headers = sanitize_headers(request.headers)
|
32
|
+
request.data = sanitize_hash(request.data) unless fields.size.zero?
|
33
|
+
request.headers = sanitize_headers(request.headers) unless http_headers.size.zero?
|
34
34
|
request.cookies = sanitize_cookies(request.cookies) if cookies
|
35
35
|
end
|
36
36
|
|
@@ -1,57 +1,14 @@
|
|
1
1
|
require 'sentry/configuration'
|
2
2
|
require 'sentry/sanitizer/cleaner'
|
3
|
+
require 'sentry/sanitizer/configuration_mixin'
|
3
4
|
|
4
5
|
module Sentry
|
5
6
|
# Monkey-patching Sentry::Configuration
|
6
7
|
class Configuration
|
7
|
-
|
8
|
-
def before_send=(value)
|
9
|
-
unless value == false || value.respond_to?(:call)
|
10
|
-
raise ArgumentError, "before_send must be callable (or false to disable)"
|
11
|
-
end
|
12
|
-
|
13
|
-
return value if value == false
|
14
|
-
|
15
|
-
@before_send_hook_list ||= []
|
16
|
-
@before_send_hook_list << value
|
17
|
-
|
18
|
-
@before_send = ->(event, hint) {
|
19
|
-
@before_send_hook_list.each do |hook|
|
20
|
-
event = hook.call(event, hint)
|
21
|
-
end
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
def sanitize
|
26
|
-
@sanitize ||= Sentry::Sanitizer::Configuration.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def sanitize_fields=(fields)
|
30
|
-
unless fields.is_a? Array
|
31
|
-
raise ArgumentError, 'sanitize_fields must be array'
|
32
|
-
end
|
33
|
-
|
34
|
-
sanitize.fields = fields
|
35
|
-
end
|
36
|
-
|
37
|
-
def sanitize_http_headers=(headers)
|
38
|
-
unless headers.is_a? Array
|
39
|
-
raise ArgumentError, 'sanitize_http_headers must be array'
|
40
|
-
end
|
41
|
-
|
42
|
-
sanitize.http_headers = headers
|
43
|
-
end
|
44
|
-
|
45
|
-
def sanitize_cookies=(cookies)
|
46
|
-
unless [TrueClass, FalseClass].include?(cookies.class)
|
47
|
-
raise ArgumentError, 'sanitize_cookies must be boolean'
|
48
|
-
end
|
49
|
-
|
50
|
-
sanitize.cookies = cookies
|
51
|
-
end
|
8
|
+
prepend Sentry::Sanitizer::ConfigurationMixin
|
52
9
|
|
53
10
|
add_post_initialization_callback do
|
54
|
-
self.before_send = Sentry::Sanitizer::Cleaner::HOOK
|
11
|
+
self.before_send = Sentry::Sanitizer::Cleaner::HOOK
|
55
12
|
end
|
56
13
|
end
|
57
14
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Sanitizer
|
3
|
+
module ConfigurationMixin
|
4
|
+
# Allow adding multiple hooks for this extension
|
5
|
+
def before_send=(value)
|
6
|
+
unless value == false || value.respond_to?(:call)
|
7
|
+
raise ArgumentError, "before_send must be callable (or false to disable)"
|
8
|
+
end
|
9
|
+
|
10
|
+
return value if value == false
|
11
|
+
|
12
|
+
@before_send_hook_list ||= []
|
13
|
+
@before_send_hook_list << value
|
14
|
+
|
15
|
+
@before_send = ->(event, hint) {
|
16
|
+
@before_send_hook_list.each do |hook|
|
17
|
+
event = hook.call(event, hint)
|
18
|
+
end
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def sanitize
|
23
|
+
@sanitize ||= Sentry::Sanitizer::Configuration.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def sanitize_fields=(fields)
|
27
|
+
unless fields.is_a? Array
|
28
|
+
raise ArgumentError, 'sanitize_fields must be array'
|
29
|
+
end
|
30
|
+
|
31
|
+
sanitize.fields = fields
|
32
|
+
end
|
33
|
+
|
34
|
+
def sanitize_http_headers=(headers)
|
35
|
+
unless headers.is_a? Array
|
36
|
+
raise ArgumentError, 'sanitize_http_headers must be array'
|
37
|
+
end
|
38
|
+
|
39
|
+
sanitize.http_headers = headers
|
40
|
+
end
|
41
|
+
|
42
|
+
def sanitize_cookies=(cookies)
|
43
|
+
unless [TrueClass, FalseClass].include?(cookies.class)
|
44
|
+
raise ArgumentError, 'sanitize_cookies must be boolean'
|
45
|
+
end
|
46
|
+
|
47
|
+
sanitize.cookies = cookies
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-sanitizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentine Kiselev
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/sentry/sanitizer.rb
|
88
88
|
- lib/sentry/sanitizer/cleaner.rb
|
89
89
|
- lib/sentry/sanitizer/configuration.rb
|
90
|
+
- lib/sentry/sanitizer/configuration_mixin.rb
|
90
91
|
- lib/sentry/sanitizer/version.rb
|
91
92
|
- sentry-sanitizer.gemspec
|
92
93
|
homepage: https://github.com/mrexox/sentry-sanitizer
|