airbrake-ruby 4.14.1 → 4.15.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
2
  SHA256:
3
- metadata.gz: 8a99b9f69c92aab19bd33806452b720f4e193578d5ffa22f79faa780c38d9fa0
4
- data.tar.gz: 6e19717eef99f7446b8f2e50e79e2eea6787d2b283c0a291821f09ab5e227a8f
3
+ metadata.gz: 9737dfd8078f14a0150525e1c8b226bcaa5bb87e7627542d7a1a25a27d3c191d
4
+ data.tar.gz: 653ff8929bc7199a77c59ead004167a38d214741157282d93e947c3d5ca8ecd6
5
5
  SHA512:
6
- metadata.gz: 8ece3a704ef7a11e8994e657e53526c684da53316cc609ff8efc05e5b14cf6eca8b2536233a8ab0bfd8c6bc0997f7c97a9ef073967a8fd85b69f960db9db5757
7
- data.tar.gz: 28b983d5c3b2b3e7d2a31c5429ffb72b06103569444411c5e7231c76ce308ef143140f40d215401b178aa2022f912914ef7c3f7b14ec4f01c75398342dda97c0
6
+ metadata.gz: 21d60bd1415bec1e0ed3b89891f5b35e56f019b09dcb50c05f1e55b2176a2976a566c95e0a3fc4cdce2601a1b4b0e786b1ddbcc67188da6df51bd5c94188e54d
7
+ data.tar.gz: 3c3b2312b7945685c6199ecd21f23601b752e1d4234d35461db2f4c7cf0318c24ee263df2536e9cffb7e107002a5a5be10af1cf7eecc16ac65e07cd948f2c68e
@@ -24,8 +24,8 @@ require 'airbrake-ruby/notice'
24
24
  require 'airbrake-ruby/backtrace'
25
25
  require 'airbrake-ruby/truncator'
26
26
  require 'airbrake-ruby/filters/keys_filter'
27
- require 'airbrake-ruby/filters/keys_whitelist'
28
- require 'airbrake-ruby/filters/keys_blacklist'
27
+ require 'airbrake-ruby/filters/keys_allowlist'
28
+ require 'airbrake-ruby/filters/keys_blocklist'
29
29
  require 'airbrake-ruby/filters/gem_root_filter'
30
30
  require 'airbrake-ruby/filters/system_exit_filter'
31
31
  require 'airbrake-ruby/filters/root_directory_filter'
@@ -572,14 +572,14 @@ module Airbrake
572
572
 
573
573
  # rubocop:disable Metrics/AbcSize
574
574
  def process_config_options(config)
575
- if config.blacklist_keys.any?
576
- blacklist = Airbrake::Filters::KeysBlacklist.new(config.blacklist_keys)
577
- notice_notifier.add_filter(blacklist)
575
+ if config.blocklist_keys.any?
576
+ blocklist = Airbrake::Filters::KeysBlocklist.new(config.blocklist_keys)
577
+ notice_notifier.add_filter(blocklist)
578
578
  end
579
579
 
580
- if config.whitelist_keys.any?
581
- whitelist = Airbrake::Filters::KeysWhitelist.new(config.whitelist_keys)
582
- notice_notifier.add_filter(whitelist)
580
+ if config.allowlist_keys.any?
581
+ allowlist = Airbrake::Filters::KeysAllowlist.new(config.allowlist_keys)
582
+ notice_notifier.add_filter(allowlist)
583
583
  end
584
584
 
585
585
  return unless config.root_directory
@@ -68,14 +68,20 @@ module Airbrake
68
68
  # @return [Array<String, Symbol, Regexp>] the keys, which should be
69
69
  # filtered
70
70
  # @api public
71
- # @since v1.2.0
72
- attr_accessor :blacklist_keys
71
+ # @since v4.15.0
72
+ attr_accessor :allowlist_keys
73
73
 
