airbrake-ruby 4.13.2-java → 4.15.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby.rb +12 -8
- data/lib/airbrake-ruby/config.rb +31 -7
- data/lib/airbrake-ruby/filter_chain.rb +15 -1
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +2 -1
- data/lib/airbrake-ruby/filters/{keys_whitelist.rb → keys_allowlist.rb} +3 -3
- data/lib/airbrake-ruby/filters/{keys_blacklist.rb → keys_blocklist.rb} +3 -3
- data/lib/airbrake-ruby/filters/keys_filter.rb +17 -6
- data/lib/airbrake-ruby/notice_notifier.rb +6 -0
- data/lib/airbrake-ruby/stat.rb +15 -10
- data/lib/airbrake-ruby/thread_pool.rb +1 -0
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/airbrake_spec.rb +36 -14
- data/spec/config_spec.rb +30 -2
- data/spec/filter_chain_spec.rb +27 -0
- data/spec/filters/git_last_checkout_filter_spec.rb +20 -3
- data/spec/filters/{keys_whitelist_spec.rb → keys_allowlist_spec.rb} +10 -10
- data/spec/filters/{keys_blacklist_spec.rb → keys_blocklist_spec.rb} +10 -10
- data/spec/filters/sql_filter_spec.rb +3 -3
- data/spec/notice_notifier/options_spec.rb +4 -4
- data/spec/performance_notifier_spec.rb +2 -2
- data/spec/thread_pool_spec.rb +25 -5
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5dd62f478034e980ccfbc26b0eb53c7696a81f784a0b50643693b7f0d55548
|
4
|
+
data.tar.gz: 653ff8929bc7199a77c59ead004167a38d214741157282d93e947c3d5ca8ecd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f264aa26bed243459d9f5c9eb8827d24ae05d1f9d5cd03416b4e10612e4df1782b2e6ef3cc170db523798e594e1d7d1765a3e9d59fbf81b7955729db9f16cf5
|
7
|
+
data.tar.gz: 3c3b2312b7945685c6199ecd21f23601b752e1d4234d35461db2f4c7cf0318c24ee263df2536e9cffb7e107002a5a5be10af1cf7eecc16ac65e07cd948f2c68e
|
data/lib/airbrake-ruby.rb
CHANGED
@@ -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/
|
28
|
-
require 'airbrake-ruby/filters/
|
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.
|
575
|
-
|
576
|
-
notice_notifier.add_filter(
|
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.
|
580
|
-
|
581
|
-
notice_notifier.add_filter(
|
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
|
data/lib/airbrake-ruby/config.rb
CHANGED
@@ -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
|
72
|
-
attr_accessor :
|
71
|
+
# @since v4.15.0
|
72
|
+
attr_accessor :allowlist_keys
|
73
73
|
|
74
|
-
# @
|
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
|
78
|
-
attr_accessor :
|
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.
|
138
|
-
self.
|
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
|
-
|
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::
|
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
|
25
|
+
# @see KeysBlocklist
|
26
26
|
# @see KeysFilter
|
27
|
-
class
|
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::
|
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
|
25
|
+
# @see KeysAllowlist
|
26
26
|
# @see KeysFilter
|
27
27
|
# @api private
|
28
|
-
class
|
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
|
11
|
-
# @see
|
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
|
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
|
27
|
-
FILTERABLE_CONTEXT_KEYS = %i[
|
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
|
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)
|
data/lib/airbrake-ruby/stat.rb
CHANGED
@@ -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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
58
|
-
|
60
|
+
@mutex.synchronize do
|
61
|
+
self.sum += ms
|
62
|
+
self.sumsq += ms * ms
|
59
63
|
|
60
|
-
|
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
|
data/spec/airbrake_spec.rb
CHANGED
@@ -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
|
102
|
+
context "when blocklist_keys gets configured" do
|
81
103
|
before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
|
82
104
|
|
83
|
-
it "adds
|
105
|
+
it "adds blocklist filter" do
|
84
106
|
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
85
|
-
.with(an_instance_of(Airbrake::Filters::
|
86
|
-
described_class.configure { |c| c.
|
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
|
90
|
-
expect(Airbrake::Filters::
|
91
|
-
described_class.configure { |c| c.
|
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
|
117
|
+
context "when allowlist_keys gets configured" do
|
96
118
|
before { allow(Airbrake.notice_notifier).to receive(:add_filter) }
|
97
119
|
|
98
|
-
it "adds
|
120
|
+
it "adds allowlist filter" do
|
99
121
|
expect(Airbrake.notice_notifier).to receive(:add_filter)
|
100
|
-
.with(an_instance_of(Airbrake::Filters::
|
101
|
-
described_class.configure { |c| c.
|
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
|
105
|
-
expect(Airbrake::Filters::
|
106
|
-
described_class.configure { |c| c.
|
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
|
|
data/spec/config_spec.rb
CHANGED
@@ -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(:
|
21
|
-
its(:
|
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
|
data/spec/filter_chain_spec.rb
CHANGED
@@ -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
|
-
|
24
|
+
context "when AIRBRAKE_DEPLOY_USERNAME env variable is set" do
|
25
|
+
before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = 'deployer' }
|
25
26
|
|
26
|
-
|
27
|
-
|
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::
|
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
|
-
/
|
73
|
+
/KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
|
74
74
|
)
|
75
|
-
|
76
|
-
|
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
|
-
/
|
86
|
+
/KeysAllowlist is invalid.+patterns: \[#<Proc:.+>\]/,
|
87
87
|
)
|
88
|
-
|
89
|
-
|
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
|
-
/
|
116
|
+
/KeysAllowlist is invalid.+patterns: \[#<Object:.+>\]/,
|
117
117
|
)
|
118
|
-
|
119
|
-
|
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::
|
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
|
-
/
|
94
|
+
/KeysBlocklist is invalid.+patterns: \[#<Object:.+>\]/,
|
95
95
|
)
|
96
|
-
|
97
|
-
|
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
|
-
/
|
107
|
+
/KeysBlocklist is invalid.+patterns: \[#<Proc:.+>\]/,
|
108
108
|
)
|
109
|
-
|
110
|
-
|
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
|
-
/
|
136
|
+
/KeysBlocklist is invalid.+patterns: \[#<Object:.+>\]/,
|
137
137
|
)
|
138
|
-
|
139
|
-
|
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
|
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
|
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
|
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 ":
|
237
|
+
describe ":blocklist_keys" do
|
238
238
|
# Fixes https://github.com/airbrake/airbrake-ruby/issues/276
|
239
|
-
context "when specified along with :
|
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
|
-
|
244
|
-
|
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('' =>
|
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('' =>
|
604
|
+
expect(retval).to eq('' => '')
|
605
605
|
end
|
606
606
|
end
|
607
607
|
|
data/spec/thread_pool_spec.rb
CHANGED
@@ -85,11 +85,31 @@ RSpec.describe Airbrake::ThreadPool do
|
|
85
85
|
expect(subject).not_to have_workers
|
86
86
|
end
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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.
|
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-
|
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/
|
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/
|
109
|
-
- spec/filters/
|
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
|
-
|
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/
|
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
|