airbrake-ruby 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/filters/keys_filter.rb +13 -8
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/filters/keys_blacklist_spec.rb +30 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d37ba4b5467c1b4c23efde342796d56a40ae2603
|
4
|
+
data.tar.gz: 5a500173b55d2aeb86cbc891048d928e0abd4391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17da4cdf501d76c606aa55db2c18fec5bef4af58eeae465fab3dea614d1301db602df0559b894e57cfecf80f68dc616106437fe55fa5ac03e20f4d5a86860ea7
|
7
|
+
data.tar.gz: 45989b8b85dd89dd62ba1a7d81db9630990fef94dd4a36f829353a2553e45f92457613e5f5aae6eb14ce6c6071a0c0b7e8f3f87ea6db110e21bf2bd6317b5631
|
@@ -23,6 +23,11 @@ module Airbrake
|
|
23
23
|
# by blacklist/whitelist filters
|
24
24
|
FILTERABLE_KEYS = %i[environment session params].freeze
|
25
25
|
|
26
|
+
##
|
27
|
+
# @return [Array<Symbol>] parts of a Notice's *context* payload that can
|
28
|
+
# be modified by blacklist/whitelist filters
|
29
|
+
FILTERABLE_CONTEXT_KEYS = %i[user headers].freeze
|
30
|
+
|
26
31
|
##
|
27
32
|
# @return [Integer]
|
28
33
|
attr_reader :weight
|
@@ -53,14 +58,7 @@ module Airbrake
|
|
53
58
|
end
|
54
59
|
|
55
60
|
FILTERABLE_KEYS.each { |key| filter_hash(notice[key]) }
|
56
|
-
|
57
|
-
if notice[:context][:user]
|
58
|
-
if should_filter?(:user)
|
59
|
-
notice[:context][:user] = FILTERED
|
60
|
-
else
|
61
|
-
filter_hash(notice[:context][:user])
|
62
|
-
end
|
63
|
-
end
|
61
|
+
FILTERABLE_CONTEXT_KEYS.each { |key| filter_context_key(notice, key) }
|
64
62
|
|
65
63
|
return unless notice[:context][:url]
|
66
64
|
filter_url(notice)
|
@@ -130,6 +128,13 @@ module Airbrake
|
|
130
128
|
"Known patterns: #{@patterns}"
|
131
129
|
)
|
132
130
|
end
|
131
|
+
|
132
|
+
def filter_context_key(notice, key)
|
133
|
+
return unless notice[:context][key]
|
134
|
+
return filter_hash(notice[:context][key]) unless should_filter?(key)
|
135
|
+
|
136
|
+
notice[:context][key] = FILTERED
|
137
|
+
end
|
133
138
|
end
|
134
139
|
end
|
135
140
|
end
|
@@ -193,5 +193,35 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
193
193
|
expect(notice[:context][:user]).to eq('[Filtered]')
|
194
194
|
end
|
195
195
|
end
|
196
|
+
|
197
|
+
context "and when it is a hash" do
|
198
|
+
let(:patterns) { ['name'] }
|
199
|
+
|
200
|
+
it "filters out individual user fields" do
|
201
|
+
notice[:context][:user] = { id: 1337, name: 'Bingo Bango' }
|
202
|
+
subject.call(notice)
|
203
|
+
expect(notice[:context][:user][:name]).to eq('[Filtered]')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
context "when the headers key is present" do
|
209
|
+
let(:patterns) { ['headers'] }
|
210
|
+
|
211
|
+
it "filters out the headers" do
|
212
|
+
notice[:context][:headers] = { 'HTTP_COOKIE' => 'banana' }
|
213
|
+
subject.call(notice)
|
214
|
+
expect(notice[:context][:headers]).to eq('[Filtered]')
|
215
|
+
end
|
216
|
+
|
217
|
+
context "and when it is a hash" do
|
218
|
+
let(:patterns) { ['HTTP_COOKIE'] }
|
219
|
+
|
220
|
+
it "filters out individual header fields" do
|
221
|
+
notice[:context][:headers] = { 'HTTP_COOKIE' => 'banana' }
|
222
|
+
subject.call(notice)
|
223
|
+
expect(notice[:context][:headers]['HTTP_COOKIE']).to eq('[Filtered]')
|
224
|
+
end
|
225
|
+
end
|
196
226
|
end
|
197
227
|
end
|