blinkist-airbrake-scrubber 4.0.1 → 4.1.1

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
  SHA256:
3
- metadata.gz: a083d817fd9131687fae2c4b94df7ec28ae87195ae51d3aa113405d1cdf664b7
4
- data.tar.gz: b88f7ceef737368005585566571902f9982b403b0caeac275a91b01509fd6325
3
+ metadata.gz: 481351d1dcfaacbac3c90de8d56a3ec874ffa06ad7a594d28e8c2d836ad9017d
4
+ data.tar.gz: ef6af4052741c1608fa7ebefaacaca7590d33b1a5eaf97dc82c6698d080145b8
5
5
  SHA512:
6
- metadata.gz: 46dead51e7abc95c97e5021117cf257c55f94205f4208cf6ecec2d5ad27ed4ee0dd49b01a3d9f96db803c47adc8650c9c7915b4868f0dcef5b966ab12accfac4
7
- data.tar.gz: dfd1426d7e9296c82101ede7879268a6ba24dfd582d9971f3949bb2720be3136b5e0c071fa9c743ae71efdd786df8536a4f09f8f2d58f5c2059caf6c00edaf52
6
+ metadata.gz: 0e94893b4853f603fe92f21bbcadeaf281585cfd153b6fc458a6178e5331bd9da24b1842b6de2e4a3fefc8ea066b1519ff253c3351dd820fda2eb4768a4e236f
7
+ data.tar.gz: 71cdc6db850e77c69cff4010507a7c2977664bd46c70d62a9fef6b800a25ac8f48966791528755d2656c97566c71b51e7ebf52bf7442ffd760fd3325290a39ff
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ group :test do
10
10
  gem "forgery"
11
11
  gem "simplecov"
12
12
  gem "dotenv"
13
+ gem "rspec_junit_formatter"
13
14
  end
14
15
 
15
16
  group :development, :test do
@@ -15,7 +15,7 @@ end
15
15
  module Blinkist
16
16
  module AirbrakeScrubber
17
17
  FILTERED = '[Filtered]'
18
- SCRUBBERS = [ MessageEmail, ParamsEmail, ParamsPassword ]
18
+ SCRUBBERS = [ MessageEmail, ParamsEmail, ParamsPassword, ParamsTokens ]
19
19
 
20
20
  # Override original Airbrake.configure
21
21
  def configure(*args, &block)
@@ -11,7 +11,7 @@ module Blinkist
11
11
  end # def self.scrub!
12
12
 
13
13
  def self.scrub(message)
14
- message.gsub(REGEXP, FILTERED)
14
+ message.gsub(REGEXP, FILTERED) if message
15
15
  end
16
16
 
17
17
  end
@@ -0,0 +1,17 @@
1
+ module Blinkist
2
+ module AirbrakeScrubber
3
+ class ParamsTokens
4
+
5
+ def self.scrub!
6
+ ::Airbrake.add_filter do |notice|
7
+ notice[:params] = DeepTraversal.new(notice[:params]).traverse do |key, value|
8
+ value = FILTERED if %w( facebook_access_token google_id_token ).include?(key.to_s)
9
+ value
10
+ end
11
+ notice
12
+ end
13
+ end # def self.scrub!
14
+
15
+ end
16
+ end
17
+ end
@@ -1,7 +1,7 @@
1
1
  module Blinkist
2
2
  module AirbrakeScrubber
3
3
 
4
- VERSION = "4.0.1"
4
+ VERSION = "4.1.1"
5
5
 
6
6
  end
7
7
  end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blinkist::AirbrakeScrubber::ParamsTokens do
