raygun4ruby 3.2.5.pre → 4.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +48 -0
- data/.gitignore +22 -21
- data/.rspec +1 -1
- data/Appraisals +19 -0
- data/CHANGELOG.md +169 -130
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +424 -420
- data/Rakefile +32 -27
- data/examples/sinatras_raygun.rb +17 -17
- data/gemfiles/rails_6.gemfile +9 -0
- data/gemfiles/rails_7.gemfile +10 -0
- data/gemfiles/rails_7_sidekiq_6.gemfile +10 -0
- data/lib/generators/raygun/install_generator.rb +26 -26
- data/lib/raygun/affected_user.rb +59 -59
- data/lib/raygun/breadcrumbs/breadcrumb.rb +34 -34
- data/lib/raygun/breadcrumbs/store.rb +86 -86
- data/lib/raygun/breadcrumbs.rb +34 -34
- data/lib/raygun/client.rb +313 -308
- data/lib/raygun/configuration.rb +197 -194
- data/lib/raygun/demo_exception.rb +23 -0
- data/lib/raygun/error.rb +10 -10
- data/lib/raygun/error_subscriber.rb +21 -0
- data/lib/raygun/javascript_tracker.rb +42 -42
- data/lib/raygun/middleware/breadcrumbs_store_initializer.rb +19 -19
- data/lib/raygun/middleware/javascript_exception_tracking.rb +40 -32
- data/lib/raygun/middleware/rack_exception_interceptor.rb +18 -18
- data/lib/raygun/middleware/rails_insert_affected_user.rb +26 -26
- data/lib/raygun/railtie.rb +47 -39
- data/lib/raygun/services/apply_whitelist_filter_to_payload.rb +27 -27
- data/lib/raygun/sidekiq.rb +51 -71
- data/lib/raygun/version.rb +3 -3
- data/lib/raygun.rb +197 -179
- data/lib/raygun4ruby.rb +1 -1
- data/lib/resque/failure/raygun.rb +25 -25
- data/lib/tasks/raygun.tasks +7 -7
- data/raygun4ruby.gemspec +43 -45
- data/spec/features/javascript_spec.rb +48 -48
- data/spec/rails_applications/6.1.4/Gemfile +56 -0
- data/spec/{dummy/README.rdoc → rails_applications/6.1.4/README.md} +24 -28
- data/spec/{dummy → rails_applications/6.1.4}/Rakefile +6 -6
- data/spec/rails_applications/6.1.4/app/assets/config/manifest.js +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/assets/stylesheets/application.css +15 -15
- data/spec/rails_applications/6.1.4/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/6.1.4/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/6.1.4/app/controllers/application_controller.rb +2 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/controllers/home_controller.rb +4 -4
- data/spec/{dummy → rails_applications/6.1.4}/app/helpers/application_helper.rb +2 -2
- data/spec/rails_applications/6.1.4/app/javascript/channels/consumer.js +6 -0
- data/spec/rails_applications/6.1.4/app/javascript/channels/index.js +5 -0
- data/spec/rails_applications/6.1.4/app/javascript/packs/application.js +13 -0
- data/spec/rails_applications/6.1.4/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/6.1.4/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/6.1.4/app/models/application_record.rb +3 -0
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.html.erb +3 -3
- data/spec/{dummy → rails_applications/6.1.4}/app/views/home/index.json.erb +1 -1
- data/spec/rails_applications/6.1.4/app/views/layouts/application.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/6.1.4/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/6.1.4/bin/rails +5 -0
- data/spec/rails_applications/6.1.4/bin/rake +5 -0
- data/spec/rails_applications/6.1.4/bin/setup +36 -0
- data/spec/rails_applications/6.1.4/bin/spring +14 -0
- data/spec/rails_applications/6.1.4/bin/yarn +17 -0
- data/spec/rails_applications/6.1.4/config/application.rb +22 -0
- data/spec/rails_applications/6.1.4/config/boot.rb +3 -0
- data/spec/rails_applications/6.1.4/config/cable.yml +10 -0
- data/spec/rails_applications/6.1.4/config/credentials.yml.enc +1 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/database.yml +25 -25
- data/spec/{dummy → rails_applications/6.1.4}/config/environment.rb +5 -5
- data/spec/rails_applications/6.1.4/config/environments/development.rb +76 -0
- data/spec/rails_applications/6.1.4/config/environments/production.rb +120 -0
- data/spec/rails_applications/6.1.4/config/environments/test.rb +60 -0
- data/spec/rails_applications/6.1.4/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/assets.rb +14 -0
- data/spec/rails_applications/6.1.4/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/rails_applications/6.1.4/config/initializers/content_security_policy.rb +30 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/cookies_serializer.rb +5 -3
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/filter_parameter_logging.rb +6 -4
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/inflections.rb +16 -16
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/mime_types.rb +4 -4
- data/spec/rails_applications/6.1.4/config/initializers/permissions_policy.rb +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/config/initializers/wrap_parameters.rb +14 -14
- data/spec/{dummy → rails_applications/6.1.4}/config/locales/en.yml +33 -23
- data/spec/rails_applications/6.1.4/config/master.key +1 -0
- data/spec/rails_applications/6.1.4/config/puma.rb +43 -0
- data/spec/rails_applications/6.1.4/config/routes.rb +4 -0
- data/spec/rails_applications/6.1.4/config/spring.rb +6 -0
- data/spec/rails_applications/6.1.4/config/storage.yml +34 -0
- data/spec/{dummy → rails_applications/6.1.4}/config.ru +6 -4
- data/spec/rails_applications/6.1.4/db/seeds.rb +7 -0
- data/spec/rails_applications/6.1.4/package.json +11 -0
- data/spec/{dummy → rails_applications/6.1.4}/public/404.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/422.html +67 -67
- data/spec/{dummy → rails_applications/6.1.4}/public/500.html +66 -66
- data/spec/rails_applications/6.1.4/public/robots.txt +1 -0
- data/spec/rails_applications/7.1.3/.dockerignore +37 -0
- data/spec/rails_applications/7.1.3/.gitattributes +9 -0
- data/spec/rails_applications/7.1.3/.gitignore +35 -0
- data/spec/rails_applications/7.1.3/.ruby-version +1 -0
- data/spec/rails_applications/7.1.3/Dockerfile +62 -0
- data/spec/rails_applications/7.1.3/Gemfile +67 -0
- data/spec/rails_applications/7.1.3/README.md +24 -0
- data/spec/rails_applications/7.1.3/Rakefile +6 -0
- data/spec/rails_applications/7.1.3/app/assets/config/manifest.js +4 -0
- data/spec/rails_applications/7.1.3/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/channel.rb +4 -0
- data/spec/rails_applications/7.1.3/app/channels/application_cable/connection.rb +4 -0
- data/spec/rails_applications/7.1.3/app/controllers/application_controller.rb +2 -0
- data/spec/rails_applications/7.1.3/app/controllers/concerns/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/controllers/home_controller.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/application_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/helpers/home_helper.rb +2 -0
- data/spec/rails_applications/7.1.3/app/javascript/application.js +3 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/application.js +9 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/hello_controller.js +7 -0
- data/spec/rails_applications/7.1.3/app/javascript/controllers/index.js +11 -0
- data/spec/rails_applications/7.1.3/app/jobs/application_job.rb +7 -0
- data/spec/rails_applications/7.1.3/app/mailers/application_mailer.rb +4 -0
- data/spec/rails_applications/7.1.3/app/models/application_record.rb +3 -0
- data/spec/rails_applications/7.1.3/app/models/concerns/.keep +0 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.html.erb +3 -0
- data/spec/rails_applications/7.1.3/app/views/home/index.json.erb +1 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/application.html.erb +16 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.html.erb +13 -0
- data/spec/rails_applications/7.1.3/app/views/layouts/mailer.text.erb +1 -0
- data/spec/rails_applications/7.1.3/bin/bundle +109 -0
- data/spec/rails_applications/7.1.3/bin/docker-entrypoint +8 -0
- data/spec/rails_applications/7.1.3/bin/importmap +4 -0
- data/spec/rails_applications/7.1.3/bin/rails +4 -0
- data/spec/rails_applications/7.1.3/bin/rake +4 -0
- data/spec/rails_applications/7.1.3/bin/setup +33 -0
- data/spec/rails_applications/7.1.3/config/application.rb +27 -0
- data/spec/rails_applications/7.1.3/config/boot.rb +4 -0
- data/spec/rails_applications/7.1.3/config/cable.yml +11 -0
- data/spec/rails_applications/7.1.3/config/credentials.yml.enc +1 -0
- data/spec/rails_applications/7.1.3/config/database.yml +25 -0
- data/spec/rails_applications/7.1.3/config/environment.rb +5 -0
- data/spec/rails_applications/7.1.3/config/environments/development.rb +76 -0
- data/spec/rails_applications/7.1.3/config/environments/production.rb +97 -0
- data/spec/rails_applications/7.1.3/config/environments/test.rb +64 -0
- data/spec/rails_applications/7.1.3/config/importmap.rb +7 -0
- data/spec/rails_applications/7.1.3/config/initializers/assets.rb +12 -0
- data/spec/rails_applications/7.1.3/config/initializers/content_security_policy.rb +25 -0
- data/spec/rails_applications/7.1.3/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/rails_applications/7.1.3/config/initializers/inflections.rb +16 -0
- data/spec/rails_applications/7.1.3/config/initializers/permissions_policy.rb +13 -0
- data/spec/rails_applications/7.1.3/config/locales/en.yml +31 -0
- data/spec/rails_applications/7.1.3/config/puma.rb +35 -0
- data/spec/rails_applications/7.1.3/config/routes.rb +11 -0
- data/spec/rails_applications/7.1.3/config/storage.yml +34 -0
- data/spec/rails_applications/7.1.3/config.ru +6 -0
- data/spec/rails_applications/7.1.3/db/seeds.rb +9 -0
- data/spec/rails_applications/7.1.3/lib/assets/.keep +0 -0
- data/spec/rails_applications/7.1.3/lib/tasks/.keep +0 -0
- data/spec/rails_applications/7.1.3/public/404.html +67 -0
- data/spec/rails_applications/7.1.3/public/422.html +67 -0
- data/spec/rails_applications/7.1.3/public/500.html +66 -0
- data/spec/rails_applications/7.1.3/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/rails_applications/7.1.3/public/apple-touch-icon.png +0 -0
- data/spec/rails_applications/7.1.3/public/favicon.ico +0 -0
- data/spec/rails_applications/7.1.3/public/robots.txt +1 -0
- data/spec/rails_applications/7.1.3/storage/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/application_system_test_case.rb +5 -0
- data/spec/rails_applications/7.1.3/test/channels/application_cable/connection_test.rb +13 -0
- data/spec/rails_applications/7.1.3/test/controllers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/controllers/home_controller_test.rb +7 -0
- data/spec/rails_applications/7.1.3/test/fixtures/files/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/helpers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/integration/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/mailers/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/models/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/system/.keep +0 -0
- data/spec/rails_applications/7.1.3/test/test_helper.rb +15 -0
- data/spec/rails_applications/7.1.3/vendor/.keep +0 -0
- data/spec/rails_applications/7.1.3/vendor/javascript/.keep +0 -0
- data/spec/rails_helper.rb +8 -4
- data/spec/raygun/breadcrumbs/breadcrumb_spec.rb +171 -171
- data/spec/raygun/breadcrumbs/store_spec.rb +170 -170
- data/spec/services/apply_whitelist_filter_to_payload_spec.rb +251 -251
- data/spec/spec_helper.rb +24 -24
- data/spec/support/fake_logger.rb +17 -17
- data/test/integration/client_test.rb +19 -19
- data/test/rails_helper.rb +6 -0
- data/test/test_helper.rb +76 -72
- data/test/unit/affected_user_test.rb +136 -136
- data/test/unit/client_test.rb +812 -812
- data/test/unit/configuration_test.rb +202 -206
- data/test/unit/error_subscriber_test.rb +43 -0
- data/test/unit/raygun_test.rb +106 -25
- data/test/unit/resque_failure_test.rb +27 -24
- data/test/unit/sidekiq_failure_test.rb +42 -32
- metadata +186 -115
- data/.travis.yml +0 -20
- data/spec/dummy/.gitignore +0 -17
- data/spec/dummy/Gemfile +0 -47
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -9
- data/spec/dummy/bin/rake +0 -9
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/bin/spring +0 -17
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -3
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
- data/spec/dummy/config/routes.rb +0 -58
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/public/robots.txt +0 -5
- data/spec/raygun/raygun_spec.rb +0 -47
- /data/spec/{dummy → rails_applications/6.1.4}/app/assets/images/.keep +0 -0
- /data/spec/{dummy → rails_applications/6.1.4}/app/controllers/concerns/.keep +0 -0
- /data/spec/{dummy/app/mailers → rails_applications/6.1.4/app/models/concerns}/.keep +0 -0
- /data/spec/{dummy/app/models/.keep → rails_applications/6.1.4/db/test.sqlite3} +0 -0
- /data/spec/{dummy/app/models/concerns → rails_applications/6.1.4/lib/assets}/.keep +0 -0
- /data/spec/{dummy/lib/assets → rails_applications/6.1.4/lib/tasks}/.keep +0 -0
- /data/spec/{dummy/lib/tasks/.keep → rails_applications/6.1.4/public/apple-touch-icon-precomposed.png} +0 -0
- /data/spec/{dummy/log/.keep → rails_applications/6.1.4/public/apple-touch-icon.png} +0 -0
- /data/spec/{dummy → rails_applications/6.1.4}/public/favicon.ico +0 -0
- /data/spec/{dummy/vendor/assets/javascripts → rails_applications/6.1.4/storage}/.keep +0 -0
- /data/spec/{dummy/vendor/assets/stylesheets → rails_applications/7.1.3/app/assets/images}/.keep +0 -0
@@ -1,251 +1,251 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module Raygun
|
4
|
-
module Services
|
5
|
-
describe ApplyWhitelistFilterToPayload do
|
6
|
-
let(:service) { ApplyWhitelistFilterToPayload.new }
|
7
|
-
|
8
|
-
describe "top level keys" do
|
9
|
-
let(:payload) do
|
10
|
-
{ foo: 1, bar: 2 }
|
11
|
-
end
|
12
|
-
let(:expected) do
|
13
|
-
{ foo: 1 , bar: '[FILTERED]'}
|
14
|
-
end
|
15
|
-
|
16
|
-
it "filters out keys that are not present in the shape" do
|
17
|
-
shape = {
|
18
|
-
foo: true
|
19
|
-
}
|
20
|
-
|
21
|
-
new_payload = service.call(shape, payload)
|
22
|
-
|
23
|
-
expect(new_payload).to eq(expected)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "filters out keys that are set to false" do
|
27
|
-
shape = {
|
28
|
-
foo: true,
|
29
|
-
bar: false
|
30
|
-
}
|
31
|
-
|
32
|
-
new_payload = service.call(shape, payload)
|
33
|
-
|
34
|
-
expect(new_payload).to eq(expected)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "nested hashes" do
|
39
|
-
let(:payload) {{
|
40
|
-
foo: 1,
|
41
|
-
bar: {
|
42
|
-
baz: 2,
|
43
|
-
qux: 3
|
44
|
-
}
|
45
|
-
}}
|
46
|
-
let(:expected) {{
|
47
|
-
foo: 1,
|
48
|
-
bar: {
|
49
|
-
baz: 2,
|
50
|
-
qux: '[FILTERED]'
|
51
|
-
}
|
52
|
-
}}
|
53
|
-
|
54
|
-
it "filters out keys in nested hashes" do
|
55
|
-
shape = {
|
56
|
-
foo: true,
|
57
|
-
bar: {
|
58
|
-
baz: true
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
new_payload = service.call(shape, payload)
|
63
|
-
|
64
|
-
expect(new_payload).to eq(expected)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "filters out a nested hash if the whitelist does not contain it" do
|
68
|
-
shape = {
|
69
|
-
foo: true
|
70
|
-
}
|
71
|
-
expected[:bar] = "[FILTERED]"
|
72
|
-
|
73
|
-
new_payload = service.call(shape, payload)
|
74
|
-
|
75
|
-
expect(new_payload).to eq(expected)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "handles nested hashes when the whitelist is set to allow the whole hash" do
|
79
|
-
shape = {
|
80
|
-
bar: true
|
81
|
-
}
|
82
|
-
expected = {
|
83
|
-
foo: '[FILTERED]',
|
84
|
-
bar: {
|
85
|
-
baz: 2,
|
86
|
-
qux: 3
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
new_payload = service.call(shape, payload)
|
91
|
-
|
92
|
-
expect(new_payload).to eq(expected)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "handles nested hashes when the whitelist is set to not allow the whole hash" do
|
96
|
-
shape = {
|
97
|
-
foo: true,
|
98
|
-
bar: false
|
99
|
-
}
|
100
|
-
expected = {
|
101
|
-
foo: 1,
|
102
|
-
bar: '[FILTERED]'
|
103
|
-
}
|
104
|
-
|
105
|
-
new_payload = service.call(shape, payload)
|
106
|
-
|
107
|
-
expect(new_payload).to eq(expected)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "string keys" do
|
112
|
-
it "handles the case where a payload key is a string and a whitelist key is a symbol" do
|
113
|
-
shape = {
|
114
|
-
foo: true
|
115
|
-
}
|
116
|
-
payload = {
|
117
|
-
"foo" => 1,
|
118
|
-
"bar" => 2
|
119
|
-
}
|
120
|
-
expected = {
|
121
|
-
"foo" => 1,
|
122
|
-
"bar" => '[FILTERED]'
|
123
|
-
}
|
124
|
-
|
125
|
-
new_payload = service.call(shape, payload)
|
126
|
-
|
127
|
-
expect(new_payload).to eq(expected)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
it "handles a very complex shape" do
|
132
|
-
shape = {
|
133
|
-
machineName: true,
|
134
|
-
version: true,
|
135
|
-
client: true,
|
136
|
-
error: {
|
137
|
-
className: true,
|
138
|
-
message: true,
|
139
|
-
stackTrace: true
|
140
|
-
},
|
141
|
-
userCustomData: true,
|
142
|
-
tags: true,
|
143
|
-
request: {
|
144
|
-
hostName: true,
|
145
|
-
url: true,
|
146
|
-
httpMethod: true,
|
147
|
-
iPAddress: true,
|
148
|
-
queryString: {
|
149
|
-
param1: true,
|
150
|
-
param2: true,
|
151
|
-
},
|
152
|
-
headers: {
|
153
|
-
"Host" => true,
|
154
|
-
"Connection" => true,
|
155
|
-
"Upgrade-Insecure_requests" => true,
|
156
|
-
"User-Agent" => false,
|
157
|
-
"Accept" => true,
|
158
|
-
},
|
159
|
-
form: {
|
160
|
-
controller: true,
|
161
|
-
action: false
|
162
|
-
},
|
163
|
-
rawData: {
|
164
|
-
controller: true,
|
165
|
-
action: false
|
166
|
-
}
|
167
|
-
},
|
168
|
-
user: false,
|
169
|
-
}
|
170
|
-
payload = {
|
171
|
-
machineName: "mindscapes-MacBook-Pro.local",
|
172
|
-
version: nil,
|
173
|
-
client: {name: "Raygun4Ruby Gem", version: "1.1.12", clientUrl: "https://github.com/MindscapeHQ/raygun4ruby"},
|
174
|
-
error: {className: "Exception", message: "foo", stackTrace: []},
|
175
|
-
userCustomData: {},
|
176
|
-
tags: ["development"],
|
177
|
-
request: {
|
178
|
-
hostName: "localhost",
|
179
|
-
url: "/make-me-an-error-charlie",
|
180
|
-
httpMethod: "GET",
|
181
|
-
iPAddress: "::1",
|
182
|
-
queryString: {
|
183
|
-
param1: "1",
|
184
|
-
param2: "2",
|
185
|
-
param3: "3",
|
186
|
-
},
|
187
|
-
headers: {
|
188
|
-
"Host"=>"localhost:3000",
|
189
|
-
"Connection"=>"keep-alive",
|
190
|
-
"Upgrade-Insecure_requests"=>"1",
|
191
|
-
"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",
|
192
|
-
"Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
193
|
-
"Accept-Encoding"=>"gzip, deflate, sdch, br",
|
194
|
-
"Accept-Language"=>"en-US,en;q=0.8",
|
195
|
-
"Version"=>"HTTP/1.1"
|
196
|
-
},
|
197
|
-
form: {
|
198
|
-
controller: "home",
|
199
|
-
action: "raise_error"
|
200
|
-
},
|
201
|
-
rawData: {
|
202
|
-
controller: "home",
|
203
|
-
action: "raise_error"
|
204
|
-
}
|
205
|
-
}
|
206
|
-
}
|
207
|
-
expected = {
|
208
|
-
machineName: "mindscapes-MacBook-Pro.local",
|
209
|
-
version: nil,
|
210
|
-
client: {name: "Raygun4Ruby Gem", version: "1.1.12", clientUrl: "https://github.com/MindscapeHQ/raygun4ruby"},
|
211
|
-
error: {className: "Exception", message: "foo", stackTrace: []},
|
212
|
-
userCustomData: {},
|
213
|
-
tags: ["development"],
|
214
|
-
request: {
|
215
|
-
hostName: "localhost",
|
216
|
-
url: "/make-me-an-error-charlie",
|
217
|
-
httpMethod: "GET",
|
218
|
-
iPAddress: "::1",
|
219
|
-
queryString: {
|
220
|
-
param1: "1",
|
221
|
-
param2: "2",
|
222
|
-
param3: '[FILTERED]'
|
223
|
-
},
|
224
|
-
headers: {
|
225
|
-
"Host"=>"localhost:3000",
|
226
|
-
"Connection"=>"keep-alive",
|
227
|
-
"Upgrade-Insecure_requests"=>"1",
|
228
|
-
"User-Agent" => "[FILTERED]",
|
229
|
-
"Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
230
|
-
"Accept-Encoding" => "[FILTERED]",
|
231
|
-
"Accept-Language" => "[FILTERED]",
|
232
|
-
"Version" => "[FILTERED]"
|
233
|
-
},
|
234
|
-
form: {
|
235
|
-
controller: "home",
|
236
|
-
action: "[FILTERED]"
|
237
|
-
},
|
238
|
-
rawData: {
|
239
|
-
controller: "home",
|
240
|
-
action: "[FILTERED]"
|
241
|
-
}
|
242
|
-
}
|
243
|
-
}
|
244
|
-
|
245
|
-
new_payload = service.call(shape, payload)
|
246
|
-
|
247
|
-
expect(new_payload).to eq(expected)
|
248
|
-
end
|
249
|
-
end
|
250
|
-
end
|
251
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Raygun
|
4
|
+
module Services
|
5
|
+
describe ApplyWhitelistFilterToPayload do
|
6
|
+
let(:service) { ApplyWhitelistFilterToPayload.new }
|
7
|
+
|
8
|
+
describe "top level keys" do
|
9
|
+
let(:payload) do
|
10
|
+
{ foo: 1, bar: 2 }
|
11
|
+
end
|
12
|
+
let(:expected) do
|
13
|
+
{ foo: 1 , bar: '[FILTERED]'}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "filters out keys that are not present in the shape" do
|
17
|
+
shape = {
|
18
|
+
foo: true
|
19
|
+
}
|
20
|
+
|
21
|
+
new_payload = service.call(shape, payload)
|
22
|
+
|
23
|
+
expect(new_payload).to eq(expected)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "filters out keys that are set to false" do
|
27
|
+
shape = {
|
28
|
+
foo: true,
|
29
|
+
bar: false
|
30
|
+
}
|
31
|
+
|
32
|
+
new_payload = service.call(shape, payload)
|
33
|
+
|
34
|
+
expect(new_payload).to eq(expected)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "nested hashes" do
|
39
|
+
let(:payload) {{
|
40
|
+
foo: 1,
|
41
|
+
bar: {
|
42
|
+
baz: 2,
|
43
|
+
qux: 3
|
44
|
+
}
|
45
|
+
}}
|
46
|
+
let(:expected) {{
|
47
|
+
foo: 1,
|
48
|
+
bar: {
|
49
|
+
baz: 2,
|
50
|
+
qux: '[FILTERED]'
|
51
|
+
}
|
52
|
+
}}
|
53
|
+
|
54
|
+
it "filters out keys in nested hashes" do
|
55
|
+
shape = {
|
56
|
+
foo: true,
|
57
|
+
bar: {
|
58
|
+
baz: true
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
new_payload = service.call(shape, payload)
|
63
|
+
|
64
|
+
expect(new_payload).to eq(expected)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "filters out a nested hash if the whitelist does not contain it" do
|
68
|
+
shape = {
|
69
|
+
foo: true
|
70
|
+
}
|
71
|
+
expected[:bar] = "[FILTERED]"
|
72
|
+
|
73
|
+
new_payload = service.call(shape, payload)
|
74
|
+
|
75
|
+
expect(new_payload).to eq(expected)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "handles nested hashes when the whitelist is set to allow the whole hash" do
|
79
|
+
shape = {
|
80
|
+
bar: true
|
81
|
+
}
|
82
|
+
expected = {
|
83
|
+
foo: '[FILTERED]',
|
84
|
+
bar: {
|
85
|
+
baz: 2,
|
86
|
+
qux: 3
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
new_payload = service.call(shape, payload)
|
91
|
+
|
92
|
+
expect(new_payload).to eq(expected)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "handles nested hashes when the whitelist is set to not allow the whole hash" do
|
96
|
+
shape = {
|
97
|
+
foo: true,
|
98
|
+
bar: false
|
99
|
+
}
|
100
|
+
expected = {
|
101
|
+
foo: 1,
|
102
|
+
bar: '[FILTERED]'
|
103
|
+
}
|
104
|
+
|
105
|
+
new_payload = service.call(shape, payload)
|
106
|
+
|
107
|
+
expect(new_payload).to eq(expected)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "string keys" do
|
112
|
+
it "handles the case where a payload key is a string and a whitelist key is a symbol" do
|
113
|
+
shape = {
|
114
|
+
foo: true
|
115
|
+
}
|
116
|
+
payload = {
|
117
|
+
"foo" => 1,
|
118
|
+
"bar" => 2
|
119
|
+
}
|
120
|
+
expected = {
|
121
|
+
"foo" => 1,
|
122
|
+
"bar" => '[FILTERED]'
|
123
|
+
}
|
124
|
+
|
125
|
+
new_payload = service.call(shape, payload)
|
126
|
+
|
127
|
+
expect(new_payload).to eq(expected)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "handles a very complex shape" do
|
132
|
+
shape = {
|
133
|
+
machineName: true,
|
134
|
+
version: true,
|
135
|
+
client: true,
|
136
|
+
error: {
|
137
|
+
className: true,
|
138
|
+
message: true,
|
139
|
+
stackTrace: true
|
140
|
+
},
|
141
|
+
userCustomData: true,
|
142
|
+
tags: true,
|
143
|
+
request: {
|
144
|
+
hostName: true,
|
145
|
+
url: true,
|
146
|
+
httpMethod: true,
|
147
|
+
iPAddress: true,
|
148
|
+
queryString: {
|
149
|
+
param1: true,
|
150
|
+
param2: true,
|
151
|
+
},
|
152
|
+
headers: {
|
153
|
+
"Host" => true,
|
154
|
+
"Connection" => true,
|
155
|
+
"Upgrade-Insecure_requests" => true,
|
156
|
+
"User-Agent" => false,
|
157
|
+
"Accept" => true,
|
158
|
+
},
|
159
|
+
form: {
|
160
|
+
controller: true,
|
161
|
+
action: false
|
162
|
+
},
|
163
|
+
rawData: {
|
164
|
+
controller: true,
|
165
|
+
action: false
|
166
|
+
}
|
167
|
+
},
|
168
|
+
user: false,
|
169
|
+
}
|
170
|
+
payload = {
|
171
|
+
machineName: "mindscapes-MacBook-Pro.local",
|
172
|
+
version: nil,
|
173
|
+
client: {name: "Raygun4Ruby Gem", version: "1.1.12", clientUrl: "https://github.com/MindscapeHQ/raygun4ruby"},
|
174
|
+
error: {className: "Exception", message: "foo", stackTrace: []},
|
175
|
+
userCustomData: {},
|
176
|
+
tags: ["development"],
|
177
|
+
request: {
|
178
|
+
hostName: "localhost",
|
179
|
+
url: "/make-me-an-error-charlie",
|
180
|
+
httpMethod: "GET",
|
181
|
+
iPAddress: "::1",
|
182
|
+
queryString: {
|
183
|
+
param1: "1",
|
184
|
+
param2: "2",
|
185
|
+
param3: "3",
|
186
|
+
},
|
187
|
+
headers: {
|
188
|
+
"Host"=>"localhost:3000",
|
189
|
+
"Connection"=>"keep-alive",
|
190
|
+
"Upgrade-Insecure_requests"=>"1",
|
191
|
+
"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",
|
192
|
+
"Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
193
|
+
"Accept-Encoding"=>"gzip, deflate, sdch, br",
|
194
|
+
"Accept-Language"=>"en-US,en;q=0.8",
|
195
|
+
"Version"=>"HTTP/1.1"
|
196
|
+
},
|
197
|
+
form: {
|
198
|
+
controller: "home",
|
199
|
+
action: "raise_error"
|
200
|
+
},
|
201
|
+
rawData: {
|
202
|
+
controller: "home",
|
203
|
+
action: "raise_error"
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
expected = {
|
208
|
+
machineName: "mindscapes-MacBook-Pro.local",
|
209
|
+
version: nil,
|
210
|
+
client: {name: "Raygun4Ruby Gem", version: "1.1.12", clientUrl: "https://github.com/MindscapeHQ/raygun4ruby"},
|
211
|
+
error: {className: "Exception", message: "foo", stackTrace: []},
|
212
|
+
userCustomData: {},
|
213
|
+
tags: ["development"],
|
214
|
+
request: {
|
215
|
+
hostName: "localhost",
|
216
|
+
url: "/make-me-an-error-charlie",
|
217
|
+
httpMethod: "GET",
|
218
|
+
iPAddress: "::1",
|
219
|
+
queryString: {
|
220
|
+
param1: "1",
|
221
|
+
param2: "2",
|
222
|
+
param3: '[FILTERED]'
|
223
|
+
},
|
224
|
+
headers: {
|
225
|
+
"Host"=>"localhost:3000",
|
226
|
+
"Connection"=>"keep-alive",
|
227
|
+
"Upgrade-Insecure_requests"=>"1",
|
228
|
+
"User-Agent" => "[FILTERED]",
|
229
|
+
"Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
|
230
|
+
"Accept-Encoding" => "[FILTERED]",
|
231
|
+
"Accept-Language" => "[FILTERED]",
|
232
|
+
"Version" => "[FILTERED]"
|
233
|
+
},
|
234
|
+
form: {
|
235
|
+
controller: "home",
|
236
|
+
action: "[FILTERED]"
|
237
|
+
},
|
238
|
+
rawData: {
|
239
|
+
controller: "home",
|
240
|
+
action: "[FILTERED]"
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
new_payload = service.call(shape, payload)
|
246
|
+
|
247
|
+
expect(new_payload).to eq(expected)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
# Coverage
|
7
|
-
require
|
8
|
-
SimpleCov.start do
|
9
|
-
add_filter
|
10
|
-
end
|
11
|
-
|
12
|
-
require
|
13
|
-
|
14
|
-
RSpec.configure do |config|
|
15
|
-
# Enable flags like --only-failures and --next-failure
|
16
|
-
# config.example_status_persistence_file_path = ".rspec_status"
|
17
|
-
|
18
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
19
|
-
# config.disable_monkey_patching!
|
20
|
-
|
21
|
-
config.expect_with :rspec do |c|
|
22
|
-
c.syntax = :expect
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require "bundler/setup"
|
2
|
+
|
3
|
+
require "timecop"
|
4
|
+
require "webmock/rspec"
|
5
|
+
|
6
|
+
# Coverage
|
7
|
+
require "simplecov"
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter "/spec/"
|
10
|
+
end
|
11
|
+
|
12
|
+
require "support/fake_logger"
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
# Enable flags like --only-failures and --next-failure
|
16
|
+
# config.example_status_persistence_file_path = ".rspec_status"
|
17
|
+
|
18
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
19
|
+
# config.disable_monkey_patching!
|
20
|
+
|
21
|
+
config.expect_with :rspec do |c|
|
22
|
+
c.syntax = :expect
|
23
|
+
end
|
24
|
+
end
|
data/spec/support/fake_logger.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
class FakeLogger
|
2
|
-
def initialize
|
3
|
-
@logger = StringIO.new
|
4
|
-
end
|
5
|
-
|
6
|
-
def info(message)
|
7
|
-
@logger.write(message)
|
8
|
-
end
|
9
|
-
|
10
|
-
def reset
|
11
|
-
@logger.string = ""
|
12
|
-
end
|
13
|
-
|
14
|
-
def get
|
15
|
-
@logger.string
|
16
|
-
end
|
17
|
-
end
|
1
|
+
class FakeLogger
|
2
|
+
def initialize
|
3
|
+
@logger = StringIO.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def info(message)
|
7
|
+
@logger.write(message)
|
8
|
+
end
|
9
|
+
|
10
|
+
def reset
|
11
|
+
@logger.string = ""
|
12
|
+
end
|
13
|
+
|
14
|
+
def get
|
15
|
+
@logger.string
|
16
|
+
end
|
17
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require_relative "../test_helper.rb"
|
2
|
-
|
3
|
-
class ClientTest < Raygun::IntegrationTest
|
4
|
-
|
5
|
-
class InnocentTestException < StandardError
|
6
|
-
def message
|
7
|
-
"I am nothing but a test exception"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_sending_a_sample_exception
|
12
|
-
begin
|
13
|
-
raise InnocentTestException.new
|
14
|
-
rescue InnocentTestException => e
|
15
|
-
response = Raygun.track_exception(e)
|
16
|
-
assert_equal 202, response.code, "Raygun Request Failed: #{response.inspect}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
1
|
+
require_relative "../test_helper.rb"
|
2
|
+
|
3
|
+
class ClientTest < Raygun::IntegrationTest
|
4
|
+
|
5
|
+
class InnocentTestException < StandardError
|
6
|
+
def message
|
7
|
+
"I am nothing but a test exception"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_sending_a_sample_exception
|
12
|
+
begin
|
13
|
+
raise InnocentTestException.new
|
14
|
+
rescue InnocentTestException => e
|
15
|
+
response = Raygun.track_exception(e)
|
16
|
+
assert_equal 202, response.code, "Raygun Request Failed: #{response.inspect}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
20
|
end
|