blinkist-airbrake-scrubber 2.1.2 → 3.0.0

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
- SHA256:
3
- metadata.gz: 53871ae26c08cd03b64bc821bfec741187b5c2def8e4ea753f421d49dc484738
4
- data.tar.gz: 72102ad7935db2166fb74fc1479f5d6fe5cf7c2a85c2446c737945587c014e7f
2
+ SHA1:
3
+ metadata.gz: 6c7292d499d48e12d164b7099303bc900cb2386c
4
+ data.tar.gz: e5c1c74178c864d515b79e91c3cf2815da08584e
5
5
  SHA512:
6
- metadata.gz: 5729e3cab4e34ae7e0e80715e716e65846d1ccaf51fe9808d8dba10f73809bf759940376540587bb959572ee8a4c2217efad0b6bf8b383c06b2f2cde777e3468
7
- data.tar.gz: ad1d22a7067437c2c45708a9730a5e8a03d29b42ece38a0d24916f11bf400a6e882393432c15a015bb594f45c29fad7b6e6d74ab7ea89e295a129bd1d8aee3a5
6
+ metadata.gz: 8a6c5b60ac452b1c6137dd00138db21b2bdfd403fb2ef62c5514b23dc6aefca20946ce0076581077fd6198b6e62f4626ce06385850f47cbce3bf62f69f83949c
7
+ data.tar.gz: ce775a0990fe520c9d7396df3da85c48e92b279b7faae5963e6d8da16db69c3c0b87230247d2e49c530190d8cac06a0b02f6bff7a677b0999bb42dc8c0f117bd
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # Blinkist::Airbrake::Scrubber
1
+ # Blinkist::AirbrakeScrubber
2
2
 
3
- Blinkist::Airbrake::Scrubber provides an Airbrake scrubbing service to remove various sensitive informations from the notifications, e.g. emails. It does *not* replace Airbrake configuration, but provides some seamless functionality.
3
+ Blinkist::AirbrakeScrubber provides an Airbrake scrubbing service to remove various sensitive informations from the notifications, e.g. emails. It does *not* replace Airbrake configuration, but provides some seamless functionality.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem "blinkist-airbrake-scrubber", "0.0.1", github: "blinkist-airbrake-scrubber", tag: "v0.0.1"
9
+ gem "blinkist-airbrake-scrubber"
10
10
 
11
11
  And then execute:
12
12
 
@@ -19,7 +19,7 @@ And then execute:
19
19
  To extend the functionality, create a new scrubber file in `lib/blinkist-airbrake-scrubber/scrubbers` folder, like the template:
20
20
 
21
21
  ```ruby
22
- module Blinkist::Airbrake::Scrubber
22
+ module Blinkist::AirbrakeScrubber
23
23
  class WubbaLubba
24
24
  REGEXP = /[\S]+@[\S]+/i
25
25
 
@@ -34,17 +34,11 @@ module Blinkist::Airbrake::Scrubber
34
34
  end
35
35
  ```
36
36
 
37
- Then, add the class to Blinkist::Airbrake::Scrubber's SCRUBBERS list to have it ran after Airbrake.configure
38
-
39
- ### Applications using this gem
40
-
41
- There are a few applications available on GitHub that use this gem. For usage see:
42
-
43
- * blinkist-messenger
37
+ Then, add the class to Blinkist::AirbrakeScrubber's SCRUBBERS list to have it ran after Airbrake.configure
44
38
 
45
39
  ### Dependencies
46
40
 
47
- This gem has dependency on airbrake (~> 5), it will automatically add it unless already bundled.
41
+ This gem has dependency on airbrake (~> 7), it will automatically add it unless already bundled.
48
42
 
49
43
  ## Maintainers
50
44
 
@@ -5,12 +5,12 @@ require_relative "lib/blinkist-airbrake-scrubber/version"
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "blinkist-airbrake-scrubber"
8
- gem.version = Blinkist::Airbrake::Scrubber::VERSION
9
- gem.authors = ["Paweł Komarnicki", "Dinesh Vasudevan"]
10
- gem.email = ["pawel@blinkist.com", "dinesh@blinkist.com"]
8
+ gem.version = Blinkist::AirbrakeScrubber::VERSION
9
+ gem.authors = ["Paweł Komarnicki", "Dinesh Vasudevan", 'Tomek Przedmojski']
10
+ gem.email = ["pawel@blinkist.com", "dinesh@blinkist.com", "tomek@blinkist.com"]
11
11
  gem.description = %q{Email scrubbing configuration for Airbrake at Blinkist}
