Skip to content

Commit

Permalink
Merge pull request #213 from airbrake/airbrake-739-keys-filter-fix
Browse files Browse the repository at this point in the history
filters/keys_filter: handle hash keys that are not symbols/strings
  • Loading branch information
kyrylo authored May 11, 2017
2 parents b3eaf60 + d2de7d9 commit 42593e3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Airbrake Ruby Changelog

### master

* Fixed bug in keys filters while trying to filter a non Symbol/String key when
there's a Regexp ignore pattern defined
([#213](https://github.com/airbrake/airbrake-ruby/pull/213))

### [v2.2.2][v2.2.2] (May 5, 2017)

* Fixed `SystemStackError` while using the thread filter with RSpec
Expand Down
2 changes: 1 addition & 1 deletion lib/airbrake-ruby/filters/keys_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def should_filter?(_key)

def filter_hash(hash)
hash.each_key do |key|
if should_filter?(key)
if should_filter?(key.to_s)
hash[key] = FILTERED
elsif hash[key].is_a?(Hash)
filter_hash(hash[key])
Expand Down
22 changes: 22 additions & 0 deletions spec/filters/keys_blacklist_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper'

RSpec.describe Airbrake::Filters::KeysBlacklist do
subject do
described_class.new(Logger.new('/dev/null'), patterns)
end

describe "#call" do
let(:notice) do
Airbrake::Notice.new(Airbrake::Config.new, AirbrakeTestError.new)
end

context "when a pattern is a regexp and when a key is a hash" do
let(:patterns) { [/bango/] }

it "doesn't fail" do
notice[:params] = { bingo: { {} => 'unfiltered' } }
expect { subject.call(notice) }.not_to raise_error
end
end
end
end

0 comments on commit 42593e3

Please sign in to comment.