74
- # @return [Array<String, Symbol, Regexp>] the keys, which shouldn't be
74
+ # @deprecated Use allowlist_keys instead
75
+ alias whitelist_keys allowlist_keys
76
+
77
+ # @return [Array<String, Symbol, Regexp>] the keys, which should be
75
78
  # filtered
76
79
  # @api public
77
- # @since v1.2.0
78
- attr_accessor :whitelist_keys
80
+ # @since v4.15.0
81
+ attr_accessor :blocklist_keys
82
+
83
+ # @deprecated Use blocklist_keys instead
84
+ alias blacklist_keys blocklist_keys
79
85
 
80
86
  # @return [Boolean] true if the library should attach code hunks to each
81
87
  # frame in a backtrace, false otherwise
@@ -134,8 +140,8 @@ module Airbrake
134
140
 
135
141
  self.timeout = user_config[:timeout]
136
142
 
137
- self.blacklist_keys = []
138
- self.whitelist_keys = []
143
+ self.blocklist_keys = []
144
+ self.allowlist_keys = []
139
145
 
140
146
  self.root_directory = File.realpath(
141
147
  (defined?(Bundler) && Bundler.root) ||
@@ -152,6 +158,24 @@ module Airbrake
152
158
  end
153
159
  # rubocop:enable Metrics/AbcSize
154
160
 
161
+ def blacklist_keys=(keys)
162
+ loc = caller_locations(1..1).first
163
+ Kernel.warn(
164
+ "#{loc.path}:#{loc.lineno}: warning: blacklist_keys= is deprecated " \
165
+ "use blocklist_keys= instead",
166
+ )
167
+ self.blocklist_keys = keys
168
+ end
169
+
170
+ def whitelist_keys=(keys)
171
+ loc = caller_locations(1..1).first
172
+ Kernel.warn(
173
+ "#{loc.path}:#{loc.lineno}: warning: whitelist_keys= is deprecated " \
174
+ "use allowlist_keys= instead",
175
+ )
176
+ self.allowlist_keys = keys
177
+ end
178
+
155
179
  # The full URL to the Airbrake Notice API. Based on the +:host+ option.
156
180
  # @return [URI] the endpoint address
157
181
  def endpoint
@@ -4,7 +4,7 @@ module Airbrake
4
4
  # notice, but specified keys.
5
5
  #
6
6
  # @example
7
- # filter = Airbrake::Filters::KeysBlacklist.new(
7
+ # filter = Airbrake::Filters::KeysAllowlist.new(
8
8
  # [:email, /credit/i, 'password']
9
9
  # )
10
10
  # airbrake.add_filter(filter)
@@ -22,9 +22,9 @@ module Airbrake
22
22
  # # email: 'john@example.com',
23
23
  # # account_id: 42 }
24
24
  #
25
- # @see KeysBlacklist
25
+ # @see KeysBlocklist
26
26
  # @see KeysFilter
27
- class KeysWhitelist
27
+ class KeysAllowlist
28
28
  include KeysFilter
29
29
 
30
30
  def initialize(*)
@@ -4,7 +4,7 @@ module Airbrake
4
4
  # list of parameters in the payload of a notice.
5
5
  #
6
6
  # @example
7
- # filter = Airbrake::Filters::KeysBlacklist.new(
7
+ # filter = Airbrake::Filters::KeysBlocklist.new(
8
8
  # [:email, /credit/i, 'password']
9
9
  # )
10
10
  # airbrake.add_filter(filter)
@@ -22,10 +22,10 @@ module Airbrake
22
22
  # # email: '[Filtered]',
23
23
  # # credit_card: '[Filtered]' }
24
24
  #
25
- # @see KeysWhitelist
25
+ # @see KeysAllowlist
26
26
  # @see KeysFilter
27
27
  # @api private
28
- class KeysBlacklist
28
+ class KeysBlocklist
29
29
  include KeysFilter
30
30
 
31
31
  def initialize(*)
@@ -7,8 +7,8 @@ module Airbrake
7
7
  # class that includes this module must implement.
8
8
  #
9
9
  # @see Notice
10
- # @see KeysWhitelist
11
- # @see KeysBlacklist
10
+ # @see KeysAllowlist
11
+ # @see KeysBlocklist
12
12
  # @api private
13
13
  module KeysFilter
14
14
  # @return [String] The label to replace real values of filtered payload
@@ -19,11 +19,11 @@ module Airbrake
19
19
  VALID_PATTERN_CLASSES = [String, Symbol, Regexp].freeze
20
20
 
21
21
  # @return [Array<Symbol>] parts of a Notice's payload that can be modified
22
- # by blacklist/whitelist filters
22
+ # by blocklist/allowlist filters
23
23
  FILTERABLE_KEYS = %i[environment session params].freeze
24
24
 
25
25
  # @return [Array<Symbol>] parts of a Notice's *context* payload that can
26
- # be modified by blacklist/whitelist filters
26
+ # be modified by blocklist/allowlist filters
27
27
  FILTERABLE_CONTEXT_KEYS = %i[
28
28
  user
29
29
 
@@ -42,7 +42,7 @@ module Airbrake
42
42
  # @return [Integer]
43
43
  attr_reader :weight
44
44
 
45
- # Creates a new KeysBlacklist or KeysWhitelist filter that uses the given
45
+ # Creates a new KeysBlocklist or KeysAllowlist filter that uses the given
46
46
  # +patterns+ for filtering a notice's payload.
47
47
  #
48
48
  # @param [Array<String,Regexp,Symbol>] patterns
@@ -2,5 +2,5 @@
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
- AIRBRAKE_RUBY_VERSION = '4.14.1'.freeze
5
+ AIRBRAKE_RUBY_VERSION = '4.15.0'.freeze
6
6
  end
@@ -99,33 +99,33 @@ RSpec.describe Airbrake do
99
99
  end
100
100
  end
101
101
 
102
- context "when blacklist_keys gets configured" do
102
+ context "when blocklist_keys gets configured" do
103
103
  before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
104
104
 
105
- it "adds blacklist filter" do
105
+ it "adds blocklist filter" do
106
106
  expect(Airbrake.notice_notifier).to receive(:add_filter)
107
- .with(an_instance_of(Airbrake::Filters::KeysBlacklist))
108
- described_class.configure { |c| c.blacklist_keys = %w[password] }
107
+ .with(an_instance_of(Airbrake::Filters::KeysBlocklist))
108
+ described_class.configure { |c| c.blocklist_keys = %w[password] }
109
109
  end
110
110
 
111
- it "initializes blacklist with specified parameters" do
112
- expect(Airbrake::Filters::KeysBlacklist).to receive(:new).with(%w[password])
113
- described_class.configure { |c| c.blacklist_keys = %w[password] }
111
+ it "initializes blocklist with specified parameters" do
112
+ expect(Airbrake::Filters::KeysBlocklist).to receive(:new).with(%w[password])
113
+ described_class.configure { |c| c.blocklist_keys = %w[password] }
114
114
  end
115
115
  end
116
116
 
117
- context "when whitelist_keys gets configured" do
117
+ context "when allowlist_keys gets configured" do
118
118
  before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
119
119
 
120
- it "adds whitelist filter" do
120
+ it "adds allowlist filter" do
121
121
  expect(Airbrake.notice_notifier).to receive(:add_filter)
122
- .with(an_instance_of(Airbrake::Filters::KeysWhitelist))
123
- described_class.configure { |c| c.whitelist_keys = %w[banana] }
122
+ .with(an_instance_of(Airbrake::Filters::KeysAllowlist))
123
+ described_class.configure { |c| c.allowlist_keys = %w[banana] }
124
124
  end
125
125
 
126
- it "initializes whitelist with specified parameters" do
127
- expect(Airbrake::Filters::KeysWhitelist).to receive(:new).with(%w[banana])
128
- described_class.configure { |c| c.whitelist_keys = %w[banana] }
126
+ it "initializes allowlist with specified parameters" do
127
+ expect(Airbrake::Filters::KeysAllowlist).to receive(:new).with(%w[banana])
128
+ described_class.configure { |c| c.allowlist_keys = %w[banana] }
129
129
  end
130
130
  end
131
131
 
@@ -17,8 +17,8 @@ RSpec.describe Airbrake::Config do
17
17
  its(:environment) { is_expected.to be_nil }
18
18
  its(:ignore_environments) { is_expected.to be_empty }
19
19
  its(:timeout) { is_expected.to be_nil }
20
- its(:blacklist_keys) { is_expected.to be_empty }
21
- its(:whitelist_keys) { is_expected.to be_empty }
20
+ its(:blocklist_keys) { is_expected.to be_empty }
21
+ its(:allowlist_keys) { is_expected.to be_empty }
22
22
  its(:performance_stats) { is_expected.to eq(true) }
23
23
  its(:performance_stats_flush_period) { is_expected.to eq(15) }
24
24
  its(:query_stats) { is_expected.to eq(true) }
@@ -169,4 +169,32 @@ RSpec.describe Airbrake::Config do
169
169
  expect(subject.logger.level).to eq(Logger::WARN)
170
170
  end
171
171
  end
172
+
173
+ describe "#blacklist_keys=" do
174
+ before { allow(Kernel).to receive(:warn) }
175
+
176
+ it "sets blocklist_keys instead" do
177
+ subject.blacklist_keys = [1, 2, 3]
178
+ expect(subject.blocklist_keys).to eq([1, 2, 3])
179
+ end
180
+
181
+ it "prints a warning" do
182
+ expect(Kernel).to receive(:warn).with(/use blocklist_keys= instead/)
183
+ subject.blacklist_keys = [1, 2, 3]
184
+ end
185
+ end
186
+
187
+ describe "#whitelist_keys=" do
188
+ before { allow(Kernel).to receive(:warn) }
189
+
190
+ it "sets allowlist_keys instead" do
191
+ subject.whitelist_keys = [1, 2, 3]
192
+ expect(subject.allowlist_keys).to eq([1, 2, 3])
193
+ end
194
+
195
+ it "prints a warning" do
196
+ expect(Kernel).to receive(:warn).with(/use allowlist_keys= instead/)
197
+ subject.whitelist_keys = [1, 2, 3]
198
+ end
199
+ end
172
200
  end
@@ -1,4 +1,4 @@
1
- RSpec.describe Airbrake::Filters::KeysWhitelist do
1
+ RSpec.describe Airbrake::Filters::KeysAllowlist do
2
2
  subject { described_class.new(patterns) }
3
3
 
4
4
  let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
@@ -70,10 +70,10 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
70
70
 
71
71
  it "logs an error" do
72
72
  expect(Airbrake::Loggable.instance).to receive(:error).with(
73
- /KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/,
73
+ /KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
74
74
  )
75
- keys_whitelist = described_class.new(patterns)
76
- keys_whitelist.call(notice)
75
+ keys_allowlist = described_class.new(patterns)
76
+ keys_allowlist.call(notice)
77
77
  end
78
78
  end
79
79
 
@@ -83,10 +83,10 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
83
83
  context "and when the filter is called once" do
84
84
  it "logs an error" do
85
85
  expect(Airbrake::Loggable.instance).to receive(:error).with(
86
- /KeysWhitelist is invalid.+patterns: \[#<Proc:.+>\]/,
86
+ /KeysAllowlist is invalid.+patterns: \[#<Proc:.+>\]/,
87
87
  )
88
- keys_whitelist = described_class.new(patterns)
89
- keys_whitelist.call(notice)
88
+ keys_allowlist = described_class.new(patterns)
89
+ keys_allowlist.call(notice)
90
90
  end
91
91
 
92
92
  include_examples(
@@ -113,10 +113,10 @@ RSpec.describe Airbrake::Filters::KeysWhitelist do
113
113
 
114
114
  it "logs an error" do
115
115
  expect(Airbrake::Loggable.instance).to receive(:error).with(
116
- /KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/,
116
+ /KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
117
117
  )
118
- keys_whitelist = described_class.new(patterns)
119
- keys_whitelist.call(notice)
118
+ keys_allowlist = described_class.new(patterns)
119
+ keys_allowlist.call(notice)
120
120
  end
121
121
  end
122
122
 
@@ -1,4 +1,4 @@
1
- RSpec.describe Airbrake::Filters::KeysBlacklist do
1
+ RSpec.describe Airbrake::Filters::KeysBlocklist do
2
2
  subject { described_class.new(patterns) }
3
3
 
4
4
  let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
@@ -91,10 +91,10 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
91
91
 
92
92
  it "logs an error" do
93
93
  expect(Airbrake::Loggable.instance).to receive(:error).with(
94
- /KeysBlacklist is invalid.+patterns: \[#<Object:.+>\]/,
94
+ /KeysBlocklist is invalid.+patterns: \[#<Object:.+>\]/,
95
95
  )
96
- keys_blacklist = described_class.new(patterns)
97
- keys_blacklist.call(notice)
96
+ keys_blocklist = described_class.new(patterns)
97
+ keys_blocklist.call(notice)
98
98
  end
99
99
  end
100
100
 
@@ -104,10 +104,10 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
104
104
  context "and when the filter is called once" do
105
105
  it "logs an error" do
106
106
  expect(Airbrake::Loggable.instance).to receive(:error).with(
107
- /KeysBlacklist is invalid.+patterns: \[#<Proc:.+>\]/,
107
+ /KeysBlocklist is invalid.+patterns: \[#<Proc:.+>\]/,
108
108
  )
109
- keys_blacklist = described_class.new(patterns)
110
- keys_blacklist.call(notice)
109
+ keys_blocklist = described_class.new(patterns)
110
+ keys_blocklist.call(notice)
111
111
  end
112
112
  end
113
113
 
@@ -133,10 +133,10 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
133
133
 
134
134
  it "logs an error" do
135
135
  expect(Airbrake::Loggable.instance).to receive(:error).with(
136
- /KeysBlacklist is invalid.+patterns: \[#<Object:.+>\]/,
136
+ /KeysBlocklist is invalid.+patterns: \[#<Object:.+>\]/,
137
137
  )
138
- keys_blacklist = described_class.new(patterns)
139
- keys_blacklist.call(notice)
138
+ keys_blocklist = described_class.new(patterns)
139
+ keys_blocklist.call(notice)
140
140
  end
141
141
  end
142
142
 
@@ -10,7 +10,7 @@ RSpec.describe Airbrake::Filters::SqlFilter do
10
10
  end
11
11
  end
12
12
 
13
- shared_examples "query blacklisting" do |query, opts|
13
+ shared_examples "query blocklisting" do |query, opts|
14
14
  it "ignores '#{query}'" do
15
15
  filter = described_class.new('postgres')
16
16
  q = Airbrake::Query.new(query: query, method: 'GET', route: '/', timing: 1)
@@ -263,12 +263,12 @@ RSpec.describe Airbrake::Filters::SqlFilter do
263
263
 
264
264
  'SELECT t.oid, t.typname FROM pg_type as t WHERE t.typname IN (?)',
265
265
  ].each do |query|
266
- include_examples 'query blacklisting', query, should_ignore: true
266
+ include_examples 'query blocklisting', query, should_ignore: true
267
267
  end
268
268
 
269
269
  [
270
270
  'UPDATE "users" SET "last_sign_in_at" = ? WHERE "users"."id" = ?',
271
271
  ].each do |query|
272
- include_examples 'query blacklisting', query, should_ignore: false
272
+ include_examples 'query blocklisting', query, should_ignore: false
273
273
  end
274
274
  end
@@ -234,14 +234,14 @@ RSpec.describe Airbrake::NoticeNotifier do
234
234
  end
235
235
  end
236
236
 
237
- describe ":blacklist_keys" do
237
+ describe ":blocklist_keys" do
238
238
  # Fixes https://github.com/airbrake/airbrake-ruby/issues/276
239
- context "when specified along with :whitelist_keys" do
239
+ context "when specified along with :allowlist_keys" do
240
240
  context "and when context payload is present" do
241
241
  before do
242
242
  Airbrake::Config.instance.merge(
243
- blacklist_keys: %i[password password_confirmation],
244
- whitelist_keys: [:email, /user/i, 'account_id'],
243
+ blocklist_keys: %i[password password_confirmation],
244
+ allowlist_keys: [:email, /user/i, 'account_id'],
245
245
  )
246
246
  end
247
247
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.14.1
4
+ version: 4.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3
@@ -55,9 +55,9 @@ files:
55
55
  - lib/airbrake-ruby/filters/git_last_checkout_filter.rb
56
56
  - lib/airbrake-ruby/filters/git_repository_filter.rb
57
57
  - lib/airbrake-ruby/filters/git_revision_filter.rb
58
- - lib/airbrake-ruby/filters/keys_blacklist.rb
58
+ - lib/airbrake-ruby/filters/keys_allowlist.rb
59
+ - lib/airbrake-ruby/filters/keys_blocklist.rb
59
60
  - lib/airbrake-ruby/filters/keys_filter.rb
60
- - lib/airbrake-ruby/filters/keys_whitelist.rb
61
61
  - lib/airbrake-ruby/filters/root_directory_filter.rb
62
62
  - lib/airbrake-ruby/filters/sql_filter.rb
63
63
  - lib/airbrake-ruby/filters/system_exit_filter.rb
@@ -105,8 +105,8 @@ files:
105
105
  - spec/filters/git_last_checkout_filter_spec.rb
106
106
  - spec/filters/git_repository_filter.rb
107
107
  - spec/filters/git_revision_filter_spec.rb
108
- - spec/filters/keys_blacklist_spec.rb
109
- - spec/filters/keys_whitelist_spec.rb
108
+ - spec/filters/keys_allowlist_spec.rb
109
+ - spec/filters/keys_blocklist_spec.rb
110
110
  - spec/filters/root_directory_filter_spec.rb
111
111
  - spec/filters/sql_filter_spec.rb
112
112
  - spec/filters/system_exit_filter_spec.rb
@@ -172,14 +172,14 @@ test_files:
172
172
  - spec/filters/exception_attributes_filter_spec.rb
173
173
  - spec/filters/root_directory_filter_spec.rb
174
174
  - spec/filters/sql_filter_spec.rb
175
- - spec/filters/keys_whitelist_spec.rb
176
175
  - spec/filters/system_exit_filter_spec.rb
177
176
  - spec/filters/thread_filter_spec.rb
177
+ - spec/filters/keys_allowlist_spec.rb
178
178
  - spec/filters/dependency_filter_spec.rb
179
179
  - spec/filters/context_filter_spec.rb
180
180
  - spec/filters/git_last_checkout_filter_spec.rb
181
181
  - spec/filters/git_revision_filter_spec.rb
182
- - spec/filters/keys_blacklist_spec.rb
182
+ - spec/filters/keys_blocklist_spec.rb
183
183
  - spec/filters/gem_root_filter_spec.rb
184
184
  - spec/filters/git_repository_filter.rb
185
185
  - spec/spec_helper.rb