airbrake-ruby 4.13.2-java → 4.15.0-java

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: 8d2c5667a0276760d3b310122a798f99a8bbdde299048cab9e36de60939794ed
4
- data.tar.gz: a5b264fb9ac50c258bd7f239af074b20b8bd1515a9a94241f98c602d700d5255
3
+ metadata.gz: ae5dd62f478034e980ccfbc26b0eb53c7696a81f784a0b50643693b7f0d55548
4
+ data.tar.gz: 653ff8929bc7199a77c59ead004167a38d214741157282d93e947c3d5ca8ecd6
5
5
  SHA512:
6
- metadata.gz: bea1b4da4930c3c1a700d016c64e6484bc4213f09950ba13434da8035979fed165f664d52c610ffbf31b6e35a2a6133e165a4244a6c0f17c4364b0ba37f6f28c
7
- data.tar.gz: 39b6d21b0007e6e14f31903a82d8871f45a47a6d27ecef6df65cff7ba6db95ae2b4e81a8bb84e227b2f65cf7ed2cc6fe06bf1b3c2dc880f3423232a25d39224a
6
+ metadata.gz: 4f264aa26bed243459d9f5c9eb8827d24ae05d1f9d5cd03416b4e10612e4df1782b2e6ef3cc170db523798e594e1d7d1765a3e9d59fbf81b7955729db9f16cf5
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'
@@ -570,15 +570,16 @@ module Airbrake
570
570
 
571
571
  private
572
572
 
573
+ # rubocop:disable Metrics/AbcSize
573
574
  def process_config_options(config)
574
- if config.blacklist_keys.any?
575
- blacklist = Airbrake::Filters::KeysBlacklist.new(config.blacklist_keys)
576
- 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)
577
578
  end
578
579
 
579
- if config.whitelist_keys.any?
580
- whitelist = Airbrake::Filters::KeysWhitelist.new(config.whitelist_keys)
581
- 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)
582
583
  end
583
584
 
584
585
  return unless config.root_directory
@@ -589,9 +590,12 @@ module Airbrake
589
590
  Airbrake::Filters::GitRepositoryFilter,
590
591
  Airbrake::Filters::GitLastCheckoutFilter,
591
592
  ].each do |filter|
593
+ next if notice_notifier.has_filter?(filter)
594
+
592
595
  notice_notifier.add_filter(filter.new(config.root_directory))
593
596
  end
594
597
  end
598
+ # rubocop:enable Metrics/AbcSize
595
599
  end
596
600
  end
597
601
  # rubocop:enable Metrics/ModuleLength
@@ -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
@@ -76,7 +76,7 @@ module Airbrake
76
76
 
77
77
  # @return [String] customized inspect to lessen the amount of clutter
78
78
  def inspect
79
- @filters.map(&:class).to_s
79
+ filter_classes.to_s
80
80
  end
81
81
 
82
82
  # @return [String] {#inspect} for PrettyPrint
@@ -91,5 +91,19 @@ module Airbrake
91
91
  end
92
92
  q.text(']')
93
93
  end
94
+
95
+ # @param [Class] filter_class
96
+ # @return [Boolean] true if the current chain has an instance of the given
97
+ # class, false otherwise
98
+ # @since v4.14.0
99
+ def includes?(filter_class)
100
+ filter_classes.include?(filter_class)
101
+ end
102
+
103
+ private
104
+
105
+ def filter_classes
106
+ @filters.map(&:class)
107
+ end
94
108
  end
95
109
  end
@@ -27,6 +27,7 @@ module Airbrake
27
27
  @git_path = File.join(root_directory, '.git')
28
28
  @weight = 116
29
29
  @last_checkout = nil
30
+ @deploy_username = ENV['AIRBRAKE_DEPLOY_USERNAME']
30
31
  end
31
32
 
32
33
  # @macro call_filter
@@ -59,7 +60,7 @@ module Airbrake
59
60
 
60
61
  author = parts[2..-4]
