From 475ce4b6a9ad370affcb16679da4d90a9dcc2df4 Mon Sep 17 00:00:00 2001 From: Adrianna Chang Date: Fri, 27 Oct 2023 08:43:30 -0400 Subject: [PATCH] Fix regex in Mysql2 adapter --- lib/semian/mysql2.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/semian/mysql2.rb b/lib/semian/mysql2.rb index 31d41045..e26ebd85 100644 --- a/lib/semian/mysql2.rb +++ b/lib/semian/mysql2.rb @@ -37,11 +37,7 @@ module Mysql2 DEFAULT_HOST = "localhost" DEFAULT_PORT = 3306 - QUERY_WHITELIST = Regexp.union( - %r{\A(?:/\*.*?\*/)?\s*ROLLBACK}i, - %r{\A(?:/\*.*?\*/)?\s*COMMIT}i, - %r{\A(?:/\*.*?\*/)?\s*RELEASE\s+SAVEPOINT}i, - ) + QUERY_ALLOWLIST = %r{\A(?:/\*.*?\*/)?\s*(ROLLBACK|COMMIT|RELEASE\s+SAVEPOINT)}i class << self # The naked methods are exposed as `raw_query` and `raw_connect` for instrumentation purpose @@ -114,7 +110,7 @@ def resource_exceptions end def query_whitelisted?(sql, *) - QUERY_WHITELIST =~ sql + QUERY_ALLOWLIST =~ sql rescue ArgumentError # The above regexp match can fail if the input SQL string contains binary # data that is not recognized as a valid encoding, in which case we just