raygun4ruby 1.5.0 → 2.0.0

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
  SHA1:
3
- metadata.gz: 87bcff1d09782d4e215f3c5bcaec19c5ab14d43e
4
- data.tar.gz: 4d033882abae5990a864817801f3c928981bb60a
3
+ metadata.gz: 558ace0abc94bf42933ffec0ae4327a8cfba09a2
4
+ data.tar.gz: a27eb894bc5e0079d7b10b40463c5e47c82b21ad
5
5
  SHA512:
6
- metadata.gz: 683c9f6446683722f334a370ec6e4c463fcdc43699deb9146c1bb44bfa8f9017324271036396c77639e9129e21a749655ddfbb0a9c750f0bcfa8fed7bf3c59ef
7
- data.tar.gz: 47c6be6d9106a7eff502f64f15cc72ea751534ad239e392224388f186d8fea8e1b0c2c7b7480f5f8d585db960a711f1afc6242b3b3687577040437a36e81b5c7
6
+ metadata.gz: c390cf858fa96eef0e2a42174c0098cefda944dc9d4e1ea85ce2c06b4e9e0795170fa409ff726ac2d5431aa2a928803a61c5d963a71e472bd0ebfa793f31f62f
7
+ data.tar.gz: 6d334a8df11475639df6ad6eebdedc7d7301d61915392179b711ee45030ec2ec8f9e0fc411794e5ea53ce5bac90447af489925298e325a83760aea6bcf1dd21c
data/CHANGELOG.md CHANGED
@@ -1,34 +1,40 @@
1
+ ## 2.0.0 (20/04/2017)
2
+
3
+ Bugfixes:
4
+ - Fix broken handling of raw request body reading in Rack applications ([#116](https://github.com/MindscapeHQ/raygun4ruby/pull/116))
5
+ - This is a breaking change to how raw data was being read before so it requires a major version bump
6
+ - Raw request data reading is now disabled by default and can be enabled via the `record_raw_data` configuration option
1
7
  ## 1.5.0 (16/03/2017)
2
8
 
3
9
  Features
4
- - Send utcOffset with Raygun payload to calculate local server time in Raygun dashboard
10
+ - Send utcOffset with Raygun payload to calculate local server time in Raygun dashboard ([#112](https://github.com/MindscapeHQ/raygun4ruby/pull/112))
5
11
 
6
12
  ## 1.4.0 (14/03/2017)
7
13
 
8
14
  Features:
9
- - Raygun API url is now configurable via `Configuration.api_url`
10
- - Added support for `Exception#cause` to be tracked as `innerError` on Raygun. Only supported on Ruby >= 2.1
15
+ - Raygun API url is now configurable via `Configuration.api_url` ([#111](https://github.com/MindscapeHQ/raygun4ruby/pull/111))
16
+ - Added support for `Exception#cause` to be tracked as `innerError` on Raygun. Only supported on Ruby >= 2.1 ([#107](https://github.com/MindscapeHQ/raygun4ruby/pull/107))
11
17
 
12
18
  ## 1.3.0 (10/03/2017)
13
19
 
14
20
  Features:
15
- - Improve affected user handling to let you specify all Raygun parameters, identifier, email, first name, full name and uuid. See [README.md](https://github.com/MindscapeHQ/raygun4ruby#affected-user-tracking) for details
16
- - Pass a user object as the third parameter to `Raygun.track_exception` to have affected user tracking for manually tracked exceptions, see the above link for more information on configuring this
17
- - If the exception instance responds to `:raygun_custom_data` that method will be called and the return value merged into the `custom_data` hash sent to Raygun. For convenience a `Raygun::Error` class is provided that takes this custom data as a second argument
18
- - Allowed `Configuration.custom_data` to be set to a proc to allow a global custom data hook for all exceptions. It is passed as arguments the exception and the environment hash
19
- - Added `Configuration.debug` to enable logging the reason why an exception was not reported
21
+ - Improve affected user handling to let you specify all Raygun parameters, identifier, email, first name, full name and uuid. See [README.md](https://github.com/MindscapeHQ/raygun4ruby#affected-user-tracking) for details ([#34](https://github.com/MindscapeHQ/raygun4ruby/pull/34))
22
+ - Pass a user object as the third parameter to `Raygun.track_exception` to have affected user tracking for manually tracked exceptions, see the above link for more information on configuring this ([#106](https://github.com/MindscapeHQ/raygun4ruby/pull/106))
23
+ - If the exception instance responds to `:raygun_custom_data` that method will be called and the return value merged into the `custom_data` hash sent to Raygun. For convenience a `Raygun::Error` class is provided that takes this custom data as a second argument ([#101](https://github.com/MindscapeHQ/raygun4ruby/pull/101))
24
+ - Allowed `Configuration.custom_data` to be set to a proc to allow a global custom data hook for all exceptions. It is passed as arguments the exception and the environment hash ([#108](https://github.com/MindscapeHQ/raygun4ruby/pull/108))
25
+ - Added `Configuration.debug` to enable logging the reason why an exception was not reported ([#109](https://github.com/MindscapeHQ/raygun4ruby/pull/109))
20
26
 
21
27
  ## 1.2.1 (09/03/2017)
22
28
 
23
29
  Bugfixes:
24
- - dup input hashes before applying whitelist filtering, previously this was modifying the contents of `action_dispatch.request.parameters`
30
+ - dup input hashes before applying whitelist filtering, previously this was modifying the contents of `action_dispatch.request.parameters` ([#105](https://github.com/MindscapeHQ/raygun4ruby/pull/105))
25
31
 
26
32
  ## 1.2.0 (09/03/2017)
27
33
 
28
34
  Features:
29
- - Added two new configuration options, `filter_payload_with_whitelist` and `whitelist_payload_shape`
35
+ - Added two new configuration options, `filter_payload_with_whitelist` and `whitelist_payload_shape` ([#100](https://github.com/MindscapeHQ/raygun4ruby/pull/100))
30
36
  - See [README.md](https://github.com/MindscapeHQ/raygun4ruby#filtering-the-payload-by-whitelist) for an example of how to use them
31
- - When raygun4ruby encounters an exception trying to track an exception it will try once to send that exception to Raygun so you are notified
37
+ - When raygun4ruby encounters an exception trying to track an exception it will try once to send that exception to Raygun so you are notified ([#104](https://github.com/MindscapeHQ/raygun4ruby/pull/104))
32
38
 
33
39
  Bugfixes:
34
- - raygun4ruby will no longer crash and suppress app exceptions when the API key is not configured
40
+ - raygun4ruby will no longer crash and suppress app exceptions when the API key is not configured ([#87](https://github.com/MindscapeHQ/raygun4ruby/pull/87))
data/lib/raygun/client.rb CHANGED
@@ -132,9 +132,21 @@ module Raygun
132
132
  end
133
133
 
134
134
  def raw_data(rack_env)
135
+ return unless Raygun.configuration.record_raw_data
136
+
135
137
  request = Rack::Request.new(rack_env)
136
- unless request.form_data?
137
- form_params(rack_env)
138
+ input = rack_env['rack.input']
139
+
140
+ if input && !request.form_data?
141
+ current_position = input.pos
142
+ input.rewind
143
+
144
+ body = (input.read || '').slice(0, 4096)
145
+ input.seek(current_position)
146
+
147
+ body
148
+ else
149
+ {}
138
150
  end
139
151
  end
140
152
 
@@ -70,6 +70,10 @@ module Raygun
70
70
  # Override this if you wish to connect to a different Raygun API than the standard one
71
71
  config_option :api_url
72
72
 
73
+ # Should Raygun include the raw request body in the payload? This will not include
74
+ # form submissions and will not be filtered by the blacklist
75
+ config_option :record_raw_data
76
+
73
77
  # Exception classes to ignore by default
74
78
  IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
75
79
  'ActionController::RoutingError',
@@ -119,7 +123,8 @@ module Raygun
119
123
  whitelist_payload_shape: DEFAULT_WHITELIST_PAYLOAD_SHAPE,
120
124
  proxy_settings: {},
121
125
  debug: false,
122
- api_url: 'https://api.raygun.io/'
126
+ api_url: 'https://api.raygun.io/',
127
+ record_raw_data: false
123
128
  })
124
129
  end
125
130
 
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "1.5.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -29,6 +29,7 @@ class ClientTest < Raygun::UnitTest
29
29
  def setup
30
30
  super
31
31
  @client = Raygun::Client.new
32
+ Raygun.configuration.record_raw_data = true
32
33
  fake_successful_entry
33
34
 
34
35
  # Force NZ time zone for utcOffset tests
@@ -222,15 +223,36 @@ class ClientTest < Raygun::UnitTest
222
223
  assert_equal({}, @client.send(:request_information, nil))
223
224
  end
224
225
 
225
- def test_non_form_parameters
226
- put_body_env_hash = sample_env_hash.merge({
227
- "REQUEST_METHOD"=>"PUT",
228
- "action_dispatch.request.parameters"=> { "a" => "b", "c" => "4945438", "password" => "swordfish" }
226
+ def test_raw_post_body
227
+ env_hash = sample_env_hash.merge({
228
+ "CONTENT_TYPE" => "application/json",
229
+ "REQUEST_METHOD" => "POST",
230
+ "rack.input" => StringIO.new('{"foo": "bar"}')
229
231
  })
230
232
 
231
- expected_form_hash = { "a" => "b", "c" => "4945438", "password" => "[FILTERED]" }
233
+ assert_equal '{"foo": "bar"}', @client.send(:request_information, env_hash)[:rawData]
234
+ end
235
+
236
+ def test_raw_post_body_with_more_than_4096_chars
237
+ input = "0" * 5000;
238
+ env_hash = sample_env_hash.merge({
239
+ "CONTENT_TYPE" => "application/json",
240
+ "REQUEST_METHOD" => "POST",
241
+ "rack.input" => StringIO.new(input)
242
+ })
232
243
 
233
- assert_equal expected_form_hash, @client.send(:request_information, put_body_env_hash)[:rawData]
244
+ assert_equal input.slice(0, 4096), @client.send(:request_information, env_hash)[:rawData]
245
+ end
246
+
247
+ def test_raw_post_body_with_config_disabled
248
+ Raygun.configuration.record_raw_data = false
249
+ env_hash = sample_env_hash.merge({
250
+ "CONTENT_TYPE" => "application/json",
251
+ "REQUEST_METHOD" => "POST",
252
+ "rack.input" => StringIO.new('{"foo": "bar"}')
253
+ })
254
+
255
+ assert_equal(nil, @client.send(:request_information, env_hash)[:rawData])
234
256
  end
235
257
 
236
258
  def test_error_raygun_custom_data
@@ -461,6 +483,7 @@ class ClientTest < Raygun::UnitTest
461
483
  Raygun.configuration.filter_payload_with_whitelist = true
462
484
 
463
485
  post_body_env_hash = sample_env_hash.merge(
486
+ "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
464
487
  "REQUEST_METHOD" => "POST",
465
488
  "rack.input"=>StringIO.new("a=b&c=4945438&password=swordfish")
466
489
  )
@@ -475,7 +498,7 @@ class ClientTest < Raygun::UnitTest
475
498
  queryString: { },
476
499
  headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Cookie"=>"cookieval" },
477
500
  form: { "a" => "[FILTERED]", "c" => "[FILTERED]", "password" => "[FILTERED]" },
478
- rawData: nil
501
+ rawData: {}
479
502
  }
480
503
 
481
504
  assert_equal expected_hash, details[:request]
@@ -506,7 +529,7 @@ class ClientTest < Raygun::UnitTest
506
529
  queryString: { },
507
530
  headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Cookie"=>"cookieval" },
508
531
  form: { "username" => "foo", "password" => "[FILTERED]" },
509
- rawData: nil
532
+ rawData: {}
510
533
  }
511
534
 
512
535
  assert_equal expected_hash, details[:request]
@@ -129,4 +129,8 @@ class ConfigurationTest < Raygun::UnitTest
129
129
  def test_api_url_default
130
130
  assert_equal "https://api.raygun.io/", Raygun.configuration.api_url
131
131
  end
132
+
133
+ def test_record_raw_data_default
134
+ assert_equal false, Raygun.configuration.record_raw_data
135
+ end
132
136
  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.5.0
4
+ version: 2.0.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-03-15 00:00:00.000000000 Z
12
+ date: 2017-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty