Skip to content

Commit a34d55b

Browse files
committed
Skip test for regular expression timeout attack
On Ruby < 3.2.
1 parent 1e13f60 commit a34d55b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/aikido/zen/scanners/sql_injection_scanner_test.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,20 @@ def refute_attack(query, input = query, *args)
276276
end
277277

278278
test "it flags regular expression matching timeouts as attacks" do
279-
timeout = Regexp.timeout
280-
Regexp.timeout = 0.01
279+
skip if RUBY_VERSION < "3.2"
281280

282-
refute_attack "SELECT * FROM users WHERE id IN (123,)", "123,"
281+
begin
282+
timeout = Regexp.timeout
283+
Regexp.timeout = 0.01
283284

284-
input = "1," * 1 * 1024 * 1024
285+
refute_attack "SELECT * FROM users WHERE id IN (123,)", "123,"
285286

286-
assert_attack "SELECT * FROM users WHERE id IN (#{input})", input
287-
ensure
288-
Regexp.timeout = timeout
287+
input = "1," * 1 * 1024 * 1024
288+
289+
assert_attack "SELECT * FROM users WHERE id IN (#{input})", input
290+
ensure
291+
Regexp.timeout = timeout
292+
end
289293
end
290294

291295
test "attacks are not prevented if libzen can't be loaded" do

0 commit comments

Comments
 (0)