raygun4ruby 1.1.12 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +51 -0
- data/lib/raygun/client.rb +29 -9
- data/lib/raygun/configuration.rb +33 -1
- data/lib/raygun/middleware/rack_exception_interceptor.rb +2 -2
- data/lib/raygun/middleware/rails_insert_affected_user.rb +1 -2
- data/lib/raygun/railtie.rb +0 -2
- data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +23 -0
- data/lib/raygun/version.rb +1 -1
- data/lib/raygun.rb +24 -1
- data/raygun4ruby.gemspec +1 -0
- data/specs/services/apply_whitelist_filter_to_payload_spec.rb +253 -0
- data/test/unit/client_test.rb +390 -28
- data/test/unit/configuration_test.rb +16 -0
- data/test/unit/raygun_test.rb +12 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 880e6dc1a2610cd344816502b0ff0b9c8025a48c
|
4
|
+
data.tar.gz: 4c5be5b014cbbf39a9433a43a2cb36af56262832
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5d1eaba8ca8a31a4e1b66b6444af7d478ac4e64bd3fff3629777ca513de4265ce3f64348c2dc97e27ef6051e960000be0cc295de803e43b067b998d4a320dd6
|
7
|
+
data.tar.gz: 11a0d8f62960c06dfb43530a23df400f8d976e32ad97325a756acf7eaf6ecda321fd19b2c87b5665f21241e4db1a78a0b61ce18d39ccb854e0b95617b95060c7
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
## 1.2.0 (09/03/2017)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
- Added two new configuration options, `filter_payload_with_whitelist` and `whitelist_payload_shape`
|
5
|
+
- See [README.md](https://github.com/MindscapeHQ/raygun4ruby#filtering-the-payload-by-whitelist) for an example of how to use them
|
6
|
+
- When raygun4ruby encounters an exception trying to track an exception it will try once to send that exception to Raygun so you are notified
|
7
|
+
|
8
|
+
Bugfixes:
|
9
|
+
- raygun4ruby will no longer crash and suppress app exceptions when the API key is not configured
|
data/README.md
CHANGED
@@ -91,6 +91,53 @@ Raygun.setup do |config|
|
|
91
91
|
end
|
92
92
|
```
|
93
93
|
|
94
|
+
### Filtering the payload by whitelist
|
95
|
+
|
96
|
+
As an alternative to the above, you can also opt-in to the keys/values to be sent to Raygun by providing a specific whitelist of the keys you want to transmit.
|
97
|
+
|
98
|
+
This disables the blacklist filtering above (`filter_parameters`), and is applied to the entire payload (error, request, environment and custom data included), not just the request parameters.
|
99
|
+
|
100
|
+
In order to opt-in to this feature, set `filter_payload_with_whitelist` to `true`, and specify a shape of what keys you want (the default is below which is to allow everything through, this also means that the query parameters filtered out by default like password, creditcard etc will not be unless changed):
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
Raygun.setup do |config|
|
104
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
105
|
+
config.filter_payload_with_whitelist = true
|
106
|
+
|
107
|
+
config.whitelist_payload_shape = {
|
108
|
+
machineName: true,
|
109
|
+
version: true,
|
110
|
+
error: true,
|
111
|
+
userCustomData: true,
|
112
|
+
tags: true,
|
113
|
+
request: {
|
114
|
+
hostName: true,
|
115
|
+
url: true,
|
116
|
+
httpMethod: true,
|
117
|
+
iPAddress: true,
|
118
|
+
queryString: true,
|
119
|
+
headers: true,
|
120
|
+
form: {}, # Set to empty hash so that it doesn't just filter out the whole thing, but instead filters out each individual param
|
121
|
+
rawData: true
|
122
|
+
}
|
123
|
+
}
|
124
|
+
end
|
125
|
+
```
|
126
|
+
|
127
|
+
Alternatively, provide a Proc to filter the payload using your own logic:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
Raygun.setup do |config|
|
131
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
132
|
+
config.filter_payload_with_whitelist = true
|
133
|
+
|
134
|
+
config.whitelist_payload_keys do |payload|
|
135
|
+
# Return the payload mutated into your desired form
|
136
|
+
payload
|
137
|
+
end
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
94
141
|
### Custom User Data
|
95
142
|
Custom data can be added to `track_exception` by passing a custom_data key in the second parameter hash.
|
96
143
|
|
@@ -226,6 +273,10 @@ Raygun4Ruby can track errors from Sidekiq (2.x or 3+). All you need to do is add
|
|
226
273
|
|
227
274
|
Either in your Raygun initializer or wherever else takes your fancy :)
|
228
275
|
|
276
|
+
### Other Configuration options
|
277
|
+
|
278
|
+
For a complete list of configuration options see the [configuration.rb](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb) file
|
279
|
+
|
229
280
|
## Found a bug?
|
230
281
|
|
231
282
|
Oops! Just let us know by opening an Issue on Github.
|
data/lib/raygun/client.rb
CHANGED
@@ -116,7 +116,7 @@ module Raygun
|
|
116
116
|
|
117
117
|
def form_params(env)
|
118
118
|
params = action_dispatch_params(env) || rack_params(env) || {}
|
119
|
-
|
119
|
+
filter_params_with_blacklist(params, env["action_dispatch.parameter_filter"])
|
120
120
|
end
|
121
121
|
|
122
122
|
def action_dispatch_params(env)
|
@@ -137,7 +137,7 @@ module Raygun
|
|
137
137
|
|
138
138
|
def filter_custom_data(env)
|
139
139
|
params = env.delete(:custom_data) || {}
|
140
|
-
|
140
|
+
filter_params_with_blacklist(params, env["action_dispatch.parameter_filter"])
|
141
141
|
end
|
142
142
|
|
143
143
|
# see http://raygun.io/raygun-providers/rest-json-api?v=1
|
@@ -145,7 +145,11 @@ module Raygun
|
|
145
145
|
custom_data = filter_custom_data(env) || {}
|
146
146
|
tags = env.delete(:tags) || []
|
147
147
|
|
148
|
-
|
148
|
+
if rails_env
|
149
|
+
tags << rails_env
|
150
|
+
else
|
151
|
+
tags << rack_env
|
152
|
+
end
|
149
153
|
|
150
154
|
grouping_key = env.delete(:grouping_key)
|
151
155
|
|
@@ -163,6 +167,10 @@ module Raygun
|
|
163
167
|
|
164
168
|
error_details.merge!(user: user_information(env)) if affected_user_present?(env)
|
165
169
|
|
170
|
+
if Raygun.configuration.filter_payload_with_whitelist
|
171
|
+
error_details = filter_payload_with_whitelist(error_details)
|
172
|
+
end
|
173
|
+
|
166
174
|
{
|
167
175
|
occurredOn: Time.now.utc.iso8601,
|
168
176
|
details: error_details
|
@@ -173,17 +181,29 @@ module Raygun
|
|
173
181
|
self.class.post("/entries", verify_peer: true, verify: true, headers: @headers, body: JSON.generate(payload_hash))
|
174
182
|
end
|
175
183
|
|
176
|
-
def
|
177
|
-
if Raygun.configuration.
|
178
|
-
|
184
|
+
def filter_params_with_blacklist(params_hash = {}, extra_filter_keys = nil)
|
185
|
+
return params_hash if Raygun.configuration.filter_payload_with_whitelist
|
186
|
+
|
187
|
+
filter_parameters = Raygun.configuration.filter_parameters
|
188
|
+
|
189
|
+
if filter_parameters.is_a? Proc
|
190
|
+
filter_parameters.call(params_hash)
|
179
191
|
else
|
180
|
-
filter_keys = (Array(extra_filter_keys) +
|
192
|
+
filter_keys = (Array(extra_filter_keys) + filter_parameters).map(&:to_s)
|
193
|
+
|
181
194
|
filter_params_with_array(params_hash, filter_keys)
|
182
195
|
end
|
183
196
|
end
|
184
197
|
|
185
|
-
def
|
186
|
-
|
198
|
+
def filter_payload_with_whitelist(payload_hash)
|
199
|
+
shape = Raygun.configuration.whitelist_payload_shape
|
200
|
+
|
201
|
+
if shape.is_a? Proc
|
202
|
+
shape.call(payload_hash)
|
203
|
+
else
|
204
|
+
# Always keep the client hash, so force it to true here
|
205
|
+
Services::ApplyWhitelistFilterToPayload.new.call(shape.merge(client: true), payload_hash)
|
206
|
+
end
|
187
207
|
end
|
188
208
|
|
189
209
|
def filter_params_with_array(params_hash, filter_keys)
|
data/lib/raygun/configuration.rb
CHANGED
@@ -26,7 +26,7 @@ module Raygun
|
|
26
26
|
# Tags to send with each exception
|
27
27
|
config_option :tags
|
28
28
|
|
29
|
-
# Logger to use when
|
29
|
+
# Logger to use when we find an exception :)
|
30
30
|
config_option :logger
|
31
31
|
|
32
32
|
# Should we actually report exceptions to Raygun? (Usually disabled in Development mode, for instance)
|
@@ -44,6 +44,12 @@ module Raygun
|
|
44
44
|
# Which parameter keys should we filter out by default?
|
45
45
|
config_option :filter_parameters
|
46
46
|
|
47
|
+
# Should we switch to a white listing mode for keys instead of the default blacklist?
|
48
|
+
config_option :filter_payload_with_whitelist
|
49
|
+
|
50
|
+
# If :filter_payload_with_whitelist is true, which keys should we whitelist?
|
51
|
+
config_option :whitelist_payload_shape
|
52
|
+
|
47
53
|
# Hash of proxy settings - :address, :port (defaults to 80), :username and :password (both default to nil)
|
48
54
|
config_option :proxy_settings
|
49
55
|
|
@@ -59,6 +65,25 @@ module Raygun
|
|
59
65
|
|
60
66
|
DEFAULT_FILTER_PARAMETERS = [ :password, :card_number, :cvv ]
|
61
67
|
|
68
|
+
DEFAULT_WHITELIST_PAYLOAD_SHAPE_REQUEST = {
|
69
|
+
hostName: true,
|
70
|
+
url: true,
|
71
|
+
httpMethod: true,
|
72
|
+
iPAddress: true,
|
73
|
+
queryString: true,
|
74
|
+
headers: true,
|
75
|
+
form: {}, # Set to empty hash so that it doesn't just filter out the whole thing, but instead filters out each individual param
|
76
|
+
rawData: true
|
77
|
+
}.freeze
|
78
|
+
DEFAULT_WHITELIST_PAYLOAD_SHAPE = {
|
79
|
+
machineName: true,
|
80
|
+
version: true,
|
81
|
+
error: true,
|
82
|
+
userCustomData: true,
|
83
|
+
tags: true,
|
84
|
+
request: DEFAULT_WHITELIST_PAYLOAD_SHAPE_REQUEST
|
85
|
+
}.freeze
|
86
|
+
|
62
87
|
attr_reader :defaults
|
63
88
|
|
64
89
|
def initialize
|
@@ -73,6 +98,8 @@ module Raygun
|
|
73
98
|
affected_user_method: :current_user,
|
74
99
|
affected_user_identifier_methods: [ :email, :username, :id ],
|
75
100
|
filter_parameters: DEFAULT_FILTER_PARAMETERS,
|
101
|
+
filter_payload_with_whitelist: false,
|
102
|
+
whitelist_payload_shape: DEFAULT_WHITELIST_PAYLOAD_SHAPE,
|
76
103
|
proxy_settings: {}
|
77
104
|
})
|
78
105
|
end
|
@@ -98,6 +125,11 @@ module Raygun
|
|
98
125
|
read_value(:filter_parameters)
|
99
126
|
end
|
100
127
|
|
128
|
+
def whitelist_payload_shape(&filter_proc)
|
129
|
+
set_value(:whitelist_payload_shape, filter_proc) if block_given?
|
130
|
+
read_value(:whitelist_payload_shape)
|
131
|
+
end
|
132
|
+
|
101
133
|
private
|
102
134
|
|
103
135
|
def read_value(name)
|
@@ -9,10 +9,10 @@ module Raygun
|
|
9
9
|
def call(env)
|
10
10
|
response = @app.call(env)
|
11
11
|
rescue Exception => exception
|
12
|
-
Raygun.track_exception(exception, env)
|
12
|
+
Raygun.track_exception(exception, env) if Raygun.configured?
|
13
13
|
raise exception
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
data/lib/raygun/railtie.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class Raygun::Railtie < Rails::Railtie
|
2
|
-
|
3
2
|
initializer "raygun.configure_rails_initialization" do |app|
|
4
3
|
|
5
4
|
# Thanks Airbrake: See https://github.com/rails/rails/pull/8624
|
@@ -34,5 +33,4 @@ class Raygun::Railtie < Rails::Railtie
|
|
34
33
|
rake_tasks do
|
35
34
|
load "tasks/raygun.tasks"
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Raygun
|
2
|
+
module Services
|
3
|
+
class ApplyWhitelistFilterToPayload
|
4
|
+
def call(whitelist, payload)
|
5
|
+
filter_hash(whitelist, payload)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def filter_hash(whitelist, hash)
|
11
|
+
hash.each do |k, v|
|
12
|
+
unless whitelist && (whitelist[k] || whitelist[k.to_sym])
|
13
|
+
hash[k] = '[FILTERED]'
|
14
|
+
end
|
15
|
+
|
16
|
+
if v.is_a?(Hash) && whitelist[k].is_a?(Hash)
|
17
|
+
filter_hash(whitelist[k], v)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/raygun/version.rb
CHANGED
data/lib/raygun.rb
CHANGED
@@ -10,7 +10,12 @@ require "raygun/configuration"
|
|
10
10
|
require "raygun/client"
|
11
11
|
require "raygun/middleware/rack_exception_interceptor"
|
12
12
|
require "raygun/testable"
|
13
|
+
require "raygun/services/apply_whitelist_filter_to_payload"
|
13
14
|
require "raygun/railtie" if defined?(Rails)
|
15
|
+
begin
|
16
|
+
require "pry"
|
17
|
+
rescue LoadError
|
18
|
+
end
|
14
19
|
|
15
20
|
module Raygun
|
16
21
|
|
@@ -37,7 +42,11 @@ module Raygun
|
|
37
42
|
configuration.defaults
|
38
43
|
end
|
39
44
|
|
40
|
-
def
|
45
|
+
def configured?
|
46
|
+
!!configuration.api_key
|
47
|
+
end
|
48
|
+
|
49
|
+
def track_exception(exception_instance, env = {}, retry_count = 1)
|
41
50
|
if should_report?(exception_instance)
|
42
51
|
log("[Raygun] Tracking Exception...")
|
43
52
|
Client.new.track_exception(exception_instance, env)
|
@@ -45,6 +54,16 @@ module Raygun
|
|
45
54
|
rescue Exception => e
|
46
55
|
if configuration.failsafe_logger
|
47
56
|
failsafe_log("Problem reporting exception to Raygun: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
|
57
|
+
end
|
58
|
+
|
59
|
+
if retry_count > 0
|
60
|
+
new_exception = e.exception("raygun4ruby encountered an exception processing your exception")
|
61
|
+
new_exception.set_backtrace(e.backtrace)
|
62
|
+
|
63
|
+
env[:custom_data] ||= {}
|
64
|
+
env[:custom_data].merge!(original_stacktrace: exception_instance.backtrace)
|
65
|
+
|
66
|
+
track_exception(new_exception, env, retry_count - 1)
|
48
67
|
else
|
49
68
|
raise e
|
50
69
|
end
|
@@ -66,6 +85,10 @@ module Raygun
|
|
66
85
|
|
67
86
|
private
|
68
87
|
|
88
|
+
def print_api_key_warning
|
89
|
+
$stderr.puts(NO_API_KEY_MESSAGE)
|
90
|
+
end
|
91
|
+
|
69
92
|
def should_report?(exception)
|
70
93
|
return false if configuration.silence_reporting
|
71
94
|
return false if configuration.ignore.flatten.include?(exception.class.to_s)
|
data/raygun4ruby.gemspec
CHANGED
@@ -0,0 +1,253 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/pride"
|
3
|
+
require_relative "../../lib/raygun"
|
4
|
+
|
5
|
+
module Raygun
|
6
|
+
module Services
|
7
|
+
describe ApplyWhitelistFilterToPayload do
|
8
|
+
let(:service) { ApplyWhitelistFilterToPayload.new }
|
9
|
+
|
10
|
+
describe "top level keys" do
|
11
|
+
let(:payload) do
|
12
|
+
{ foo: 1, bar: 2 }
|
13
|
+
end
|
14
|
+
let(:expected) do
|
15
|
+
{ foo: 1 , bar: '[FILTERED]'}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "filters out keys that are not present in the shape" do
|
19
|
+
shape = {
|
20
|
+
foo: true
|
21
|
+
}
|
22
|
+
|
23
|
+
new_payload = service.call(shape, payload)
|
24
|
+
|
25
|
+
new_payload.must_equal(expected)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "filters out keys that are set to false" do
|
29
|
+
shape = {
|
30
|
+
foo: true,
|
31
|
+
bar: false
|
32
|
+
}
|
33
|
+
|
34
|
+
new_payload = service.call(shape, payload)
|
35
|
+
|
36
|
+
new_payload.must_equal(expected)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "nested hashes" do
|
41
|
+
let(:payload) {{
|
42
|
+
foo: 1,
|
43
|
+
bar: {
|
44
|
+
baz: 2,
|
45
|
+
qux: 3
|
46
|
+
}
|
47
|
+
}}
|
48
|
+
let(:expected) {{
|
49
|
+
foo: 1,
|
50
|
+
bar: {
|
51
|
+
baz: 2,
|
52
|
+
qux: '[FILTERED]'
|
53
|
+
}
|
54
|
+
}}
|
55
|
+
|
56
|
+
it "filters out keys in nested hashes" do
|
57
|
+
shape = {
|
58
|
+
foo: true,
|
59
|
+
bar: {
|
60
|
+
baz: true
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
new_payload = service.call(shape, payload)
|
65
|
+
|
66
|
+
new_payload.must_equal(expected)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "filters out a nested hash if the whitelist does not contain it" do
|
70
|
+
shape = {
|
71
|
+
foo: true
|
72
|
+
}
|
73
|
+
expected[:bar] = "[FILTERED]"
|
74
|
+
|
75
|
+
new_payload = service.call(shape, payload)
|
76
|
+
|
77
|
+
new_payload.must_equal(expected)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "handles nested hashes when the whitelist is set to allow the whole hash" do
|
81
|
+
shape = {
|
82
|
+
bar: true
|
83
|
+
}
|
84
|
+
expected = {
|
85
|
+
foo: '[FILTERED]',
|
86
|
+
bar: {
|
87
|
+
baz: 2,
|
88
|
+
qux: 3
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
new_payload = service.call(shape, payload)
|
93
|
+
|
94
|
+
new_payload.must_equal(expected)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "handles nested hashes when the whitelist is set to not allow the whole hash" do
|
98
|
+
shape = {
|
99
|
+
foo: true,
|
100
|
+
bar: false
|
101
|
+
}
|
102
|
+
expected = {
|
103
|
+
foo: 1,
|
104
|
+
bar: '[FILTERED]'
|
105
|
+
}
|
106
|
+
|
107
|
+
new_payload = service.call(shape, payload)
|
108
|
+
|
109
|
+
new_payload.must_equal(expected)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "string keys" do
|
114
|
+
it "handles the case where a payload key is a string and a whitelist key is a symbol" do
|
115
|
+
shape = {
|
116
|
+
foo: true
|
117
|
+
}
|
118
|
+
payload = {
|
119
|
+
"foo" => 1,
|
120
|
+
"bar" => 2
|
121
|
+
}
|
122
|
+
expected = {
|
123
|
+
"foo" => 1,
|
124
|
+
"bar" => '[FILTERED]'
|
125
|
+
}
|
126
|
+
|
127
|
+
new_payload = service.call(shape, payload)
|
128
|
+
|
129
|
+
new_payload.must_equal(expected)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "handles a very complex shape" do
|
134
|
+
shape = {
|
135
|
+
machineName: true,
|
136
|
+
version: true,
|
137
|
+
client: true,
|
138
|
+
error: {
|
139
|
+
className: true,
|
140
|
+
message: true,
|
141
|
+
stackTrace: true
|
142
|
+
},
|
143
|
+
userCustomData: true,
|
144
|
+
tags: true,
|
145
|
+
request: {
|
146
|
+
hostName: true,
|
147
|
+
url: true,
|
148
|
+
httpMethod: true,
|
149
|
+
iPAddress: true,
|
150
|
+
queryString: {
|
151
|
+
param1: true,
|
152
|
+
param2: true,
|
153
|
+
},
|
154
|
+
headers: {
|
155
|
+
"Host" => true,
|
156
|
+
"Connection" => true,
|
157
|
+
"Upgrade-Insecure_requests" => true,
|
158
|
+
"User-Agent" => false,
|
159
|
+
"Accept" => true,
|
160
|
+
},
|
161
|
+
form: {
|
162
|
+
controller: true,
|
163
|
+
action: false
|
164
|
+
},
|
165
|
+
rawData: {
|
166
|
+
controller: true,
|
167
|
+
action: false
|
168
|
+
}
|
169
|
+
},
|
170
|
+
user: false,
|
171
|
+
}
|
172
|
+
payload = {
|
173
|
+
machineName: "mindscapes-MacBook-Pro.local",
|
174
|
+
version: nil,
|
175
|
+
client: {name: "Raygun4Ruby Gem", version: "1.1.12", clientUrl: "https://github.com/MindscapeHQ/raygun4ruby"},
|
176
|
+
error: {className: "Exception", message: "foo", stackTrace: []},
|
177
|
+
userCustomData: {},
|
178
|
+
tags: ["development"],
|
179
|
+
request: {
|
180
|
+
hostName: "localhost",
|
181
|
+
url: "/make-me-an-error-charlie",
|
182
|
+
httpMethod: "GET",
|
183
|
+
iPAddress: "::1",
|
184
|
+
queryString: {
|
185
|
+
param1: "1",
|
186
|
+
param2: "2",
|
187
|
+
param3: "3",
|
188
|
+
},
|
189
|
+
headers: {
|
190
|
+
"Host"=>"localhost:3000",
|
191
|
+
"Connection"=>"keep-alive",
|
192
|
+
"Upgrade-Insecure_requests"=>"1",
|
193
|
+
"User-Agent"=> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
194
|
+
"Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
195
|
+
"Accept-Encoding"=>"gzip, deflate, sdch, br",
|
196
|
+
"Accept-Language"=>"en-US,en;q=0.8",
|
197
|
+
"Version"=>"HTTP/1.1"
|
198
|
+
},
|
199
|
+
form: {
|
200
|
+
controller: "home",
|
201
|
+
action: "raise_error"
|
202
|
+
},
|
203
|
+
rawData: {
|
204
|
+
controller: "home",
|
205
|
+
action: "raise_error"
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
expected = {
|
210
|
+
machineName: "mindscapes-MacBook-Pro.local",
|
211
|
+
version: nil,
|
212
|
+
client: {name: "Raygun4Ruby Gem", version: "1.1.12", clientUrl: "https://github.com/MindscapeHQ/raygun4ruby"},
|
213
|
+
error: {className: "Exception", message: "foo", stackTrace: []},
|
214
|
+
userCustomData: {},
|
215
|
+
tags: ["development"],
|
216
|
+
request: {
|
217
|
+
hostName: "localhost",
|
218
|
+
url: "/make-me-an-error-charlie",
|
219
|
+
httpMethod: "GET",
|
220
|
+
iPAddress: "::1",
|
221
|
+
queryString: {
|
222
|
+
param1: "1",
|
223
|
+
param2: "2",
|
224
|
+
param3: '[FILTERED]'
|
225
|
+
},
|
226
|
+
headers: {
|
227
|
+
"Host"=>"localhost:3000",
|
228
|
+
"Connection"=>"keep-alive",
|
229
|
+
"Upgrade-Insecure_requests"=>"1",
|
230
|
+
"User-Agent" => "[FILTERED]",
|
231
|
+
"Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
232
|
+
"Accept-Encoding" => "[FILTERED]",
|
233
|
+
"Accept-Language" => "[FILTERED]",
|
234
|
+
"Version" => "[FILTERED]"
|
235
|
+
},
|
236
|
+
form: {
|
237
|
+
controller: "home",
|
238
|
+
action: "[FILTERED]"
|
239
|
+
},
|
240
|
+
rawData: {
|
241
|
+
controller: "home",
|
242
|
+
action: "[FILTERED]"
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
new_payload = service.call(shape, payload)
|
248
|
+
|
249
|
+
new_payload.must_equal(expected)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
data/test/unit/client_test.rb
CHANGED
@@ -113,7 +113,7 @@ class ClientTest < Raygun::UnitTest
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def test_unicode
|
116
|
-
e = TestException.new('日本語のメッセージ')
|
116
|
+
e = TestException.new('日本語のメッセージ です')
|
117
117
|
|
118
118
|
assert_silent { @client.track_exception(e) }
|
119
119
|
end
|
@@ -271,10 +271,12 @@ class ClientTest < Raygun::UnitTest
|
|
271
271
|
def test_filter_parameters_using_proc
|
272
272
|
# filter any parameters that start with "nsa_only"
|
273
273
|
Raygun.configuration.filter_parameters do |hash|
|
274
|
-
hash.inject({}) do |sanitized_hash,
|
275
|
-
k
|
276
|
-
|
277
|
-
|
274
|
+
hash.inject({}) do |sanitized_hash, (k, v)|
|
275
|
+
sanitized_hash[k] = if k.start_with? "nsa_only"
|
276
|
+
"[OUREYESONLY]"
|
277
|
+
else
|
278
|
+
v
|
279
|
+
end
|
278
280
|
sanitized_hash
|
279
281
|
end
|
280
282
|
end
|
@@ -420,31 +422,391 @@ class ClientTest < Raygun::UnitTest
|
|
420
422
|
end
|
421
423
|
end
|
422
424
|
|
423
|
-
|
425
|
+
def test_filter_payload_with_whitelist_never_filters_toplevel
|
426
|
+
Timecop.freeze do
|
427
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
428
|
+
Raygun.configuration.whitelist_payload_shape = {}
|
429
|
+
|
430
|
+
e = TestException.new("A test message")
|
431
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
432
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
433
|
+
|
434
|
+
client_details = @client.send(:client_details)
|
435
|
+
|
436
|
+
assert_equal Time.now.utc.iso8601, @client.send(:build_payload_hash, e)[:occurredOn]
|
437
|
+
assert_equal Hash, @client.send(:build_payload_hash, e)[:details].class
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
def test_filter_payload_with_whitelist_never_filters_client
|
442
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
443
|
+
Raygun.configuration.whitelist_payload_shape = {}
|
444
|
+
|
445
|
+
e = TestException.new("A test message")
|
446
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
447
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
448
|
+
|
449
|
+
client_details = @client.send(:client_details)
|
450
|
+
|
451
|
+
assert_equal client_details, @client.send(:build_payload_hash, e)[:details][:client]
|
452
|
+
end
|
424
453
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
"
|
439
|
-
"
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
454
|
+
def test_filter_payload_with_whitelist_default_error
|
455
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
456
|
+
|
457
|
+
e = TestException.new("A test message")
|
458
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
459
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
460
|
+
|
461
|
+
details = @client.send(:build_payload_hash, e)[:details]
|
462
|
+
|
463
|
+
expected_hash = {
|
464
|
+
className: "ClientTest::TestException",
|
465
|
+
message: e.message,
|
466
|
+
stackTrace: [
|
467
|
+
{ lineNumber: "123", fileName: "/some/folder/some_file.rb", methodName: "some_method_name" },
|
468
|
+
{ lineNumber: "1234", fileName: "/another/path/foo.rb", methodName: "block (3 levels) run" }
|
469
|
+
]
|
470
|
+
}
|
471
|
+
|
472
|
+
assert_equal expected_hash, details[:error]
|
473
|
+
end
|
474
|
+
|
475
|
+
def test_filter_payload_with_whitelist_exclude_error_keys
|
476
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
477
|
+
Raygun.configuration.whitelist_payload_shape = {
|
478
|
+
error: {
|
479
|
+
className: true,
|
480
|
+
message: true,
|
481
|
+
stackTrace: true
|
447
482
|
}
|
483
|
+
}
|
484
|
+
|
485
|
+
e = TestException.new("A test message")
|
486
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
487
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
488
|
+
|
489
|
+
details = @client.send(:build_payload_hash, e)[:details]
|
490
|
+
|
491
|
+
expected_hash = {
|
492
|
+
className: "ClientTest::TestException",
|
493
|
+
message: e.message,
|
494
|
+
stackTrace: [
|
495
|
+
{ lineNumber: "123", fileName: "/some/folder/some_file.rb", methodName: "some_method_name" },
|
496
|
+
{ lineNumber: "1234", fileName: "/another/path/foo.rb", methodName: "block (3 levels) run" }
|
497
|
+
]
|
498
|
+
}
|
499
|
+
|
500
|
+
assert_equal expected_hash, details[:error]
|
501
|
+
end
|
502
|
+
|
503
|
+
def test_filter_payload_with_whitelist_exclude_error_except_stacktrace
|
504
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
505
|
+
Raygun.configuration.whitelist_payload_shape = {
|
506
|
+
error: {
|
507
|
+
className: true,
|
508
|
+
message: true,
|
509
|
+
}
|
510
|
+
}
|
511
|
+
|
512
|
+
e = TestException.new("A test message")
|
513
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
514
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
515
|
+
|
516
|
+
details = @client.send(:build_payload_hash, e)[:details]
|
517
|
+
|
518
|
+
expected_hash = {
|
519
|
+
className: "ClientTest::TestException",
|
520
|
+
message: "A test message",
|
521
|
+
stackTrace: "[FILTERED]"
|
522
|
+
}
|
523
|
+
|
524
|
+
assert_equal expected_hash, details[:error]
|
525
|
+
end
|
526
|
+
|
527
|
+
def test_filter_payload_with_whitelist_proc
|
528
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
529
|
+
Raygun.configuration.whitelist_payload_shape do |payload|
|
530
|
+
payload
|
448
531
|
end
|
449
532
|
|
533
|
+
e = TestException.new("A test message")
|
534
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
535
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
536
|
+
|
537
|
+
details = @client.send(:build_payload_hash, e)[:details]
|
538
|
+
|
539
|
+
expected_hash = {
|
540
|
+
className: "ClientTest::TestException",
|
541
|
+
message: "A test message",
|
542
|
+
stackTrace: [
|
543
|
+
{ lineNumber: "123", fileName: "/some/folder/some_file.rb", methodName: "some_method_name" },
|
544
|
+
{ lineNumber: "1234", fileName: "/another/path/foo.rb", methodName: "block (3 levels) run" }
|
545
|
+
]
|
546
|
+
}
|
547
|
+
|
548
|
+
assert_equal expected_hash, details[:error]
|
549
|
+
end
|
550
|
+
|
551
|
+
def test_filter_payload_with_whitelist_default_request_post
|
552
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
553
|
+
|
554
|
+
e = TestException.new("A test message")
|
555
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
556
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
557
|
+
|
558
|
+
post_body_env_hash = sample_env_hash.merge(
|
559
|
+
"rack.input"=>StringIO.new("a=b&c=4945438&password=swordfish")
|
560
|
+
)
|
561
|
+
|
562
|
+
details = @client.send(:build_payload_hash, e, post_body_env_hash)[:details]
|
563
|
+
|
564
|
+
expected_hash = {
|
565
|
+
hostName: "localhost",
|
566
|
+
url: "/",
|
567
|
+
httpMethod: "POST",
|
568
|
+
iPAddress: "127.0.0.1",
|
569
|
+
queryString: { },
|
570
|
+
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Connection"=>"keep-alive", "Cache-Control"=>"max-age=0", "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "Cookie"=>"cookieval" },
|
571
|
+
form: { "a" => "[FILTERED]", "c" => "[FILTERED]", "password" => "[FILTERED]" },
|
572
|
+
rawData: nil
|
573
|
+
}
|
574
|
+
|
575
|
+
assert_equal expected_hash, details[:request]
|
576
|
+
end
|
577
|
+
|
578
|
+
def test_filter_payload_with_whitelist_request_post_except_formkey
|
579
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
580
|
+
shape = Raygun.configuration.whitelist_payload_shape.dup
|
581
|
+
shape[:request] = Raygun.configuration.whitelist_payload_shape[:request].merge(
|
582
|
+
form: {
|
583
|
+
username: true
|
584
|
+
}
|
585
|
+
)
|
586
|
+
Raygun.configuration.whitelist_payload_shape = shape
|
587
|
+
|
588
|
+
e = TestException.new("A test message")
|
589
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
590
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
591
|
+
|
592
|
+
post_body_env_hash = sample_env_hash.merge(
|
593
|
+
"rack.input"=>StringIO.new("username=foo&password=swordfish")
|
594
|
+
)
|
595
|
+
|
596
|
+
details = @client.send(:build_payload_hash, e, post_body_env_hash)[:details]
|
597
|
+
|
598
|
+
expected_hash = {
|
599
|
+
hostName: "localhost",
|
600
|
+
url: "/",
|
601
|
+
httpMethod: "POST",
|
602
|
+
iPAddress: "127.0.0.1",
|
603
|
+
queryString: { },
|
604
|
+
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Connection"=>"keep-alive", "Cache-Control"=>"max-age=0", "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "Cookie"=>"cookieval" },
|
605
|
+
form: { "username" => "foo", "password" => "[FILTERED]" },
|
606
|
+
rawData: nil
|
607
|
+
}
|
608
|
+
|
609
|
+
assert_equal expected_hash, details[:request]
|
610
|
+
end
|
611
|
+
|
612
|
+
def test_filter_payload_with_whitelist_default_request_get
|
613
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
614
|
+
|
615
|
+
e = TestException.new("A test message")
|
616
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
617
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
618
|
+
|
619
|
+
sample_env_hash = {
|
620
|
+
"SERVER_NAME"=>"localhost",
|
621
|
+
"REQUEST_METHOD"=>"GET",
|
622
|
+
"REQUEST_PATH"=>"/",
|
623
|
+
"PATH_INFO"=>"/",
|
624
|
+
"QUERY_STRING"=>"a=b&c=4945438",
|
625
|
+
"REQUEST_URI"=>"/?a=b&c=4945438",
|
626
|
+
"HTTP_VERSION"=>"HTTP/1.1",
|
627
|
+
"HTTP_HOST"=>"localhost:3000",
|
628
|
+
"HTTP_CONNECTION"=>"keep-alive",
|
629
|
+
"HTTP_CACHE_CONTROL"=>"max-age=0",
|
630
|
+
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
631
|
+
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36",
|
632
|
+
"HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch",
|
633
|
+
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8",
|
634
|
+
"HTTP_COOKIE"=>"cookieval",
|
635
|
+
"GATEWAY_INTERFACE"=>"CGI/1.2",
|
636
|
+
"SERVER_PORT"=>"3000",
|
637
|
+
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
638
|
+
"SCRIPT_NAME"=>"",
|
639
|
+
"REMOTE_ADDR"=>"127.0.0.1"
|
640
|
+
}
|
641
|
+
|
642
|
+
expected_hash = {
|
643
|
+
hostName: "localhost",
|
644
|
+
url: "/",
|
645
|
+
httpMethod: "GET",
|
646
|
+
iPAddress: "127.0.0.1",
|
647
|
+
queryString: { "a" => "b", "c" => "4945438" },
|
648
|
+
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Connection"=>"keep-alive", "Cache-Control"=>"max-age=0", "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "Cookie"=>"cookieval" },
|
649
|
+
form: {},
|
650
|
+
rawData: {}
|
651
|
+
}
|
652
|
+
|
653
|
+
details = @client.send(:build_payload_hash, e, sample_env_hash)[:details]
|
654
|
+
|
655
|
+
assert_equal expected_hash, details[:request]
|
656
|
+
end
|
657
|
+
|
658
|
+
def test_filter_payload_with_whitelist_default_request_get_except_querystring
|
659
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
660
|
+
shape = Raygun.configuration.whitelist_payload_shape.dup
|
661
|
+
shape[:request] = Raygun::Configuration::DEFAULT_WHITELIST_PAYLOAD_SHAPE_REQUEST.dup.tap do |h|
|
662
|
+
h.delete(:queryString)
|
663
|
+
end
|
664
|
+
Raygun.configuration.whitelist_payload_shape = shape
|
665
|
+
|
666
|
+
e = TestException.new("A test message")
|
667
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
668
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
669
|
+
|
670
|
+
sample_env_hash = {
|
671
|
+
"SERVER_NAME"=>"localhost",
|
672
|
+
"REQUEST_METHOD"=>"GET",
|
673
|
+
"REQUEST_PATH"=>"/",
|
674
|
+
"PATH_INFO"=>"/",
|
675
|
+
"QUERY_STRING"=>"a=b&c=4945438",
|
676
|
+
"REQUEST_URI"=>"/?a=b&c=4945438",
|
677
|
+
"HTTP_VERSION"=>"HTTP/1.1",
|
678
|
+
"HTTP_HOST"=>"localhost:3000",
|
679
|
+
"HTTP_CONNECTION"=>"keep-alive",
|
680
|
+
"HTTP_CACHE_CONTROL"=>"max-age=0",
|
681
|
+
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
682
|
+
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36",
|
683
|
+
"HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch",
|
684
|
+
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8",
|
685
|
+
"HTTP_COOKIE"=>"cookieval",
|
686
|
+
"GATEWAY_INTERFACE"=>"CGI/1.2",
|
687
|
+
"SERVER_PORT"=>"3000",
|
688
|
+
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
689
|
+
"SCRIPT_NAME"=>"",
|
690
|
+
"REMOTE_ADDR"=>"127.0.0.1"
|
691
|
+
}
|
692
|
+
|
693
|
+
expected_hash = {
|
694
|
+
hostName: "localhost",
|
695
|
+
url: "/",
|
696
|
+
httpMethod: "GET",
|
697
|
+
iPAddress: "127.0.0.1",
|
698
|
+
queryString: "[FILTERED]",
|
699
|
+
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Connection"=>"keep-alive", "Cache-Control"=>"max-age=0", "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "Cookie"=>"cookieval" },
|
700
|
+
form: {},
|
701
|
+
rawData: {}
|
702
|
+
}
|
703
|
+
|
704
|
+
details = @client.send(:build_payload_hash, e, sample_env_hash)[:details]
|
705
|
+
|
706
|
+
assert_equal expected_hash, details[:request]
|
707
|
+
end
|
708
|
+
|
709
|
+
def test_filter_payload_with_whitelist_being_false_does_not_filter_query_string
|
710
|
+
Raygun.configuration.filter_payload_with_whitelist = false
|
711
|
+
e = TestException.new("A test message")
|
712
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
713
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
714
|
+
|
715
|
+
sample_env_hash = {
|
716
|
+
"SERVER_NAME"=>"localhost",
|
717
|
+
"REQUEST_METHOD"=>"GET",
|
718
|
+
"REQUEST_PATH"=>"/",
|
719
|
+
"PATH_INFO"=>"/",
|
720
|
+
"QUERY_STRING"=>"a=b&c=4945438",
|
721
|
+
"REQUEST_URI"=>"/?a=b&c=4945438",
|
722
|
+
"HTTP_VERSION"=>"HTTP/1.1",
|
723
|
+
"HTTP_HOST"=>"localhost:3000",
|
724
|
+
"HTTP_CONNECTION"=>"keep-alive",
|
725
|
+
"HTTP_CACHE_CONTROL"=>"max-age=0",
|
726
|
+
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
727
|
+
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36",
|
728
|
+
"HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch",
|
729
|
+
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8",
|
730
|
+
"HTTP_COOKIE"=>"cookieval",
|
731
|
+
"GATEWAY_INTERFACE"=>"CGI/1.2",
|
732
|
+
"SERVER_PORT"=>"3000",
|
733
|
+
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
734
|
+
"SCRIPT_NAME"=>"",
|
735
|
+
"REMOTE_ADDR"=>"127.0.0.1"
|
736
|
+
}
|
737
|
+
|
738
|
+
expected_hash = {
|
739
|
+
hostName: "localhost",
|
740
|
+
url: "/",
|
741
|
+
httpMethod: "GET",
|
742
|
+
iPAddress: "127.0.0.1",
|
743
|
+
queryString: { "a" => "b", "c" => "4945438" },
|
744
|
+
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Connection"=>"keep-alive", "Cache-Control"=>"max-age=0", "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "Cookie"=>"cookieval" },
|
745
|
+
form: {},
|
746
|
+
rawData: {}
|
747
|
+
}
|
748
|
+
|
749
|
+
details = @client.send(:build_payload_hash, e, sample_env_hash)[:details]
|
750
|
+
|
751
|
+
assert_equal expected_hash, details[:request]
|
752
|
+
end
|
753
|
+
|
754
|
+
def test_filter_payload_with_whitelist_request_specific_keys
|
755
|
+
Raygun.configuration.filter_payload_with_whitelist = true
|
756
|
+
Raygun.configuration.whitelist_payload_shape = {
|
757
|
+
request: {
|
758
|
+
url: true,
|
759
|
+
httpMethod: true,
|
760
|
+
hostName: true
|
761
|
+
}
|
762
|
+
}
|
763
|
+
|
764
|
+
e = TestException.new("A test message")
|
765
|
+
e.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'",
|
766
|
+
"/another/path/foo.rb:1234:in `block (3 levels) run'"])
|
767
|
+
|
768
|
+
details = @client.send(:build_payload_hash, e, sample_env_hash)[:details]
|
769
|
+
|
770
|
+
expected_hash = {
|
771
|
+
hostName: "localhost",
|
772
|
+
url: "/",
|
773
|
+
httpMethod: "POST",
|
774
|
+
iPAddress: "[FILTERED]",
|
775
|
+
queryString: "[FILTERED]",
|
776
|
+
headers: "[FILTERED]",
|
777
|
+
form: "[FILTERED]",
|
778
|
+
rawData: "[FILTERED]"
|
779
|
+
}
|
780
|
+
|
781
|
+
assert_equal expected_hash, details[:request]
|
782
|
+
end
|
783
|
+
|
784
|
+
|
785
|
+
private
|
786
|
+
|
787
|
+
def sample_env_hash
|
788
|
+
{
|
789
|
+
"SERVER_NAME"=>"localhost",
|
790
|
+
"REQUEST_METHOD"=>"POST",
|
791
|
+
"REQUEST_PATH"=>"/",
|
792
|
+
"PATH_INFO"=>"/",
|
793
|
+
"QUERY_STRING"=>"",
|
794
|
+
"REQUEST_URI"=>"/",
|
795
|
+
"HTTP_VERSION"=>"HTTP/1.1",
|
796
|
+
"HTTP_HOST"=>"localhost:3000",
|
797
|
+
"HTTP_CONNECTION"=>"keep-alive",
|
798
|
+
"HTTP_CACHE_CONTROL"=>"max-age=0",
|
799
|
+
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
800
|
+
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36",
|
801
|
+
"HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch",
|
802
|
+
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8",
|
803
|
+
"HTTP_COOKIE"=>"cookieval",
|
804
|
+
"GATEWAY_INTERFACE"=>"CGI/1.2",
|
805
|
+
"SERVER_PORT"=>"3000",
|
806
|
+
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
807
|
+
"SCRIPT_NAME"=>"",
|
808
|
+
"REMOTE_ADDR"=>"127.0.0.1"
|
809
|
+
}
|
810
|
+
end
|
811
|
+
|
450
812
|
end
|
@@ -76,4 +76,20 @@ class ConfigurationTest < Raygun::UnitTest
|
|
76
76
|
Raygun.configuration.filter_parameters = nil
|
77
77
|
end
|
78
78
|
|
79
|
+
def test_filter_payload_with_whitelist_default
|
80
|
+
assert_equal(false, Raygun.configuration.filter_payload_with_whitelist)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_setting_whitelist_payload_keys_to_proc
|
84
|
+
Raygun.setup do |config|
|
85
|
+
config.whitelist_payload_shape do |hash|
|
86
|
+
# No-op
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
assert Raygun.configuration.whitelist_payload_shape.is_a?(Proc)
|
91
|
+
ensure
|
92
|
+
Raygun.configuration.whitelist_payload_shape = nil
|
93
|
+
end
|
94
|
+
|
79
95
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require_relative "../test_helper.rb"
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class RaygunTest < Raygun::UnitTest
|
6
|
+
|
7
|
+
def test_raygun_is_not_configured_with_no_api_key
|
8
|
+
Raygun.configuration.api_key = nil
|
9
|
+
assert !Raygun.configured?
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindscape
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -185,6 +185,20 @@ dependencies:
|
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
|
+
- !ruby/object:Gem::Dependency
|
189
|
+
name: pry
|
190
|
+
requirement: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
type: :development
|
196
|
+
prerelease: false
|
197
|
+
version_requirements: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
188
202
|
description: Ruby Adapter for Raygun.io
|
189
203
|
email:
|
190
204
|
- hello@raygun.io
|
@@ -194,6 +208,7 @@ extra_rdoc_files: []
|
|
194
208
|
files:
|
195
209
|
- ".gitignore"
|
196
210
|
- ".travis.yml"
|
211
|
+
- CHANGELOG.md
|
197
212
|
- Gemfile
|
198
213
|
- LICENSE.txt
|
199
214
|
- README.md
|
@@ -206,6 +221,7 @@ files:
|
|
206
221
|
- lib/raygun/middleware/rack_exception_interceptor.rb
|
207
222
|
- lib/raygun/middleware/rails_insert_affected_user.rb
|
208
223
|
- lib/raygun/railtie.rb
|
224
|
+
- lib/raygun/services/apply_whitelist_filter_to_payload.rb
|
209
225
|
- lib/raygun/sidekiq.rb
|
210
226
|
- lib/raygun/testable.rb
|
211
227
|
- lib/raygun/version.rb
|
@@ -213,11 +229,13 @@ files:
|
|
213
229
|
- lib/resque/failure/raygun.rb
|
214
230
|
- lib/tasks/raygun.tasks
|
215
231
|
- raygun4ruby.gemspec
|
232
|
+
- specs/services/apply_whitelist_filter_to_payload_spec.rb
|
216
233
|
- test/integration/client_test.rb
|
217
234
|
- test/test_helper.rb
|
218
235
|
- test/unit/client_test.rb
|
219
236
|
- test/unit/configuration_test.rb
|
220
237
|
- test/unit/rails_insert_affected_user_test.rb
|
238
|
+
- test/unit/raygun_test.rb
|
221
239
|
- test/unit/resque_failure_test.rb
|
222
240
|
- test/unit/sidekiq_failure_test.rb
|
223
241
|
homepage: http://raygun.io
|
@@ -240,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
258
|
version: '0'
|
241
259
|
requirements: []
|
242
260
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.
|
261
|
+
rubygems_version: 2.5.1
|
244
262
|
signing_key:
|
245
263
|
specification_version: 4
|
246
264
|
summary: This gem provides support for Ruby and Ruby on Rails for the Raygun.io error
|
@@ -251,5 +269,6 @@ test_files:
|
|
251
269
|
- test/unit/client_test.rb
|
252
270
|
- test/unit/configuration_test.rb
|
253
271
|
- test/unit/rails_insert_affected_user_test.rb
|
272
|
+
- test/unit/raygun_test.rb
|
254
273
|
- test/unit/resque_failure_test.rb
|
255
274
|
- test/unit/sidekiq_failure_test.rb
|