airbrake-ruby 4.6.0 → 6.2.2
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 +5 -5
- data/lib/airbrake-ruby/async_sender.rb +24 -109
- data/lib/airbrake-ruby/backlog.rb +123 -0
- data/lib/airbrake-ruby/backtrace.rb +8 -7
- data/lib/airbrake-ruby/benchmark.rb +1 -1
- data/lib/airbrake-ruby/code_hunk.rb +1 -1
- data/lib/airbrake-ruby/config/processor.rb +77 -0
- data/lib/airbrake-ruby/config/validator.rb +9 -3
- data/lib/airbrake-ruby/config.rb +78 -19
- data/lib/airbrake-ruby/context.rb +51 -0
- data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
- data/lib/airbrake-ruby/file_cache.rb +6 -0
- data/lib/airbrake-ruby/filter_chain.rb +18 -1
- data/lib/airbrake-ruby/filters/context_filter.rb +4 -5
- data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +3 -3
- data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +7 -7
- data/lib/airbrake-ruby/filters/git_repository_filter.rb +11 -2
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +3 -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 +41 -22
- data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/sql_filter.rb +35 -11
- data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/thread_filter.rb +6 -5
- data/lib/airbrake-ruby/grouppable.rb +12 -0
- data/lib/airbrake-ruby/ignorable.rb +1 -2
- data/lib/airbrake-ruby/inspectable.rb +2 -2
- data/lib/airbrake-ruby/loggable.rb +1 -1
- data/lib/airbrake-ruby/mergeable.rb +12 -0
- data/lib/airbrake-ruby/monotonic_time.rb +6 -1
- data/lib/airbrake-ruby/nested_exception.rb +22 -1
- data/lib/airbrake-ruby/notice.rb +12 -17
- data/lib/airbrake-ruby/notice_notifier.rb +15 -7
- data/lib/airbrake-ruby/performance_breakdown.rb +16 -9
- data/lib/airbrake-ruby/performance_notifier.rb +106 -54
- data/lib/airbrake-ruby/promise.rb +1 -0
- data/lib/airbrake-ruby/query.rb +20 -14
- data/lib/airbrake-ruby/queue.rb +65 -0
- data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
- data/lib/airbrake-ruby/remote_settings/settings_data.rb +116 -0
- data/lib/airbrake-ruby/remote_settings.rb +128 -0
- data/lib/airbrake-ruby/request.rb +14 -11
- data/lib/airbrake-ruby/response.rb +56 -5
- data/lib/airbrake-ruby/stat.rb +27 -34
- data/lib/airbrake-ruby/sync_sender.rb +43 -11
- data/lib/airbrake-ruby/tdigest.rb +52 -66
- data/lib/airbrake-ruby/thread_pool.rb +139 -0
- data/lib/airbrake-ruby/time_truncate.rb +2 -2
- data/lib/airbrake-ruby/timed_trace.rb +1 -3
- data/lib/airbrake-ruby/truncator.rb +10 -4
- data/lib/airbrake-ruby/version.rb +11 -1
- data/lib/airbrake-ruby.rb +157 -78
- metadata +122 -116
- data/spec/airbrake_spec.rb +0 -324
- data/spec/async_sender_spec.rb +0 -155
- data/spec/backtrace_spec.rb +0 -427
- data/spec/benchmark_spec.rb +0 -33
- data/spec/code_hunk_spec.rb +0 -115
- data/spec/config/validator_spec.rb +0 -184
- data/spec/config_spec.rb +0 -154
- data/spec/deploy_notifier_spec.rb +0 -48
- data/spec/file_cache.rb +0 -36
- data/spec/filter_chain_spec.rb +0 -92
- data/spec/filters/context_filter_spec.rb +0 -23
- data/spec/filters/dependency_filter_spec.rb +0 -12
- data/spec/filters/exception_attributes_filter_spec.rb +0 -50
- data/spec/filters/gem_root_filter_spec.rb +0 -41
- data/spec/filters/git_last_checkout_filter_spec.rb +0 -46
- data/spec/filters/git_repository_filter.rb +0 -61
- data/spec/filters/git_revision_filter_spec.rb +0 -126
- data/spec/filters/keys_blacklist_spec.rb +0 -225
- data/spec/filters/keys_whitelist_spec.rb +0 -194
- data/spec/filters/root_directory_filter_spec.rb +0 -39
- data/spec/filters/sql_filter_spec.rb +0 -219
- data/spec/filters/system_exit_filter_spec.rb +0 -14
- data/spec/filters/thread_filter_spec.rb +0 -277
- data/spec/fixtures/notroot.txt +0 -7
- data/spec/fixtures/project_root/code.rb +0 -221
- data/spec/fixtures/project_root/empty_file.rb +0 -0
- data/spec/fixtures/project_root/long_line.txt +0 -1
- data/spec/fixtures/project_root/short_file.rb +0 -3
- data/spec/fixtures/project_root/vendor/bundle/ignored_file.rb +0 -5
- data/spec/helpers.rb +0 -9
- data/spec/ignorable_spec.rb +0 -14
- data/spec/inspectable_spec.rb +0 -45
- data/spec/monotonic_time_spec.rb +0 -12
- data/spec/nested_exception_spec.rb +0 -73
- data/spec/notice_notifier_spec/options_spec.rb +0 -259
- data/spec/notice_notifier_spec.rb +0 -356
- data/spec/notice_spec.rb +0 -296
- data/spec/performance_breakdown_spec.rb +0 -12
- data/spec/performance_notifier_spec.rb +0 -435
- data/spec/promise_spec.rb +0 -197
- data/spec/query_spec.rb +0 -11
- data/spec/request_spec.rb +0 -11
- data/spec/response_spec.rb +0 -88
- data/spec/spec_helper.rb +0 -100
- data/spec/stashable_spec.rb +0 -23
- data/spec/stat_spec.rb +0 -47
- data/spec/sync_sender_spec.rb +0 -133
- data/spec/tdigest_spec.rb +0 -230
- data/spec/time_truncate_spec.rb +0 -13
- data/spec/timed_trace_spec.rb +0 -125
- data/spec/truncator_spec.rb +0 -238
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
RSpec.describe Airbrake::Filters::KeysWhitelist do
|
|
2
|
-
subject { described_class.new(patterns) }
|
|
3
|
-
|
|
4
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
|
5
|
-
|
|
6
|
-
shared_examples 'pattern matching' do |patts, params|
|
|
7
|
-
let(:patterns) { patts }
|
|
8
|
-
|
|
9
|
-
it "filters out the matching values" do
|
|
10
|
-
notice[:params] = params.first
|
|
11
|
-
subject.call(notice)
|
|
12
|
-
expect(notice[:params]).to eq(params.last)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context "when a pattern is a Regexp" do
|
|
17
|
-
include_examples(
|
|
18
|
-
'pattern matching',
|
|
19
|
-
[/\Abin/],
|
|
20
|
-
[
|
|
21
|
-
{ bingo: 'bango', bongo: 'bish', bash: 'bosh' },
|
|
22
|
-
{ bingo: 'bango', bongo: '[Filtered]', bash: '[Filtered]' }
|
|
23
|
-
]
|
|
24
|
-
)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context "when a pattern is a Symbol" do
|
|
28
|
-
include_examples(
|
|
29
|
-
'pattern matching',
|
|
30
|
-
[:bongo],
|
|
31
|
-
[
|
|
32
|
-
{ bongo: 'bish', bash: 'bosh', bbashh: 'bboshh' },
|
|
33
|
-
{ bongo: 'bish', bash: '[Filtered]', bbashh: '[Filtered]' }
|
|
34
|
-
]
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context "when a pattern is a String" do
|
|
39
|
-
include_examples(
|
|
40
|
-
'pattern matching',
|
|
41
|
-
['bash'],
|
|
42
|
-
[
|
|
43
|
-
{ bingo: 'bango', bongo: 'bish', bash: 'bosh' },
|
|
44
|
-
{ bingo: '[Filtered]', bongo: '[Filtered]', bash: 'bosh' }
|
|
45
|
-
]
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "when a Proc pattern was provided" do
|
|
50
|
-
context "along with normal keys" do
|
|
51
|
-
include_examples(
|
|
52
|
-
'pattern matching',
|
|
53
|
-
[proc { 'bongo' }, :bash],
|
|
54
|
-
[
|
|
55
|
-
{ bingo: 'bango', bongo: 'bish', bash: 'bosh' },
|
|
56
|
-
{ bingo: '[Filtered]', bongo: 'bish', bash: 'bosh' }
|
|
57
|
-
]
|
|
58
|
-
)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
context "which doesn't return an array of keys" do
|
|
62
|
-
include_examples(
|
|
63
|
-
'pattern matching',
|
|
64
|
-
[proc { Object.new }],
|
|
65
|
-
[
|
|
66
|
-
{ bingo: 'bango', bongo: 'bish', bash: 'bosh' },
|
|
67
|
-
{ bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
|
|
68
|
-
]
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
it "logs an error" do
|
|
72
|
-
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
|
73
|
-
/KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/
|
|
74
|
-
)
|
|
75
|
-
keys_whitelist = described_class.new(patterns)
|
|
76
|
-
keys_whitelist.call(notice)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "which returns another Proc" do
|
|
81
|
-
let(:patterns) { [proc { proc { ['bingo'] } }] }
|
|
82
|
-
|
|
83
|
-
context "and when the filter is called once" do
|
|
84
|
-
it "logs an error" do
|
|
85
|
-
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
|
86
|
-
/KeysWhitelist is invalid.+patterns: \[#<Proc:.+>\]/
|
|
87
|
-
)
|
|
88
|
-
keys_whitelist = described_class.new(patterns)
|
|
89
|
-
keys_whitelist.call(notice)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
include_examples(
|
|
93
|
-
'pattern matching',
|
|
94
|
-
[proc { proc { ['bingo'] } }],
|
|
95
|
-
[
|
|
96
|
-
{ bingo: 'bango', bongo: 'bish', bash: 'bosh' },
|
|
97
|
-
{ bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
|
|
98
|
-
]
|
|
99
|
-
)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
context "when a pattern is invalid" do
|
|
105
|
-
include_examples(
|
|
106
|
-
'pattern matching',
|
|
107
|
-
[Object.new],
|
|
108
|
-
[
|
|
109
|
-
{ bingo: 'bango', bongo: 'bish', bash: 'bosh' },
|
|
110
|
-
{ bingo: '[Filtered]', bongo: '[Filtered]', bash: '[Filtered]' }
|
|
111
|
-
]
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
it "logs an error" do
|
|
115
|
-
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
|
116
|
-
/KeysWhitelist is invalid.+patterns: \[#<Object:.+>\]/
|
|
117
|
-
)
|
|
118
|
-
keys_whitelist = described_class.new(patterns)
|
|
119
|
-
keys_whitelist.call(notice)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
context "when a value contains a nested hash" do
|
|
124
|
-
context "and it is non-recursive" do
|
|
125
|
-
include_examples(
|
|
126
|
-
'pattern matching',
|
|
127
|
-
%w[bongo bish],
|
|
128
|
-
[
|
|
129
|
-
{ bingo: 'bango', bongo: { bish: 'bash' } },
|
|
130
|
-
{ bingo: '[Filtered]', bongo: { bish: 'bash' } }
|
|
131
|
-
]
|
|
132
|
-
)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
context "and it is recursive" do
|
|
136
|
-
let(:patterns) { ['bingo'] }
|
|
137
|
-
|
|
138
|
-
it "raises error (MRI)", skip: (
|
|
139
|
-
# MRI 2.3 & 2.4 may segfault on Circle CI. Example build:
|
|
140
|
-
# https://circleci.com/workflow-run/c112358c-e7bf-4789-9eb2-4891ea84da68
|
|
141
|
-
RUBY_ENGINE == 'ruby' && RUBY_VERSION =~ /\A2\.[34]\.\d+\z/
|
|
142
|
-
) do
|
|
143
|
-
bongo = {}
|
|
144
|
-
bongo[:bingo] = bongo
|
|
145
|
-
notice[:params] = bongo
|
|
146
|
-
|
|
147
|
-
begin
|
|
148
|
-
expect { subject.call(notice) }.to raise_error(SystemStackError)
|
|
149
|
-
rescue RSpec::Expectations::ExpectationNotMetError => ex
|
|
150
|
-
# JRuby might raise two different exceptions, which represent the same
|
|
151
|
-
# thing. One is a Java exception, the other is a Ruby exception.
|
|
152
|
-
# Likely a bug: https://github.com/jruby/jruby/issues/1903
|
|
153
|
-
raise ex unless RUBY_ENGINE == 'jruby'
|
|
154
|
-
expect { subject.call(notice) }.to raise_error(java.lang.StackOverflowError)
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
describe "context payload" do
|
|
161
|
-
describe "URL" do
|
|
162
|
-
let(:patterns) { ['bish'] }
|
|
163
|
-
|
|
164
|
-
context "when it contains query params" do
|
|
165
|
-
it "filters the params" do
|
|
166
|
-
notice[:context][:url] = 'http://localhost:3000/crash?foo=bar&baz=bongo&bish=bash'
|
|
167
|
-
subject.call(notice)
|
|
168
|
-
expect(notice[:context][:url]).to(
|
|
169
|
-
eq('http://localhost:3000/crash?foo=[Filtered]&baz=[Filtered]&bish=bash')
|
|
170
|
-
)
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
context "when it is invalid" do
|
|
175
|
-
it "leaves the URL unfiltered" do
|
|
176
|
-
notice[:context][:url] =
|
|
177
|
-
'http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash'
|
|
178
|
-
subject.call(notice)
|
|
179
|
-
expect(notice[:context][:url]).to(
|
|
180
|
-
eq('http://localhost:3000/cra]]]sh?foo=bar&baz=bongo&bish=bash')
|
|
181
|
-
)
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
context "when it is without a query" do
|
|
186
|
-
it "leaves the URL untouched" do
|
|
187
|
-
notice[:context][:url] = 'http://localhost:3000/crash'
|
|
188
|
-
subject.call(notice)
|
|
189
|
-
expect(notice[:context][:url]).to(eq('http://localhost:3000/crash'))
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
RSpec.describe Airbrake::Filters::RootDirectoryFilter do
|
|
2
|
-
subject { described_class.new(root_directory) }
|
|
3
|
-
|
|
4
|
-
let(:root_directory) { '/var/www/project' }
|
|
5
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
|
6
|
-
|
|
7
|
-
it "replaces root directory in the backtrace with a label" do
|
|
8
|
-
# rubocop:disable Metrics/LineLength
|
|
9
|
-
notice[:errors].first[:backtrace] = [
|
|
10
|
-
{ file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
|
|
11
|
-
{ file: "#{root_directory}/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb " },
|
|
12
|
-
{ file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
|
|
13
|
-
{ file: "#{root_directory}/gems/rspec-core-3.3.2/exe/rspec" }
|
|
14
|
-
]
|
|
15
|
-
# rubocop:enable Metrics/LineLength
|
|
16
|
-
|
|
17
|
-
subject.call(notice)
|
|
18
|
-
|
|
19
|
-
# rubocop:disable Metrics/LineLength
|
|
20
|
-
expect(notice[:errors].first[:backtrace]).to(
|
|
21
|
-
eq(
|
|
22
|
-
[
|
|
23
|
-
{ file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
|
|
24
|
-
{ file: "/PROJECT_ROOT/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb " },
|
|
25
|
-
{ file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
|
|
26
|
-
{ file: "/PROJECT_ROOT/gems/rspec-core-3.3.2/exe/rspec" }
|
|
27
|
-
]
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
# rubocop:enable Metrics/LineLength
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "does not filter file when it is nil" do
|
|
34
|
-
expect(notice[:errors].first[:file]).to be_nil
|
|
35
|
-
expect { subject.call(notice) }.not_to(
|
|
36
|
-
change { notice[:errors].first[:file] }
|
|
37
|
-
)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
RSpec.describe Airbrake::Filters::SqlFilter do
|
|
2
|
-
shared_examples "query filtering" do |test|
|
|
3
|
-
test[:dialects].each do |dialect|
|
|
4
|
-
it "correctly filters SQL like `#{test[:input]}' (#{dialect} dialect)" do
|
|
5
|
-
filter = described_class.new(dialect)
|
|
6
|
-
q = OpenStruct.new(query: test[:input])
|
|
7
|
-
filter.call(q)
|
|
8
|
-
expect(q.query).to eq(test[:output])
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
ALL_DIALECTS = %i[mysql postgres sqlite cassandra oracle].freeze
|
|
14
|
-
|
|
15
|
-
# rubocop:disable Metrics/LineLength
|
|
16
|
-
[
|
|
17
|
-
{
|
|
18
|
-
input: 'SELECT * FROM things;',
|
|
19
|
-
output: 'SELECT * FROM things;',
|
|
20
|
-
dialects: ALL_DIALECTS
|
|
21
|
-
}, {
|
|
22
|
-
input: "SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = 'value' AND c3=\"othervalue\" LIMIT ?",
|
|
23
|
-
output: "SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = ? AND c3=? LIMIT ?",
|
|
24
|
-
dialects: %i[mysql]
|
|
25
|
-
}, {
|
|
26
|
-
input: "SELECT * FROM t WHERE foo=\"bar/*\" AND baz=\"whatever */qux\"",
|
|
27
|
-
output: "SELECT * FROM t WHERE foo=? AND baz=?",
|
|
28
|
-
dialects: %i[mysql]
|
|
29
|
-
}, {
|
|
30
|
-
input: "SELECT * FROM t WHERE foo='bar/*' AND baz='whatever */qux'",
|
|
31
|
-
output: "SELECT * FROM t WHERE foo=? AND baz=?",
|
|
32
|
-
dialects: ALL_DIALECTS
|
|
33
|
-
}, {
|
|
34
|
-
input: "SELECT \"t001\".\"c2\" FROM \"t001\" WHERE \"t001\".\"c2\" = 'value' AND c3=1234 LIMIT 1",
|
|
35
|
-
output: "SELECT \"t001\".\"c2\" FROM \"t001\" WHERE \"t001\".\"c2\" = ? AND c3=? LIMIT ?",
|
|
36
|
-
dialects: %i[postgres oracle]
|
|
37
|
-
}, {
|
|
38
|
-
input: "SELECT * FROM t WHERE foo=\"bar--\" AND\n baz=\"qux--\"",
|
|
39
|
-
output: "SELECT * FROM t WHERE foo=? AND\n baz=?",
|
|
40
|
-
dialects: %i[mysql]
|
|
41
|
-
}, {
|
|
42
|
-
input: "SELECT * FROM t WHERE foo='bar--' AND\n baz='qux--'",
|
|
43
|
-
output: "SELECT * FROM t WHERE foo=? AND\n baz=?",
|
|
44
|
-
dialects: ALL_DIALECTS
|
|
45
|
-
}, {
|
|
46
|
-
input: "SELECT * FROM foo WHERE bar='baz' /* Hide Me */",
|
|
47
|
-
output: "SELECT * FROM foo WHERE bar=? ?",
|
|
48
|
-
dialects: ALL_DIALECTS
|
|
49
|
-
}, {
|
|
50
|
-
input: "SELECT * FROM foobar WHERE password='hunter2'\n-- No peeking!",
|
|
51
|
-
output: "SELECT * FROM foobar WHERE password=?\n?",
|
|
52
|
-
dialects: ALL_DIALECTS
|
|
53
|
-
}, {
|
|
54
|
-
input: "SELECT foo, bar FROM baz WHERE password='hunter2' # Secret",
|
|
55
|
-
output: "SELECT foo, bar FROM baz WHERE password=? ?",
|
|
56
|
-
dialects: ALL_DIALECTS
|
|
57
|
-
}, {
|
|
58
|
-
input: "SELECT \"col1\", \"col2\" from \"table\" WHERE \"col3\"=E'foo\\'bar\\\\baz' AND country=e'foo\\'bar\\\\baz'",
|
|
59
|
-
output: "SELECT \"col1\", \"col2\" from \"table\" WHERE \"col3\"=E?",
|
|
60
|
-
dialects: %i[postgres]
|
|
61
|
-
}, {
|
|
62
|
-
input: "INSERT INTO `X` values(\"test\",0, 1 , 2, 'test')",
|
|
63
|
-
output: "INSERT INTO `X` values(?,?, ? , ?, ?)",
|
|
64
|
-
dialects: %i[mysql]
|
|
65
|
-
}, {
|
|
66
|
-
input: "SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value='nothing'",
|
|
67
|
-
output: "SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value=?",
|
|
68
|
-
dialects: ALL_DIALECTS
|
|
69
|
-
}, {
|
|
70
|
-
input: "INSERT INTO X VALUES(1, 23456, 123.456, 99+100)",
|
|
71
|
-
output: "INSERT INTO X VALUES(?, ?, ?, ?+?)",
|
|
72
|
-
dialects: ALL_DIALECTS
|
|
73
|
-
}, {
|
|
74
|
-
input: "SELECT * FROM table WHERE name=\"foo\" AND value=\"don't\"",
|
|
75
|
-
output: "SELECT * FROM table WHERE name=? AND value=?",
|
|
76
|
-
dialects: %i[mysql]
|
|
77
|
-
}, {
|
|
78
|
-
input: "SELECT * FROM table WHERE name='foo' AND value = 'bar'",
|
|
79
|
-
output: "SELECT * FROM table WHERE name=? AND value = ?",
|
|
80
|
-
dialects: ALL_DIALECTS
|
|
81
|
-
}, {
|
|
82
|
-
input: "SELECT * FROM table WHERE col='foo\\''bar'",
|
|
83
|
-
output: "SELECT * FROM table WHERE col=?",
|
|
84
|
-
dialects: ALL_DIALECTS
|
|
85
|
-
}, {
|
|
86
|
-
input: "SELECT * FROM table WHERE col1='foo\"bar' AND col2='what\"ever'",
|
|
87
|
-
output: "SELECT * FROM table WHERE col1=? AND col2=?",
|
|
88
|
-
dialects: ALL_DIALECTS
|
|
89
|
-
}, {
|
|
90
|
-
input: "select * from accounts where accounts.name != 'dude\n newline' order by accounts.name",
|
|
91
|
-
output: "select * from accounts where accounts.name != ? order by accounts.name",
|
|
92
|
-
dialects: ALL_DIALECTS
|
|
93
|
-
}, {
|
|
94
|
-
input: "SELECT * FROM table WHERE col1=\"don't\" AND col2=\"won't\"",
|
|
95
|
-
output: "SELECT * FROM table WHERE col1=? AND col2=?",
|
|
96
|
-
dialects: %i[mysql]
|
|
97
|
-
}, {
|
|
98
|
-
input: "INSERT INTO X values('', 'jim''s ssn',0, 1 , 'jim''s son''s son', \"\"\"jim''s\"\" hat\", \"\\\"jim''s secret\\\"\")",
|
|
99
|
-
output: "INSERT INTO X values(?, ?,?, ? , ?, ?, ?",
|
|
100
|
-
dialects: %i[mysql]
|
|
101
|
-
}, {
|
|
102
|
-
input: "SELECT * FROM table WHERE name='foo\\' AND color='blue'",
|
|
103
|
-
output: "SELECT * FROM table WHERE name=?",
|
|
104
|
-
dialects: ALL_DIALECTS
|
|
105
|
-
}, {
|
|
106
|
-
input: "SELECT * FROM table WHERE foo=\"this string ends with a backslash\\\\\"",
|
|
107
|
-
output: "SELECT * FROM table WHERE foo=?",
|
|
108
|
-
dialects: %i[mysql]
|
|
109
|
-
}, {
|
|
110
|
-
input: "SELECT * FROM table WHERE foo='this string ends with a backslash\\\\'",
|
|
111
|
-
output: "SELECT * FROM table WHERE foo=?",
|
|
112
|
-
dialects: ALL_DIALECTS
|
|
113
|
-
}, {
|
|
114
|
-
# TODO: fix this example.
|
|
115
|
-
input: "SELECT * FROM table WHERE name='foo\'' AND color='blue'",
|
|
116
|
-
output: "Error: Airbrake::Query was not filtered",
|
|
117
|
-
dialects: ALL_DIALECTS
|
|
118
|
-
}, {
|
|
119
|
-
input: "INSERT INTO X values('', 'a''b c',0, 1 , 'd''e f''s h')",
|
|
120
|
-
output: "INSERT INTO X values(?, ?,?, ? , ?)",
|
|
121
|
-
dialects: ALL_DIALECTS
|
|
122
|
-
}, {
|
|
123
|
-
input: "SELECT * FROM t WHERE -- '\n bar='baz' -- '",
|
|
124
|
-
output: "SELECT * FROM t WHERE ?\n bar=? ?",
|
|
125
|
-
dialects: ALL_DIALECTS
|
|
126
|
-
}, {
|
|
127
|
-
input: "SELECT * FROM t WHERE /* ' */\n bar='baz' -- '",
|
|
128
|
-
output: "SELECT * FROM t WHERE ?\n bar=? ?",
|
|
129
|
-
dialects: ALL_DIALECTS
|
|
130
|
-
}, {
|
|
131
|
-
input: "SELECT * FROM t WHERE -- '\n /* ' */ c2='xxx' /* ' */\n c='x\n xx' -- '",
|
|
132
|
-
output: "SELECT * FROM t WHERE ?\n ? c2=? ?\n c=? ?",
|
|
133
|
-
dialects: ALL_DIALECTS
|
|
134
|
-
}, {
|
|
135
|
-
input: "SELECT * FROM t WHERE -- '\n c='x\n xx' -- '",
|
|
136
|
-
output: "SELECT * FROM t WHERE ?\n c=? ?",
|
|
137
|
-
dialects: ALL_DIALECTS
|
|
138
|
-
}, {
|
|
139
|
-
input: "SELECT * FROM foo WHERE col='value1' AND /* don't */ col2='value1' /* won't */",
|
|
140
|
-
output: "SELECT * FROM foo WHERE col=? AND ? col2=? ?",
|
|
141
|
-
dialects: ALL_DIALECTS
|
|
142
|
-
}, {
|
|
143
|
-
input: "SELECT * FROM table WHERE foo='bar' AND baz=\"nothing to see here'",
|
|
144
|
-
output: "Error: Airbrake::Query was not filtered",
|
|
145
|
-
dialects: %i[mysql]
|
|
146
|
-
}, {
|
|
147
|
-
input: "SELECT * FROM table WHERE foo='bar' AND baz='nothing to see here",
|
|
148
|
-
output: "Error: Airbrake::Query was not filtered",
|
|
149
|
-
dialects: ALL_DIALECTS
|
|
150
|
-
}, {
|
|
151
|
-
input: "SELECT * FROM \"foo\" WHERE \"foo\" = $a$dollar quotes can be $b$nested$b$$a$ and bar = 'baz'",
|
|
152
|
-
output: "SELECT * FROM \"foo\" WHERE \"foo\" = ? and bar = ?",
|
|
153
|
-
dialects: %i[postgres]
|
|
154
|
-
}, {
|
|
155
|
-
input: "INSERT INTO \"foo\" (\"bar\", \"baz\", \"qux\") VALUES ($1, $2, $3) RETURNING \"id\"",
|
|
156
|
-
output: "INSERT INTO \"foo\" (\"bar\", \"baz\", \"qux\") VALUES ($?, $?, $?) RETURNING \"id\"",
|
|
157
|
-
dialects: %i[postgres]
|
|
158
|
-
}, {
|
|
159
|
-
input: "select * from foo where bar = 'some\\tthing' and baz = 10",
|
|
160
|
-
output: "select * from foo where bar = ? and baz = ?",
|
|
161
|
-
dialects: ALL_DIALECTS
|
|
162
|
-
}, {
|
|
163
|
-
input: "select * from users where user = 'user1\\' password = 'hunter 2' -- ->don't count this quote",
|
|
164
|
-
output: "select * from users where user = ?",
|
|
165
|
-
dialects: ALL_DIALECTS
|
|
166
|
-
}, {
|
|
167
|
-
input: "select * from foo where bar=q'[baz's]' and x=5",
|
|
168
|
-
output: "select * from foo where bar=? and x=?",
|
|
169
|
-
dialects: %i[oracle]
|
|
170
|
-
}, {
|
|
171
|
-
input: "select * from foo where bar=q'{baz's}' and x=5",
|
|
172
|
-
output: "select * from foo where bar=? and x=?",
|
|
173
|
-
dialects: %i[oracle]
|
|
174
|
-
}, {
|
|
175
|
-
input: "select * from foo where bar=q'<baz's>' and x=5",
|
|
176
|
-
output: "select * from foo where bar=? and x=?",
|
|
177
|
-
dialects: %i[oracle]
|
|
178
|
-
}, {
|
|
179
|
-
input: "select * from foo where bar=q'(baz's)' and x=5",
|
|
180
|
-
output: "select * from foo where bar=? and x=?",
|
|
181
|
-
dialects: %i[oracle]
|
|
182
|
-
}, {
|
|
183
|
-
input: "select * from foo where bar=0xabcdef123 and x=5",
|
|
184
|
-
output: "select * from foo where bar=? and x=?",
|
|
185
|
-
dialects: %i[cassandra sqlite]
|
|
186
|
-
}, {
|
|
187
|
-
input: "select * from foo where bar=0x2F and x=5",
|
|
188
|
-
output: "select * from foo where bar=? and x=?",
|
|
189
|
-
dialects: %i[mysql cassandra sqlite]
|
|
190
|
-
}, {
|
|
191
|
-
input: "select * from foo where bar=1.234e-5 and x=5",
|
|
192
|
-
output: "select * from foo where bar=? and x=?",
|
|
193
|
-
dialects: ALL_DIALECTS
|
|
194
|
-
}, {
|
|
195
|
-
input: "select * from foo where bar=01234567-89ab-cdef-0123-456789abcdef and x=5",
|
|
196
|
-
output: "select * from foo where bar=? and x=?",
|
|
197
|
-
dialects: %i[postgres cassandra]
|
|
198
|
-
}, {
|
|
199
|
-
input: "select * from foo where bar={01234567-89ab-cdef-0123-456789abcdef} and x=5",
|
|
200
|
-
output: "select * from foo where bar=? and x=?",
|
|
201
|
-
dialects: %i[postgres]
|
|
202
|
-
}, {
|
|
203
|
-
input: "select * from foo where bar=0123456789abcdef0123456789abcdef and x=5",
|
|
204
|
-
output: "select * from foo where bar=? and x=?",
|
|
205
|
-
dialects: %i[postgtes]
|
|
206
|
-
}, {
|
|
207
|
-
input: "select * from foo where bar={012-345678-9abc-def012345678-9abcdef} and x=5",
|
|
208
|
-
output: "select * from foo where bar=? and x=?",
|
|
209
|
-
dialects: %i[postgres]
|
|
210
|
-
}, {
|
|
211
|
-
input: "select * from foo where bar=true and x=FALSE",
|
|
212
|
-
output: "select * from foo where bar=? and x=?",
|
|
213
|
-
dialects: %i[mysql postgres cassandra sqlite]
|
|
214
|
-
}
|
|
215
|
-
].each do |test|
|
|
216
|
-
include_examples 'query filtering', test
|
|
217
|
-
end
|
|
218
|
-
# rubocop:enable Metrics/LineLength
|
|
219
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
RSpec.describe Airbrake::Filters::SystemExitFilter do
|
|
2
|
-
it "marks SystemExit exceptions as ignored" do
|
|
3
|
-
notice = Airbrake::Notice.new(SystemExit.new)
|
|
4
|
-
expect { subject.call(notice) }.to(
|
|
5
|
-
change { notice.ignored? }.from(false).to(true)
|
|
6
|
-
)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "doesn't mark non SystemExit exceptions as ignored" do
|
|
10
|
-
notice = Airbrake::Notice.new(AirbrakeTestError.new)
|
|
11
|
-
expect(notice).not_to be_ignored
|
|
12
|
-
expect { subject.call(notice) }.not_to(change { notice.ignored? })
|
|
13
|
-
end
|
|
14
|
-
end
|