12
12
  gem.summary = %q{With this, Airbrake will not leak emails via exception notifications}
13
- gem.homepage = "https://github.com/blinkist/blinkist-airbrake-scrubber"
13
+ gem.homepage = "https://github.com/blinkist/airbrake-scrubber"
14
14
  gem.license = "MIT"
15
15
 
16
16
  # Airbrake
@@ -4,32 +4,30 @@ Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each do |f|
4
4
  end
5
5
 
6
6
  # Prepend the original Airbrake module
7
- # Note: Do not remove from this file, it needs to be before Blinkist::Airbrake::Scrubber
7
+ # Note: Do not remove from this file, it needs to be before Blinkist::AirbrakeScrubber
8
8
  module Airbrake
9
9
  class << self
10
- prepend Blinkist::Airbrake::Scrubber
10
+ prepend Blinkist::AirbrakeScrubber
11
11
  end
12
12
  end
13
13
 
14
14
  # Set up the namespace and run every scrubber listed in SCRUBBERS
15
15
  module Blinkist
16
- module Airbrake
17
- module Scrubber
18
- FILTERED = '[Filtered]'
19
- SCRUBBERS = [ MessageEmail, ParamsEmail, ParamsPassword ]
16
+ module AirbrakeScrubber
17
+ FILTERED = '[Filtered]'
18
+ SCRUBBERS = [ MessageEmail, ParamsEmail, ParamsPassword ]
20
19
 
21
- # Override original Airbrake.configure
22
- def configure(*args, &block)
23
- super
24
- ensure
25
- Blinkist::Airbrake::Scrubber.run!
26
- end
27
-
28
- # Run scrubbers
29
- def self.run!
30
- SCRUBBERS.each { |scrubber| scrubber::scrub! }
31
- end
20
+ # Override original Airbrake.configure
21
+ def configure(*args, &block)
22
+ super
23
+ ensure
24
+ Blinkist::AirbrakeScrubber.run!
25
+ end
32
26
 
27
+ # Run scrubbers
28
+ def self.run!
29
+ SCRUBBERS.each { |scrubber| scrubber::scrub! }
33
30
  end
31
+
34
32
  end
35
33
  end
@@ -1,43 +1,41 @@
1
1
  # DeepTraversal provides traverse possibility of Hashes
2
2
  # Can handle Hash objects with deep nesting, or other nested objects that can be dug deeper (e.g. Array)
3
3
  module Blinkist
4
- module Airbrake
5
- module Scrubber
4
+ module AirbrakeScrubber
6
5
 
7
- class DeepTraversal
8
- def initialize(source)
9
- @source = source
10
- end
6
+ class DeepTraversal
7
+ def initialize(source)
8
+ @source = source
9
+ end
11
10
 
12
- def traverse(&block)
13
- recursive_traverse(@source, &block)
14
- end
11
+ def traverse(&block)
12
+ recursive_traverse(@source, &block)
13
+ end
15
14
 
16
- private
15
+ private
17
16
 
18
- def recursive_traverse(input, &block)
19
- case input
20
- when Array
21
- input.map { |i| recursive_traverse(i, &block) }
17
+ def recursive_traverse(input, &block)
18
+ case input
19
+ when Array
20
+ input.map { |i| recursive_traverse(i, &block) }
22
21
 
23
- when Hash
24
- Hash[input.map { |key, value|
22
+ when Hash
23
+ Hash[input.map { |key, value|
25
24
 
26
- # Go deeper for things that are not simple objects
27
- case value
28
- when Array, Hash
29
- [ key, recursive_traverse(value, &block) ]
30
- else
31
- [ key, block.call(key, value) ]
32
- end
25
+ # Go deeper for things that are not simple objects
26
+ case value
27
+ when Array, Hash
28
+ [ key, recursive_traverse(value, &block) ]
29
+ else
30
+ [ key, block.call(key, value) ]
31
+ end
33
32
 
34
- }]
35
- else
36
- input
37
- end
33
+ }]
34
+ else
35
+ input
38
36
  end
39
37
  end
40
-
41
38
  end
39
+
42
40
  end
43
41
  end
@@ -1,21 +1,19 @@
1
1
  module Blinkist
2
- module Airbrake
3
- module Scrubber
4
- class MessageEmail
5
- REGEXP = /[\S]+@[\S]+/i
2
+ module AirbrakeScrubber
3
+ class MessageEmail
4
+ REGEXP = /[\S]+@[\S]+/i
6
5
 
7
- def self.scrub!
8
- ::Airbrake.add_filter do |notice|
9
- # Cannot do gsub! coz of frozen literals
10
- notice[:errors].each { |error| error[:message] = scrub(error[:message]) }
11
- end
12
- end # def self.scrub!
13
-
14
- def self.scrub(message)
15
- message.gsub(REGEXP, FILTERED)
6
+ def self.scrub!
7
+ ::Airbrake.add_filter do |notice|
8
+ # Cannot do gsub! coz of frozen literals
9
+ notice[:errors].each { |error| error[:message] = scrub(error[:message]) }
16
10
  end
11
+ end # def self.scrub!
17
12
 
13
+ def self.scrub(message)
14
+ message.gsub(REGEXP, FILTERED)
18
15
  end
16
+
19
17
  end
20
18
  end
21
19
  end
@@ -1,19 +1,17 @@
1
1
  module Blinkist
2
- module Airbrake
3
- module Scrubber
4
- class ParamsEmail
2
+ module AirbrakeScrubber
3
+ class ParamsEmail
5
4
 
6
- def self.scrub!
7
- ::Airbrake.add_filter do |notice|
8
- notice[:params] = DeepTraversal.new(notice[:params]).traverse do |key, value|
9
- value = FILTERED if key.to_s == 'email'
10
- value
11
- end
12
- notice
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 key.to_s == 'email'
9
+ value
13
10
  end
14
- end # def self.scrub!
11
+ notice
12
+ end
13
+ end # def self.scrub!
15
14
 
16
- end
17
15
  end
18
16
  end
19
17
  end
@@ -1,19 +1,17 @@
1
1
  module Blinkist
2
- module Airbrake
3
- module Scrubber
4
- class ParamsPassword
2
+ module AirbrakeScrubber
3
+ class ParamsPassword
5
4
 
6
- def self.scrub!
7
- ::Airbrake.add_filter do |notice|
8
- notice[:params] = DeepTraversal.new(notice[:params]).traverse do |key, value|
9
- value = FILTERED if key.to_s == 'password'
10
- value
11
- end
12
- notice
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 key.to_s == 'password'
9
+ value
13
10
  end
14
- end # def self.scrub!
11
+ notice
12
+ end
13
+ end # def self.scrub!
15
14
 
16
- end
17
15
  end
18
16
  end
19
17
  end
@@ -1,7 +1,7 @@
1
1
  module Blinkist
2
- module Airbrake
3
- module Scrubber
4
- VERSION = "2.1.2"
5
- end
2
+ module AirbrakeScrubber
3
+
4
+ VERSION = "3.0.0"
5
+
6
6
  end
7
7
  end
@@ -10,14 +10,14 @@ describe Airbrake do
10
10
  }
11
11
 
12
12
  describe "Module#prepend" do
13
- it "does have Blinkist::Airbrake::Scrubber as one of the ancestors" do
14
- expect(described_class.ancestors).to include(Blinkist::Airbrake::Scrubber)
13
+ it "does have Blinkist::AirbrakeScrubber as one of the ancestors" do
14
+ expect(described_class.ancestors).to include(Blinkist::AirbrakeScrubber)
15
15
  end
16
16
  end
17
17
 
18
18
  describe '.configure' do
19
- it "does call Blinkist::Airbrake::Scrubber.configure" do
20
- expect_any_instance_of(Blinkist::Airbrake::Scrubber).to receive(:configure)
19
+ it "does call Blinkist::AirbrakeScrubber.configure" do
20
+ expect_any_instance_of(Blinkist::AirbrakeScrubber).to receive(:configure)
21
21
  instantiate_airbrake
22
22
  end
23
23
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'blinkist-airbrake-scrubber'
3
3
 
4
- describe Blinkist::Airbrake::Scrubber::DeepTraversal do
4
+ describe Blinkist::AirbrakeScrubber::DeepTraversal do
5
5
  subject { described_class.new(source) }
6
6
 
7
7
  let(:source) { Hash.new }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Blinkist::Airbrake::Scrubber::MessageEmail do
3
+ describe Blinkist::AirbrakeScrubber::MessageEmail do
4
4
 
5
5
  describe "Structure" do
6
6
  it "has REGEXP constant" do
@@ -24,7 +24,7 @@ describe Blinkist::Airbrake::Scrubber::MessageEmail do
24
24
  # It's ridiculously hard to peek into Airbrake::Notice
25
25
  # Instead verify the functionality here
26
26
  describe ".scrub" do
27
- let(:filtered) { Blinkist::Airbrake::Scrubber::FILTERED }
27
+ let(:filtered) { Blinkist::AirbrakeScrubber::FILTERED }
28
28
  let(:regexp) { described_class::REGEXP }
29
29
 
30
30
  let(:valid_domains) { %w{ example.org exam-ple.org exam.ple.org e-xam.ple.org e-xam.p-le.org e.x.a.m.p.l.e.co.uk } }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Blinkist::Airbrake::Scrubber::ParamsEmail do
3
+ describe Blinkist::AirbrakeScrubber::ParamsEmail do
4
4
  let(:notifier) { Airbrake[:default] }
5
5
  let(:notice) {
6
6
  Airbrake[:default].build_notice(
@@ -23,7 +23,7 @@ describe Blinkist::Airbrake::Scrubber::ParamsEmail do
23
23
 
24
24
  it "scrubs the email from the params hash" do
25
25
  notifier.instance_variable_get(:@filter_chain).refine(notice)
26
- expect(notice[:params][:email]).to eq(Blinkist::Airbrake::Scrubber::FILTERED)
26
+ expect(notice[:params][:email]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
27
27
  end
28
28
 
29
29
  it "scrubs the deep-nested email from the params hash" do
@@ -33,8 +33,8 @@ describe Blinkist::Airbrake::Scrubber::ParamsEmail do
33
33
  )
34
34
 
35
35
  notifier.instance_variable_get(:@filter_chain).refine(notice)
36
- expect(notice[:params][:email]).to eq(Blinkist::Airbrake::Scrubber::FILTERED)
37
- expect(notice[:params][:deeply][:nested][:email]).to eq(Blinkist::Airbrake::Scrubber::FILTERED)
36
+ expect(notice[:params][:email]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
37
+ expect(notice[:params][:deeply][:nested][:email]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
38
38
  end
39
39
  end
40
40
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Blinkist::Airbrake::Scrubber::ParamsPassword do
3
+ describe Blinkist::AirbrakeScrubber::ParamsPassword do
4
4
  let(:notifier) { Airbrake[:default] }
5
5
  let(:notice) {
6
6
  Airbrake[:default].build_notice(
@@ -23,7 +23,7 @@ describe Blinkist::Airbrake::Scrubber::ParamsPassword do
23
23
 
24
24
  it "scrubs the password from the params hash" do
25
25
  notifier.instance_variable_get(:@filter_chain).refine(notice)
26
- expect(notice[:params][:password]).to eq(Blinkist::Airbrake::Scrubber::FILTERED)
26
+ expect(notice[:params][:password]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
27
27
  end
28
28
 
29
29
  it "scrubs the deep-nested password from the params hash" do
@@ -33,8 +33,8 @@ describe Blinkist::Airbrake::Scrubber::ParamsPassword do
33
33
  )
34
34
 
35
35
  notifier.instance_variable_get(:@filter_chain).refine(notice)
36
- expect(notice[:params][:password]).to eq(Blinkist::Airbrake::Scrubber::FILTERED)
37
- expect(notice[:params][:deeply][:nested][:password]).to eq(Blinkist::Airbrake::Scrubber::FILTERED)
36
+ expect(notice[:params][:password]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
37
+ expect(notice[:params][:deeply][:nested][:password]).to eq(Blinkist::AirbrakeScrubber::FILTERED)
38
38
  end
39
39
  end
40
40
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'securerandom'
3
3
  require 'blinkist-airbrake-scrubber'
4
4
 
5
- describe Blinkist::Airbrake::Scrubber do
5
+ describe Blinkist::AirbrakeScrubber do
6
6
  let(:instantiate_airbrake) {
7
7
  Airbrake.configure :"notifier_#{ SecureRandom.uuid }" do |c|
8
8
  c.project_id = 1
@@ -12,19 +12,19 @@ describe Blinkist::Airbrake::Scrubber do
12
12
 
13
13
  describe "Constants" do
14
14
  it "has FILTERED constant" do
15
- expect(Blinkist::Airbrake::Scrubber.constants).to include(:FILTERED)
15
+ expect(Blinkist::AirbrakeScrubber.constants).to include(:FILTERED)
16
16
  end
17
17
 
18
18
  it "has explicit FILTERED constant content" do
19
- expect(Blinkist::Airbrake::Scrubber::FILTERED).to eq('[Filtered]')
19
+ expect(Blinkist::AirbrakeScrubber::FILTERED).to eq('[Filtered]')
20
20
  end
21
21
 
22
22
  it "has SCRUBBERS constant" do
23
- expect(Blinkist::Airbrake::Scrubber.constants).to include(:SCRUBBERS)
23
+ expect(Blinkist::AirbrakeScrubber.constants).to include(:SCRUBBERS)
24
24
  end
25
25
 
26
26
  it "has list of scrubbers in SCRUBBERS" do
27
- expect(Blinkist::Airbrake::Scrubber::SCRUBBERS.is_a?(Array)).to be true
27
+ expect(Blinkist::AirbrakeScrubber::SCRUBBERS.is_a?(Array)).to be true
28
28
  end
29
29
  end
30
30
 
@@ -34,15 +34,15 @@ describe Blinkist::Airbrake::Scrubber do
34
34
  instantiate_airbrake
35
35
  end
36
36
 
37
- it "calls Blinkist::Airbrake::Scrubber.run!" do
38
- expect(Blinkist::Airbrake::Scrubber).to receive(:run!)
37
+ it "calls Blinkist::AirbrakeScrubber.run!" do
38
+ expect(Blinkist::AirbrakeScrubber).to receive(:run!)
39
39
  instantiate_airbrake
40
40
  end
41
41
  end
42
42
 
43
43
  describe "self.run!" do
44
44
  it "runs ::scrub! for every scrubber declared in SCRUBBERS" do
45
- Blinkist::Airbrake::Scrubber::SCRUBBERS.each do |scrubber|
45
+ Blinkist::AirbrakeScrubber::SCRUBBERS.each do |scrubber|
46
46
  expect(scrubber).to receive(:scrub!)
47
47
  end
48
48
  instantiate_airbrake
@@ -2,17 +2,17 @@
2
2
  require 'spec_helper'
3
3
  require 'blinkist-airbrake-scrubber/version'
4
4
 
5
- describe Blinkist::Airbrake::Scrubber::VERSION do
5
+ describe Blinkist::AirbrakeScrubber::VERSION do
6
6
 
7
7
  it 'provides the current version' do
8
- version = Blinkist::Airbrake::Scrubber::VERSION
8
+ version = Blinkist::AirbrakeScrubber::VERSION
9
9
  expect(version).to_not be nil
10
10
  expect(version.instance_of?(String)).to be true
11
11
  end
12
12
 
13
- it 'equals 2.1.2 for auto-check purposes' do
14
- version = Blinkist::Airbrake::Scrubber::VERSION
15
- expect(version).to eq '2.1.2'
13
+ it 'equals 3.0.0 for auto-check purposes' do
14
+ version = Blinkist::AirbrakeScrubber::VERSION
15
+ expect(version).to eq '3.0.0'
16
16
  end
17
17
 
18
18
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blinkist-airbrake-scrubber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Komarnicki
8
8
  - Dinesh Vasudevan
9
+ - Tomek Przedmojski
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2018-05-24 00:00:00.000000000 Z
13
+ date: 2018-05-28 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: airbrake
@@ -29,6 +30,7 @@ description: Email scrubbing configuration for Airbrake at Blinkist
29
30
  email:
30
31
  - pawel@blinkist.com
31
32
  - dinesh@blinkist.com
33
+ - tomek@blinkist.com
32
34
  executables: []
33
35
  extensions: []
34
36
  extra_rdoc_files: []
@@ -51,7 +53,7 @@ files:
51
53
  - spec/specs/lib/blinkist-airbrake-scrubber/scrubbers/params_password_spec.rb
52
54
  - spec/specs/lib/blinkist_airbrake_scrubber_spec.rb
53
55
  - spec/specs/version_spec.rb
54
- homepage: https://github.com/blinkist/blinkist-airbrake-scrubber
56
+ homepage: https://github.com/blinkist/airbrake-scrubber
55
57
  licenses:
56
58
  - MIT
57
59
  metadata: {}
@@ -71,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
73
  version: '0'
72
74
  requirements: []
73
75
  rubyforge_project:
74
- rubygems_version: 2.7.6
76
+ rubygems_version: 2.5.2.2
75
77
  signing_key:
76
78
  specification_version: 4
77
79
  summary: With this, Airbrake will not leak emails via exception notifications