61
62
  @last_checkout = {
62
- username: author[0..1].join(' '),
63
+ username: @deploy_username || author[0..1].join(' '),
63
64
  email: parts[-3][1..-2],
64
65
  revision: parts[1],
65
66
  time: timestamp(parts[-2].to_i),
@@ -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,19 +19,30 @@ 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
27
- FILTERABLE_CONTEXT_KEYS = %i[user headers].freeze
26
+ # be modified by blocklist/allowlist filters
27
+ FILTERABLE_CONTEXT_KEYS = %i[
28
+ user
29
+
30
+ # Provided by Airbrake::Rack::HttpHeadersFilter
31
+ headers
32
+ referer
33
+ httpMethod
34
+
35
+ # Provided by Airbrake::Rack::ContextFilter
36
+ userAddr
37
+ userAgent
38
+ ].freeze
28
39
 
29
40
  include Loggable
30
41
 
31
42
  # @return [Integer]
32
43
  attr_reader :weight
33
44
 
34
- # Creates a new KeysBlacklist or KeysWhitelist filter that uses the given
45
+ # Creates a new KeysBlocklist or KeysAllowlist filter that uses the given
35
46
  # +patterns+ for filtering a notice's payload.
36
47
  #
37
48
  # @param [Array<String,Regexp,Symbol>] patterns
@@ -82,6 +82,12 @@ module Airbrake
82
82
  @context.merge!(context)
83
83
  end
84
84
 
85
+ # @return [Boolean]
86
+ # @since v4.14.0
87
+ def has_filter?(filter_class) # rubocop:disable Naming/PredicateName
88
+ @filter_chain.includes?(filter_class)
89
+ end
90
+
85
91
  private
86
92
 
87
93
  def convert_to_exception(ex)
@@ -24,18 +24,21 @@ module Airbrake
24
24
  @sum = sum
25
25
  @sumsq = sumsq
26
26
  @tdigest = tdigest
27
+ @mutex = Mutex.new
27
28
  end
28
29
 
29
30
  # @return [Hash{String=>Object}] stats as a hash with compressed TDigest
30
31
  # (serialized as base64)
31
32
  def to_h
32
- tdigest.compress!
33
- {
34
- 'count' => tdigest.size,
35
- 'sum' => sum,
36
- 'sumsq' => sumsq,
37
- 'tdigest' => Base64.strict_encode64(tdigest.as_small_bytes),
38
- }
33
+ @mutex.synchronize do
34
+ tdigest.compress!
35
+ {
36
+ 'count' => tdigest.size,
37
+ 'sum' => sum,
38
+ 'sumsq' => sumsq,
39
+ 'tdigest' => Base64.strict_encode64(tdigest.as_small_bytes),
40
+ }
41
+ end
39
42
  end
40
43
 
41
44
  # Increments tdigest timings and updates tdigest with the difference between
@@ -54,10 +57,12 @@ module Airbrake
54
57
  # @param [Float] ms
55
58
  # @return [void]
56
59
  def increment_ms(ms)
57
- self.sum += ms
58
- self.sumsq += ms * ms
60
+ @mutex.synchronize do
61
+ self.sum += ms
62
+ self.sumsq += ms * ms
59
63
 
60
- tdigest.push(ms)
64
+ tdigest.push(ms)
65
+ end
61
66
  end
62
67
 
63
68
  # We define custom inspect so that we weed out uninformative TDigest, which
@@ -83,6 +83,7 @@ module Airbrake
83
83
 
84
84
  if @pid != Process.pid && @workers.list.empty?
85
85
  @pid = Process.pid
86
+ @workers = ThreadGroup.new
86
87
  spawn_workers
87
88
  end
88
89
 
@@ -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.13.2'.freeze
5
+ AIRBRAKE_RUBY_VERSION = '4.15.0'.freeze
6
6
  end
@@ -75,35 +75,57 @@ RSpec.describe Airbrake do
75
75
  described_class.configure {}
76
76
  expect(described_class.deploy_notifier).to eql(deploy_notifier)
77
77
  end
78
+
79
+ it "doesn't append the same notice notifier filters over and over" do
80
+ described_class.configure do |c|
81
+ c.project_id = 1
82
+ c.project_key = '2'
83
+ end
84
+
85
+ expect(described_class.notice_notifier).not_to receive(:add_filter)
86
+ 10.times { described_class.configure {} }
87
+ end
88
+
89
+ it "appends some default filters" do
90
+ allow(described_class.notice_notifier).to receive(:add_filter)
91
+ expect(described_class.notice_notifier).to receive(:add_filter).with(
92
+ an_instance_of(Airbrake::Filters::RootDirectoryFilter),
93
+ )
94
+
95
+ described_class.configure do |c|
96
+ c.project_id = 1
97
+ c.project_key = '2'
98
+ end
99
+ end
78
100
  end
79
101
 
80
- context "when blacklist_keys gets configured" do
102
+ context "when blocklist_keys gets configured" do
81
103
  before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
82
104
 
83
- it "adds blacklist filter" do
105
+ it "adds blocklist filter" do
84
106
  expect(Airbrake.notice_notifier).to receive(:add_filter)
85
- .with(an_instance_of(Airbrake::Filters::KeysBlacklist))
86
- 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] }
87
109
  end
88
110
 
89
- it "initializes blacklist with specified parameters" do
90
- expect(Airbrake::Filters::KeysBlacklist).to receive(:new).with(%w[password])
91
- 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] }
92
114
  end
93
115
  end
94
116
 
95
- context "when whitelist_keys gets configured" do
117
+ context "when allowlist_keys gets configured" do
96
118
  before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
97
119
 
98
- it "adds whitelist filter" do
120
+ it "adds allowlist filter" do
99
121
  expect(Airbrake.notice_notifier).to receive(:add_filter)
100
- .with(an_instance_of(Airbrake::Filters::KeysWhitelist))
101
- 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] }
102
124
  end
103
125
 
104
- it "initializes whitelist with specified parameters" do
105
- expect(Airbrake::Filters::KeysWhitelist).to receive(:new).with(%w[banana])
106
- 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] }
107
129
  end
108
130
  end
109
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
@@ -89,4 +89,31 @@ RSpec.describe Airbrake::FilterChain do
89
89
  expect(subject.inspect).to eq('[Proc]')
90
90
  end
91
91
  end
92
+
93
+ describe "#includes?" do
94
+ context "when a custom filter class is included in the filter chain" do
95
+ it "returns true" do
96
+ klass = Class.new {}
97
+
98
+ subject.add_filter(klass.new)
99
+ expect(subject.includes?(klass)).to eq(true)
100
+ end
101
+ end
102
+
103
+ context "when Proc filter class is included in the filter chain" do
104
+ it "returns true" do
105
+ subject.add_filter(proc {})
106
+ expect(subject.includes?(Proc)).to eq(true)
107
+ end
108
+ end
109
+
110
+ context "when filter class is NOT included in the filter chain" do
111
+ it "returns false" do
112
+ klass = Class.new {}
113
+
114
+ subject.add_filter(proc {})
115
+ expect(subject.includes?(klass)).to eq(false)
116
+ end
117
+ end
118
+ end
92
119
  end
@@ -21,24 +21,41 @@ RSpec.describe Airbrake::Filters::GitLastCheckoutFilter do
21
21
  end
22
22
 
23
23
  context "when .git directory exists" do
24
- before { subject.call(notice) }
24
+ context "when AIRBRAKE_DEPLOY_USERNAME env variable is set" do
25
+ before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = 'deployer' }
25
26
 
26
- it "attaches last checkouted username" do
27
- expect(notice[:context][:lastCheckout][:username]).not_to be_empty
27
+ it "attaches username from the environment" do
28
+ subject.call(notice)
29
+ expect(notice[:context][:lastCheckout][:username]).to eq('deployer')
30
+ end
31
+ end
32
+
33
+ context "when AIRBRAKE_DEPLOY_USERNAME env variable is NOT set" do
34
+ before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = nil }
35
+
36
+ it "attaches last checkouted username" do
37
+ subject.call(notice)
38
+ username = notice[:context][:lastCheckout][:username]
39
+ expect(username).not_to be_empty
40
+ expect(username).not_to be_nil
41
+ end
28
42
  end
29
43
 
30
44
  it "attaches last checkouted email" do
45
+ subject.call(notice)
31
46
  expect(notice[:context][:lastCheckout][:email]).to(
32
47
  match(/\A\w+[\w.-]*@\w+\.?\w+?\z/),
33
48
  )
34
49
  end
35
50
 
36
51
  it "attaches last checkouted revision" do
52
+ subject.call(notice)
37
53
  expect(notice[:context][:lastCheckout][:revision]).not_to be_empty
38
54
  expect(notice[:context][:lastCheckout][:revision].size).to eq(40)
39
55
  end
40
56
 
41
57
  it "attaches last checkouted time" do
58
+ subject.call(notice)
42
59
  expect(notice[:context][:lastCheckout][:time]).not_to be_empty
43
60
  expect(notice[:context][:lastCheckout][:time].size).to eq(25)
44
61
  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
 
@@ -389,7 +389,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
389
389
  subject.close
390
390
 
391
391
  expect(promise).to be_an(Airbrake::Promise)
392
- expect(promise.value).to eq('' => nil)
392
+ expect(promise.value).to eq('' => '')
393
393
  end
394
394
 
395
395
  it "checks performance stat configuration" do
@@ -601,7 +601,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
601
601
  body: %r|\A{"queries":\[{"method":"POST","route":"/foo"|,
602
602
  ),
603
603
  ).to have_been_made
604
- expect(retval).to eq('' => nil)
604
+ expect(retval).to eq('' => '')
605
605
  end
606
606
  end
607
607
 
@@ -85,11 +85,31 @@ RSpec.describe Airbrake::ThreadPool do
85
85
  expect(subject).not_to have_workers
86
86
  end
87
87
 
88
- it "respawns workers on fork()", skip: %w[jruby].include?(RUBY_ENGINE) do
89
- pid = fork { expect(subject).to have_workers }
90
- Process.wait(pid)
91
- subject.close
92
- expect(subject).not_to have_workers
88
+ describe "forking behavior" do
89
+ before do
90
+ skip('fork() is unsupported on JRuby') if %w[jruby].include?(RUBY_ENGINE)
91
+ unless Process.respond_to?(:last_status)
92
+ skip('Process.last_status is unsupported on this Ruby')
93
+ end
94
+ end
95
+
96
+ it "respawns workers on fork()" do
97
+ pid = fork { expect(subject).to have_workers }
98
+ Process.wait(pid)
99
+ subject.close
100
+
101
+ expect(Process.last_status).to be_success
102
+ expect(subject).not_to have_workers
103
+ end
104
+
105
+ it "ensures that a new thread group is created per process" do
106
+ subject << 1
107
+ pid = fork { subject.has_workers? }
108
+ Process.wait(pid)
109
+ subject.close
110
+
111
+ expect(Process.last_status).to be_success
112
+ end
93
113
  end
94
114
  end
95
115
 
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.13.2
4
+ version: 4.15.0
5
5
  platform: java
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-21 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: rbtree-jruby
@@ -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
@@ -161,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.7.6.2
164
+ rubygems_version: 3.1.2
166
165
  signing_key:
167
166
  specification_version: 4
168
167
  summary: Ruby notifier for https://airbrake.io
@@ -173,14 +172,14 @@ test_files:
173
172
  - spec/filters/exception_attributes_filter_spec.rb
174
173
  - spec/filters/root_directory_filter_spec.rb
175
174
  - spec/filters/sql_filter_spec.rb
176
- - spec/filters/keys_whitelist_spec.rb
177
175
  - spec/filters/system_exit_filter_spec.rb
178
176
  - spec/filters/thread_filter_spec.rb
177
+ - spec/filters/keys_allowlist_spec.rb
179
178
  - spec/filters/dependency_filter_spec.rb
180
179
  - spec/filters/context_filter_spec.rb
181
180
  - spec/filters/git_last_checkout_filter_spec.rb
182
181
  - spec/filters/git_revision_filter_spec.rb
183
- - spec/filters/keys_blacklist_spec.rb
182
+ - spec/filters/keys_blocklist_spec.rb
184
183
  - spec/filters/gem_root_filter_spec.rb
185
184
  - spec/filters/git_repository_filter.rb
186
185
  - spec/spec_helper.rb