fix(db_query): relax some restrictions (#37314)

Allow valid identifiers

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2026-02-23 12:21:26 +05:30 committed by GitHub
parent 5b09a76606
commit 04b2a433b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -500,7 +500,11 @@ from {tables}
if (name := (token.get_name())) and name.lower() in blacklisted_functions:
_raise_exception()
if token.ttype in (tokens.Keyword, tokens.Name):
if token.ttype in tokens.Keyword:
if any(re.search(rf"\b{kw}\b", token.value.lower()) for kw in blacklisted_keywords):
_raise_exception()
if token.ttype in tokens.Name and not re.match(r"^`\w.*`$", token.value.strip()):
if any(re.search(rf"\b{kw}\b", token.value.lower()) for kw in blacklisted_keywords):
_raise_exception()