airbrake-ruby 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 485663114790c11fb2bce21e7d5fc9c89a2f5557
4
- data.tar.gz: 4e6de160720983de3ba60294b2674329c1ffa9db
3
+ metadata.gz: d37ba4b5467c1b4c23efde342796d56a40ae2603
4
+ data.tar.gz: 5a500173b55d2aeb86cbc891048d928e0abd4391
5
5
  SHA512:
6
- metadata.gz: 80d9aecb4ce06871347b40ee525b8b286199845096c3533e7a6109d55be1422d473f27f48ec33fa402d6760e95778c835485b1695836e67a893419921cbf170a
7
- data.tar.gz: ef0440643d93d0bedc16d4bf3d8710467a7f5287dd5331b07f9b5f2f6c0ab42bc042b887d78d344a47df7c7f59a60b5f0699792832262a7776527b6c85331667
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
@@ -4,5 +4,5 @@
4
4
  module Airbrake
5
5
  ##
6
6
  # @return [String] the library version
7
- AIRBRAKE_RUBY_VERSION = '2.4.1'.freeze
7
+ AIRBRAKE_RUBY_VERSION = '2.4.2'.freeze
8
8
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.