4
+ let(:notice) {
5
+ Airbrake.build_notice(
6
+ Exception.new('whatever'),
7
+ { google_id_token: 'blahblah', facebook_access_token: 'whatever', param: 'whatever' }
8
+ )
9
+ }
10
+
11
+ describe "Structure" do
12
+ it "has scrub! method" do
13
+ expect(described_class).to respond_to(:scrub!)
14
+ end
15
+ end
16
+
17
+ describe "self.scrub!" do
18
+ it "adds the filter" do
19
+ expect(Airbrake).to receive(:add_filter)
20
+ described_class::scrub!
21
+ end
22
+
23
+ it "scrubs the google_id_token from the params hash" do
24
+ Airbrake.notice_notifier.instance_variable_get(:@filter_chain).refine(notice)
25
+ expect(notice[:params][:google_id_token]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
26
+ end
27
+
28
+ it "scrubs the deep-nested google_id_token from the params hash" do
29
+ notice = Airbrake.build_notice(
30
+ Exception.new('whatever'),
31
+ { google_id_token: 'bahblah', deeply: { nested: { google_id_token: 'blhablah' } } }
32
+ )
33
+
34
+ Airbrake.notice_notifier.instance_variable_get(:@filter_chain).refine(notice)
35
+ expect(notice[:params][:google_id_token]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
36
+ expect(notice[:params][:deeply][:nested][:google_id_token]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
37
+ end
38
+
39
+ it "scrubs the facebook_access_token from the params hash" do
40
+ Airbrake.notice_notifier.instance_variable_get(:@filter_chain).refine(notice)
41
+ expect(notice[:params][:facebook_access_token]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
42
+ end
43
+
44
+ it "scrubs the deep-nested facebook_access_token from the params hash" do
45
+ notice = Airbrake.build_notice(
46
+ Exception.new('whatever'),
47
+ { facebook_access_token: 'bahblah', deeply: { nested: { facebook_access_token: 'blhablah' } } }
48
+ )
49
+
50
+ Airbrake.notice_notifier.instance_variable_get(:@filter_chain).refine(notice)
51
+ expect(notice[:params][:facebook_access_token]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
52
+ expect(notice[:params][:deeply][:nested][:facebook_access_token]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
53
+ end
54
+ end
55
+
56
+ end
@@ -12,7 +12,7 @@ describe Blinkist::AirbrakeScrubber::VERSION do
12
12
 
13
13
  it 'equals 4.0.1 for auto-check purposes' do
14
14
  version = Blinkist::AirbrakeScrubber::VERSION
15
- expect(version).to eq '4.0.1'
15
+ expect(version).to eq '4.1.1'
16
16
  end
17
17
 
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blinkist-airbrake-scrubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Komarnicki
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-04-09 00:00:00.000000000 Z
13
+ date: 2019-08-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: airbrake
@@ -44,6 +44,7 @@ files:
44
44
  - lib/blinkist-airbrake-scrubber/scrubbers/message_email.rb
45
45
  - lib/blinkist-airbrake-scrubber/scrubbers/params_email.rb
46
46
  - lib/blinkist-airbrake-scrubber/scrubbers/params_password.rb
47
+ - lib/blinkist-airbrake-scrubber/scrubbers/params_tokens.rb
47
48
  - lib/blinkist-airbrake-scrubber/version.rb
48
49
  - spec/spec_helper.rb
49
50
  - spec/specs/lib/blinkist-airbrake-scrubber/airbrake_spec.rb
@@ -51,6 +52,7 @@ files:
51
52
  - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/message_email_spec.rb
52
53
  - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/params_email_spec.rb
53
54
  - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/params_password_spec.rb
55
+ - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/params_tokens_spec.rb
54
56
  - spec/specs/lib/blinkist_airbrake_scrubber_spec.rb
55
57
  - spec/specs/version_spec.rb
56
58
  homepage: https://github.com/blinkist/airbrake-scrubber
@@ -84,5 +86,6 @@ test_files:
84
86
  - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/message_email_spec.rb
85
87
  - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/params_email_spec.rb
86
88
  - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/params_password_spec.rb
89
+ - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/params_tokens_spec.rb
87
90
  - spec/specs/lib/blinkist_airbrake_scrubber_spec.rb
88
91
  - spec/specs/version_spec.rb