Skip to content

Commit 582d535

Browse files
committed
chore: acknowledge the injection
1 parent 119b542 commit 582d535

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ibis/backends/mssql/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ def _get_schema_using_query(self, query: str) -> sch.Schema:
319319
# us to pre-filter the columns we want back.
320320
# The syntax is:
321321
# `sys.dm_exec_describe_first_result_set(@tsql, @params, @include_browse_information)`
322+
#
323+
# Yes, this *is* a SQL injection risk, but it's not clear how to avoid
324+
# that since we allow users to pass arbitrary SQL.
325+
#
326+
# SQLGlot has a bug that forces capitalization of
327+
# `dm_exec_describe_first_result_set`, so we can't even use its builder
328+
# APIs. That doesn't really solve the injection problem though.
322329
query = f"""
323330
SELECT
324331
name,
@@ -330,7 +337,7 @@ def _get_schema_using_query(self, query: str) -> sch.Schema:
330337
error_message
331338
FROM sys.dm_exec_describe_first_result_set(N{tsql}, NULL, 0)
332339
ORDER BY column_ordinal
333-
"""
340+
""" # noqa: S608
334341
with self._safe_raw_sql(query) as cur:
335342
rows = cur.fetchall()
336343

0 commit comments

Comments
 (0)