airbrake-ruby 4.8.0 → 5.2.0
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 +132 -57
- data/lib/airbrake-ruby/async_sender.rb +7 -30
- 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.rb +59 -15
- data/lib/airbrake-ruby/config/processor.rb +71 -0
- data/lib/airbrake-ruby/config/validator.rb +9 -3
- data/lib/airbrake-ruby/deploy_notifier.rb +1 -1
- data/lib/airbrake-ruby/file_cache.rb +1 -1
- data/lib/airbrake-ruby/filter_chain.rb +16 -1
- data/lib/airbrake-ruby/filters/dependency_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +2 -2
- data/lib/airbrake-ruby/filters/gem_root_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +5 -5
- data/lib/airbrake-ruby/filters/git_repository_filter.rb +3 -0
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +2 -0
- 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 +39 -20
- data/lib/airbrake-ruby/filters/root_directory_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/sql_filter.rb +7 -7
- data/lib/airbrake-ruby/filters/system_exit_filter.rb +1 -0
- data/lib/airbrake-ruby/filters/thread_filter.rb +5 -4
- data/lib/airbrake-ruby/grouppable.rb +12 -0
- data/lib/airbrake-ruby/ignorable.rb +1 -0
- 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 +5 -0
- data/lib/airbrake-ruby/notice.rb +7 -14
- data/lib/airbrake-ruby/notice_notifier.rb +11 -3
- data/lib/airbrake-ruby/performance_breakdown.rb +16 -10
- data/lib/airbrake-ruby/performance_notifier.rb +80 -58
- data/lib/airbrake-ruby/promise.rb +1 -0
- data/lib/airbrake-ruby/query.rb +20 -15
- data/lib/airbrake-ruby/queue.rb +65 -0
- data/lib/airbrake-ruby/remote_settings.rb +105 -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/request.rb +14 -12
- data/lib/airbrake-ruby/stat.rb +26 -33
- data/lib/airbrake-ruby/sync_sender.rb +3 -2
- data/lib/airbrake-ruby/tdigest.rb +43 -58
- data/lib/airbrake-ruby/thread_pool.rb +11 -1
- data/lib/airbrake-ruby/truncator.rb +10 -4
- data/lib/airbrake-ruby/version.rb +11 -1
- data/spec/airbrake_spec.rb +206 -71
- data/spec/async_sender_spec.rb +3 -12
- data/spec/backtrace_spec.rb +44 -44
- data/spec/code_hunk_spec.rb +11 -11
- data/spec/config/processor_spec.rb +143 -0
- data/spec/config/validator_spec.rb +23 -6
- data/spec/config_spec.rb +40 -14
- data/spec/deploy_notifier_spec.rb +2 -2
- data/spec/filter_chain_spec.rb +28 -1
- data/spec/filters/dependency_filter_spec.rb +1 -1
- data/spec/filters/gem_root_filter_spec.rb +9 -9
- data/spec/filters/git_last_checkout_filter_spec.rb +21 -4
- data/spec/filters/git_repository_filter.rb +1 -1
- data/spec/filters/git_revision_filter_spec.rb +10 -10
- data/spec/filters/{keys_whitelist_spec.rb → keys_allowlist_spec.rb} +29 -28
- data/spec/filters/{keys_blacklist_spec.rb → keys_blocklist_spec.rb} +39 -29
- data/spec/filters/root_directory_filter_spec.rb +9 -9
- data/spec/filters/sql_filter_spec.rb +58 -60
- data/spec/filters/system_exit_filter_spec.rb +1 -1
- data/spec/filters/thread_filter_spec.rb +32 -30
- data/spec/fixtures/project_root/code.rb +9 -9
- data/spec/loggable_spec.rb +17 -0
- data/spec/monotonic_time_spec.rb +11 -0
- data/spec/notice_notifier/options_spec.rb +17 -17
- data/spec/notice_notifier_spec.rb +20 -20
- data/spec/notice_spec.rb +6 -6
- data/spec/performance_breakdown_spec.rb +0 -1
- data/spec/performance_notifier_spec.rb +220 -73
- data/spec/query_spec.rb +1 -1
- data/spec/queue_spec.rb +18 -0
- data/spec/remote_settings/callback_spec.rb +143 -0
- data/spec/remote_settings/settings_data_spec.rb +348 -0
- data/spec/remote_settings_spec.rb +187 -0
- data/spec/request_spec.rb +1 -3
- data/spec/response_spec.rb +8 -8
- data/spec/spec_helper.rb +6 -6
- data/spec/stat_spec.rb +2 -12
- data/spec/sync_sender_spec.rb +14 -12
- data/spec/tdigest_spec.rb +7 -7
- data/spec/thread_pool_spec.rb +39 -10
- data/spec/timed_trace_spec.rb +1 -1
- data/spec/truncator_spec.rb +12 -12
- metadata +32 -14
@@ -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) }
|
@@ -19,8 +19,8 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
19
19
|
[/\Abon/],
|
20
20
|
[
|
21
21
|
{ bongo: 'bango' },
|
22
|
-
{ bongo: '[Filtered]' }
|
23
|
-
]
|
22
|
+
{ bongo: '[Filtered]' },
|
23
|
+
],
|
24
24
|
)
|
25
25
|
|
26
26
|
context "and when a key is a hash" do
|
@@ -40,8 +40,8 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
40
40
|
[:bingo],
|
41
41
|
[
|
42
42
|
{ bingo: 'bango' },
|
43
|
-
{ bingo: '[Filtered]' }
|
44
|
-
]
|
43
|
+
{ bingo: '[Filtered]' },
|
44
|
+
],
|
45
45
|
)
|
46
46
|
end
|
47
47
|
|
@@ -51,8 +51,8 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
51
51
|
['bingo'],
|
52
52
|
[
|
53
53
|
{ bingo: 'bango' },
|
54
|
-
{ bingo: '[Filtered]' }
|
55
|
-
]
|
54
|
+
{ bingo: '[Filtered]' },
|
55
|
+
],
|
56
56
|
)
|
57
57
|
end
|
58
58
|
|
@@ -62,8 +62,8 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
62
62
|
['bingo'],
|
63
63
|
[
|
64
64
|
{ array: [{ bingo: 'bango' }, []] },
|
65
|
-
{ array: [{ bingo: '[Filtered]' }, []] }
|
66
|
-
]
|
65
|
+
{ array: [{ bingo: '[Filtered]' }, []] },
|
66
|
+
],
|
67
67
|
)
|
68
68
|
end
|
69
69
|
|
@@ -74,8 +74,8 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
74
74
|
[proc { 'bongo' }, :bash],
|
75
75
|
[
|
76
76
|
{ bingo: 'bango', bongo: 'bish', bash: 'bosh' },
|
77
|
-
{ bingo: 'bango', bongo: '[Filtered]', bash: '[Filtered]' }
|
78
|
-
]
|
77
|
+
{ bingo: 'bango', bongo: '[Filtered]', bash: '[Filtered]' },
|
78
|
+
],
|
79
79
|
)
|
80
80
|
end
|
81
81
|
|
@@ -85,16 +85,16 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
85
85
|
[proc { Object.new }],
|
86
86
|
[
|
87
87
|
{ bingo: 'bango', bongo: 'bish' },
|
88
|
-
{ bingo: 'bango', bongo: 'bish' }
|
89
|
-
]
|
88
|
+
{ bingo: 'bango', bongo: 'bish' },
|
89
|
+
],
|
90
90
|
)
|
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
|
|
@@ -127,16 +127,16 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
127
127
|
[Object.new],
|
128
128
|
[
|
129
129
|
{ bingo: 'bango', bongo: 'bish' },
|
130
|
-
{ bingo: 'bango', bongo: 'bish' }
|
131
|
-
]
|
130
|
+
{ bingo: 'bango', bongo: 'bish' },
|
131
|
+
],
|
132
132
|
)
|
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
|
|
@@ -147,9 +147,19 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
147
147
|
['bish'],
|
148
148
|
[
|
149
149
|
{ bongo: { bish: 'bash' } },
|
150
|
-
{ bongo: { bish: '[Filtered]' } }
|
151
|
-
]
|
150
|
+
{ bongo: { bish: '[Filtered]' } },
|
151
|
+
],
|
152
152
|
)
|
153
|
+
|
154
|
+
it "doesn't mutate the original hash" do
|
155
|
+
params = { bongo: { bish: 'bash' } }
|
156
|
+
notice[:params] = params
|
157
|
+
|
158
|
+
blocklist = described_class.new([:bish])
|
159
|
+
blocklist.call(notice)
|
160
|
+
|
161
|
+
expect(params[:bongo][:bish]).to eq('bash')
|
162
|
+
end
|
153
163
|
end
|
154
164
|
|
155
165
|
context "and it is recursive" do
|
@@ -161,8 +171,8 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
161
171
|
['bango'],
|
162
172
|
[
|
163
173
|
bongo,
|
164
|
-
{ bingo: { bango: '[Filtered]' } }
|
165
|
-
]
|
174
|
+
{ bingo: { bango: '[Filtered]' } },
|
175
|
+
],
|
166
176
|
)
|
167
177
|
end
|
168
178
|
end
|
@@ -177,7 +187,7 @@ RSpec.describe Airbrake::Filters::KeysBlacklist do
|
|
177
187
|
|
178
188
|
subject.call(notice)
|
179
189
|
expect(notice[:context][:url]).to(
|
180
|
-
eq
|
190
|
+
eq('http://localhost:3000/crash?foo=bar&baz=bongo&bish=[Filtered]&color=%23FFAAFF'),
|
181
191
|
)
|
182
192
|
end
|
183
193
|
end
|
@@ -5,35 +5,35 @@ RSpec.describe Airbrake::Filters::RootDirectoryFilter do
|
|
5
5
|
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
6
6
|
|
7
7
|
it "replaces root directory in the backtrace with a label" do
|
8
|
-
# rubocop:disable
|
8
|
+
# rubocop:disable Layout/LineLength
|
9
9
|
notice[:errors].first[:backtrace] = [
|
10
10
|
{ file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
|
11
11
|
{ file: "#{root_directory}/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb " },
|
12
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" }
|
13
|
+
{ file: "#{root_directory}/gems/rspec-core-3.3.2/exe/rspec" },
|
14
14
|
]
|
15
|
-
# rubocop:enable
|
15
|
+
# rubocop:enable Layout/LineLength
|
16
16
|
|
17
17
|
subject.call(notice)
|
18
18
|
|
19
|
-
# rubocop:disable
|
19
|
+
# rubocop:disable Layout/LineLength
|
20
20
|
expect(notice[:errors].first[:backtrace]).to(
|
21
21
|
eq(
|
22
22
|
[
|
23
23
|
{ file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
|
24
24
|
{ file: "/PROJECT_ROOT/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb " },
|
25
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
|
-
)
|
26
|
+
{ file: "/PROJECT_ROOT/gems/rspec-core-3.3.2/exe/rspec" },
|
27
|
+
],
|
28
|
+
),
|
29
29
|
)
|
30
|
-
# rubocop:enable
|
30
|
+
# rubocop:enable Layout/LineLength
|
31
31
|
end
|
32
32
|
|
33
33
|
it "does not filter file when it is nil" do
|
34
34
|
expect(notice[:errors].first[:file]).to be_nil
|
35
35
|
expect { subject.call(notice) }.not_to(
|
36
|
-
change { notice[:errors].first[:file] }
|
36
|
+
change { notice[:errors].first[:file] },
|
37
37
|
)
|
38
38
|
end
|
39
39
|
end
|
@@ -10,12 +10,10 @@ 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
|
-
q = Airbrake::Query.new(
|
17
|
-
query: query, method: 'GET', route: '/', start_time: Time.now
|
18
|
-
)
|
16
|
+
q = Airbrake::Query.new(query: query, method: 'GET', route: '/', timing: 1)
|
19
17
|
filter.call(q)
|
20
18
|
|
21
19
|
expect(q.ignored?).to eq(opts[:should_ignore])
|
@@ -24,214 +22,214 @@ RSpec.describe Airbrake::Filters::SqlFilter do
|
|
24
22
|
|
25
23
|
ALL_DIALECTS = %i[mysql postgres sqlite cassandra oracle].freeze
|
26
24
|
|
27
|
-
# rubocop:disable
|
25
|
+
# rubocop:disable Layout/LineLength
|
28
26
|
[
|
29
27
|
{
|
30
28
|
input: 'SELECT * FROM things;',
|
31
29
|
output: 'SELECT * FROM things;',
|
32
|
-
dialects: ALL_DIALECTS
|
30
|
+
dialects: ALL_DIALECTS,
|
33
31
|
}, {
|
34
32
|
input: "SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = 'value' AND c3=\"othervalue\" LIMIT ?",
|
35
33
|
output: "SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = ? AND c3=? LIMIT ?",
|
36
|
-
dialects: %i[mysql]
|
34
|
+
dialects: %i[mysql],
|
37
35
|
}, {
|
38
36
|
input: "SELECT * FROM t WHERE foo=\"bar/*\" AND baz=\"whatever */qux\"",
|
39
37
|
output: "SELECT * FROM t WHERE foo=? AND baz=?",
|
40
|
-
dialects: %i[mysql]
|
38
|
+
dialects: %i[mysql],
|
41
39
|
}, {
|
42
40
|
input: "SELECT * FROM t WHERE foo='bar/*' AND baz='whatever */qux'",
|
43
41
|
output: "SELECT * FROM t WHERE foo=? AND baz=?",
|
44
|
-
dialects: ALL_DIALECTS
|
42
|
+
dialects: ALL_DIALECTS,
|
45
43
|
}, {
|
46
44
|
input: "SELECT \"t001\".\"c2\" FROM \"t001\" WHERE \"t001\".\"c2\" = 'value' AND c3=1234 LIMIT 1",
|
47
45
|
output: "SELECT \"t001\".\"c2\" FROM \"t001\" WHERE \"t001\".\"c2\" = ? AND c3=? LIMIT ?",
|
48
|
-
dialects: %i[postgres oracle]
|
46
|
+
dialects: %i[postgres oracle],
|
49
47
|
}, {
|
50
48
|
input: "SELECT * FROM t WHERE foo=\"bar--\" AND\n baz=\"qux--\"",
|
51
49
|
output: "SELECT * FROM t WHERE foo=? AND\n baz=?",
|
52
|
-
dialects: %i[mysql]
|
50
|
+
dialects: %i[mysql],
|
53
51
|
}, {
|
54
52
|
input: "SELECT * FROM t WHERE foo='bar--' AND\n baz='qux--'",
|
55
53
|
output: "SELECT * FROM t WHERE foo=? AND\n baz=?",
|
56
|
-
dialects: ALL_DIALECTS
|
54
|
+
dialects: ALL_DIALECTS,
|
57
55
|
}, {
|
58
56
|
input: "SELECT * FROM foo WHERE bar='baz' /* Hide Me */",
|
59
57
|
output: "SELECT * FROM foo WHERE bar=? ?",
|
60
|
-
dialects: ALL_DIALECTS
|
58
|
+
dialects: ALL_DIALECTS,
|
61
59
|
}, {
|
62
60
|
input: "SELECT * FROM foobar WHERE password='hunter2'\n-- No peeking!",
|
63
61
|
output: "SELECT * FROM foobar WHERE password=?\n?",
|
64
|
-
dialects: ALL_DIALECTS
|
62
|
+
dialects: ALL_DIALECTS,
|
65
63
|
}, {
|
66
64
|
input: "SELECT foo, bar FROM baz WHERE password='hunter2' # Secret",
|
67
65
|
output: "SELECT foo, bar FROM baz WHERE password=? ?",
|
68
|
-
dialects: ALL_DIALECTS
|
66
|
+
dialects: ALL_DIALECTS,
|
69
67
|
}, {
|
70
68
|
input: "SELECT \"col1\", \"col2\" from \"table\" WHERE \"col3\"=E'foo\\'bar\\\\baz' AND country=e'foo\\'bar\\\\baz'",
|
71
69
|
output: "SELECT \"col1\", \"col2\" from \"table\" WHERE \"col3\"=E?",
|
72
|
-
dialects: %i[postgres]
|
70
|
+
dialects: %i[postgres],
|
73
71
|
}, {
|
74
72
|
input: "INSERT INTO `X` values(\"test\",0, 1 , 2, 'test')",
|
75
73
|
output: "INSERT INTO `X` values(?)",
|
76
|
-
dialects: %i[mysql]
|
74
|
+
dialects: %i[mysql],
|
77
75
|
}, {
|
78
76
|
input: "INSERT INTO `X` values(\"test\",0, 1 , 2, 'test')",
|
79
77
|
output: "INSERT INTO `X` values(?)",
|
80
|
-
dialects: %i[mysql]
|
78
|
+
dialects: %i[mysql],
|
81
79
|
}, {
|
82
80
|
input: "SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value='nothing'",
|
83
81
|
output: "SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value=?",
|
84
|
-
dialects: ALL_DIALECTS
|
82
|
+
dialects: ALL_DIALECTS,
|
85
83
|
}, {
|
86
84
|
input: "INSERT INTO X VALUES(1, 23456, 123.456, 99+100)",
|
87
85
|
output: "INSERT INTO X VALUES(?)",
|
88
|
-
dialects: ALL_DIALECTS
|
86
|
+
dialects: ALL_DIALECTS,
|
89
87
|
}, {
|
90
88
|
input: "SELECT * FROM table WHERE name=\"foo\" AND value=\"don't\"",
|
91
89
|
output: "SELECT * FROM table WHERE name=? AND value=?",
|
92
|
-
dialects: %i[mysql]
|
90
|
+
dialects: %i[mysql],
|
93
91
|
}, {
|
94
92
|
input: "SELECT * FROM table WHERE name='foo' AND value = 'bar'",
|
95
93
|
output: "SELECT * FROM table WHERE name=? AND value = ?",
|
96
|
-
dialects: ALL_DIALECTS
|
94
|
+
dialects: ALL_DIALECTS,
|
97
95
|
}, {
|
98
96
|
input: "SELECT * FROM table WHERE col='foo\\''bar'",
|
99
97
|
output: "SELECT * FROM table WHERE col=?",
|
100
|
-
dialects: ALL_DIALECTS
|
98
|
+
dialects: ALL_DIALECTS,
|
101
99
|
}, {
|
102
100
|
input: "SELECT * FROM table WHERE col1='foo\"bar' AND col2='what\"ever'",
|
103
101
|
output: "SELECT * FROM table WHERE col1=? AND col2=?",
|
104
|
-
dialects: ALL_DIALECTS
|
102
|
+
dialects: ALL_DIALECTS,
|
105
103
|
}, {
|
106
104
|
input: "select * from accounts where accounts.name != 'dude\n newline' order by accounts.name",
|
107
105
|
output: "select * from accounts where accounts.name != ? order by accounts.name",
|
108
|
-
dialects: ALL_DIALECTS
|
106
|
+
dialects: ALL_DIALECTS,
|
109
107
|
}, {
|
110
108
|
input: "SELECT * FROM table WHERE col1=\"don't\" AND col2=\"won't\"",
|
111
109
|
output: "SELECT * FROM table WHERE col1=? AND col2=?",
|
112
|
-
dialects: %i[mysql]
|
110
|
+
dialects: %i[mysql],
|
113
111
|
}, {
|
114
112
|
input: "INSERT INTO X values('', 'jim''s ssn',0, 1 , 'jim''s son''s son', \"\"\"jim''s\"\" hat\", \"\\\"jim''s secret\\\"\")",
|
115
113
|
output: "INSERT INTO X values(?, ?,?, ? , ?, ?, ?",
|
116
|
-
dialects: %i[mysql]
|
114
|
+
dialects: %i[mysql],
|
117
115
|
}, {
|
118
116
|
input: "SELECT * FROM table WHERE name='foo\\' AND color='blue'",
|
119
117
|
output: "SELECT * FROM table WHERE name=?",
|
120
|
-
dialects: ALL_DIALECTS
|
118
|
+
dialects: ALL_DIALECTS,
|
121
119
|
}, {
|
122
120
|
input: "SELECT * FROM table WHERE foo=\"this string ends with a backslash\\\\\"",
|
123
121
|
output: "SELECT * FROM table WHERE foo=?",
|
124
|
-
dialects: %i[mysql]
|
122
|
+
dialects: %i[mysql],
|
125
123
|
}, {
|
126
124
|
input: "SELECT * FROM table WHERE foo='this string ends with a backslash\\\\'",
|
127
125
|
output: "SELECT * FROM table WHERE foo=?",
|
128
|
-
dialects: ALL_DIALECTS
|
126
|
+
dialects: ALL_DIALECTS,
|
129
127
|
}, {
|
130
128
|
# TODO: fix this example.
|
131
129
|
input: "SELECT * FROM table WHERE name='foo\'' AND color='blue'",
|
132
130
|
output: "Error: Airbrake::Query was not filtered",
|
133
|
-
dialects: ALL_DIALECTS
|
131
|
+
dialects: ALL_DIALECTS,
|
134
132
|
}, {
|
135
133
|
input: "INSERT INTO X values('', 'a''b c',0, 1 , 'd''e f''s h')",
|
136
134
|
output: "INSERT INTO X values(?)",
|
137
|
-
dialects: ALL_DIALECTS
|
135
|
+
dialects: ALL_DIALECTS,
|
138
136
|
}, {
|
139
137
|
input: "SELECT * FROM t WHERE -- '\n bar='baz' -- '",
|
140
138
|
output: "SELECT * FROM t WHERE ?\n bar=? ?",
|
141
|
-
dialects: ALL_DIALECTS
|
139
|
+
dialects: ALL_DIALECTS,
|
142
140
|
}, {
|
143
141
|
input: "SELECT * FROM t WHERE /* ' */\n bar='baz' -- '",
|
144
142
|
output: "SELECT * FROM t WHERE ?\n bar=? ?",
|
145
|
-
dialects: ALL_DIALECTS
|
143
|
+
dialects: ALL_DIALECTS,
|
146
144
|
}, {
|
147
145
|
input: "SELECT * FROM t WHERE -- '\n /* ' */ c2='xxx' /* ' */\n c='x\n xx' -- '",
|
148
146
|
output: "SELECT * FROM t WHERE ?\n ? c2=? ?\n c=? ?",
|
149
|
-
dialects: ALL_DIALECTS
|
147
|
+
dialects: ALL_DIALECTS,
|
150
148
|
}, {
|
151
149
|
input: "SELECT * FROM t WHERE -- '\n c='x\n xx' -- '",
|
152
150
|
output: "SELECT * FROM t WHERE ?\n c=? ?",
|
153
|
-
dialects: ALL_DIALECTS
|
151
|
+
dialects: ALL_DIALECTS,
|
154
152
|
}, {
|
155
153
|
input: "SELECT * FROM foo WHERE col='value1' AND /* don't */ col2='value1' /* won't */",
|
156
154
|
output: "SELECT * FROM foo WHERE col=? AND ? col2=? ?",
|
157
|
-
dialects: ALL_DIALECTS
|
155
|
+
dialects: ALL_DIALECTS,
|
158
156
|
}, {
|
159
157
|
input: "SELECT * FROM table WHERE foo='bar' AND baz=\"nothing to see here'",
|
160
158
|
output: "Error: Airbrake::Query was not filtered",
|
161
|
-
dialects: %i[mysql]
|
159
|
+
dialects: %i[mysql],
|
162
160
|
}, {
|
163
161
|
input: "SELECT * FROM table WHERE foo='bar' AND baz='nothing to see here",
|
164
162
|
output: "Error: Airbrake::Query was not filtered",
|
165
|
-
dialects: ALL_DIALECTS
|
163
|
+
dialects: ALL_DIALECTS,
|
166
164
|
}, {
|
167
165
|
input: "SELECT * FROM \"foo\" WHERE \"foo\" = $a$dollar quotes can be $b$nested$b$$a$ and bar = 'baz'",
|
168
166
|
output: "SELECT * FROM \"foo\" WHERE \"foo\" = ? and bar = ?",
|
169
|
-
dialects: %i[postgres]
|
167
|
+
dialects: %i[postgres],
|
170
168
|
}, {
|
171
169
|
input: "INSERT INTO \"foo\" (\"bar\", \"baz\", \"qux\") VALUES ($1, $2, $3) RETURNING \"id\"",
|
172
170
|
output: "INSERT INTO \"foo\" (?) RETURNING \"id\"",
|
173
|
-
dialects: %i[postgres]
|
171
|
+
dialects: %i[postgres],
|
174
172
|
}, {
|
175
173
|
input: "select * from foo where bar = 'some\\tthing' and baz = 10",
|
176
174
|
output: "select * from foo where bar = ? and baz = ?",
|
177
|
-
dialects: ALL_DIALECTS
|
175
|
+
dialects: ALL_DIALECTS,
|
178
176
|
}, {
|
179
177
|
input: "select * from users where user = 'user1\\' password = 'hunter 2' -- ->don't count this quote",
|
180
178
|
output: "select * from users where user = ?",
|
181
|
-
dialects: ALL_DIALECTS
|
179
|
+
dialects: ALL_DIALECTS,
|
182
180
|
}, {
|
183
181
|
input: "select * from foo where bar=q'[baz's]' and x=5",
|
184
182
|
output: "select * from foo where bar=? and x=?",
|
185
|
-
dialects: %i[oracle]
|
183
|
+
dialects: %i[oracle],
|
186
184
|
}, {
|
187
185
|
input: "select * from foo where bar=q'{baz's}' and x=5",
|
188
186
|
output: "select * from foo where bar=? and x=?",
|
189
|
-
dialects: %i[oracle]
|
187
|
+
dialects: %i[oracle],
|
190
188
|
}, {
|
191
189
|
input: "select * from foo where bar=q'<baz's>' and x=5",
|
192
190
|
output: "select * from foo where bar=? and x=?",
|
193
|
-
dialects: %i[oracle]
|
191
|
+
dialects: %i[oracle],
|
194
192
|
}, {
|
195
193
|
input: "select * from foo where bar=q'(baz's)' and x=5",
|
196
194
|
output: "select * from foo where bar=? and x=?",
|
197
|
-
dialects: %i[oracle]
|
195
|
+
dialects: %i[oracle],
|
198
196
|
}, {
|
199
197
|
input: "select * from foo where bar=0xabcdef123 and x=5",
|
200
198
|
output: "select * from foo where bar=? and x=?",
|
201
|
-
dialects: %i[cassandra sqlite]
|
199
|
+
dialects: %i[cassandra sqlite],
|
202
200
|
}, {
|
203
201
|
input: "select * from foo where bar=0x2F and x=5",
|
204
202
|
output: "select * from foo where bar=? and x=?",
|
205
|
-
dialects: %i[mysql cassandra sqlite]
|
203
|
+
dialects: %i[mysql cassandra sqlite],
|
206
204
|
}, {
|
207
205
|
input: "select * from foo where bar=1.234e-5 and x=5",
|
208
206
|
output: "select * from foo where bar=? and x=?",
|
209
|
-
dialects: ALL_DIALECTS
|
207
|
+
dialects: ALL_DIALECTS,
|
210
208
|
}, {
|
211
209
|
input: "select * from foo where bar=01234567-89ab-cdef-0123-456789abcdef and x=5",
|
212
210
|
output: "select * from foo where bar=? and x=?",
|
213
|
-
dialects: %i[postgres cassandra]
|
211
|
+
dialects: %i[postgres cassandra],
|
214
212
|
}, {
|
215
213
|
input: "select * from foo where bar={01234567-89ab-cdef-0123-456789abcdef} and x=5",
|
216
214
|
output: "select * from foo where bar=? and x=?",
|
217
|
-
dialects: %i[postgres]
|
215
|
+
dialects: %i[postgres],
|
218
216
|
}, {
|
219
217
|
input: "select * from foo where bar=0123456789abcdef0123456789abcdef and x=5",
|
220
218
|
output: "select * from foo where bar=? and x=?",
|
221
|
-
dialects: %i[postgtes]
|
219
|
+
dialects: %i[postgtes],
|
222
220
|
}, {
|
223
221
|
input: "select * from foo where bar={012-345678-9abc-def012345678-9abcdef} and x=5",
|
224
222
|
output: "select * from foo where bar=? and x=?",
|
225
|
-
dialects: %i[postgres]
|
223
|
+
dialects: %i[postgres],
|
226
224
|
}, {
|
227
225
|
input: "select * from foo where bar=true and x=FALSE",
|
228
226
|
output: "select * from foo where bar=? and x=?",
|
229
|
-
dialects: %i[mysql postgres cassandra sqlite]
|
227
|
+
dialects: %i[mysql postgres cassandra sqlite],
|
230
228
|
}
|
231
229
|
].each do |test|
|
232
230
|
include_examples 'query filtering', test
|
233
231
|
end
|
234
|
-
# rubocop:enable
|
232
|
+
# rubocop:enable Layout/LineLength
|
235
233
|
|
236
234
|
[
|
237
235
|
'COMMIT',
|
@@ -263,14 +261,14 @@ RSpec.describe Airbrake::Filters::SqlFilter do
|
|
263
261
|
'oid = rngtypid WHERE t.typname IN (?) OR t.typtype IN (?) OR t.typinput ' \
|
264
262
|
'= ?::regprocedure OR t.typelem != ?',
|
265
263
|
|
266
|
-
'SELECT t.oid, t.typname FROM pg_type as t WHERE t.typname IN (?)'
|
264
|
+
'SELECT t.oid, t.typname FROM pg_type as t WHERE t.typname IN (?)',
|
267
265
|
].each do |query|
|
268
|
-
include_examples 'query
|
266
|
+
include_examples 'query blocklisting', query, should_ignore: true
|
269
267
|
end
|
270
268
|
|
271
269
|
[
|
272
|
-
'UPDATE "users" SET "last_sign_in_at" = ? WHERE "users"."id" = ?'
|
270
|
+
'UPDATE "users" SET "last_sign_in_at" = ? WHERE "users"."id" = ?',
|
273
271
|
].each do |query|
|
274
|
-
include_examples 'query
|
272
|
+
include_examples 'query blocklisting', query, should_ignore: false
|
275
273
|
end
|
276
274
|
end
|