mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
fix: check sql only contain read operation #814
This commit is contained in:
@@ -10,6 +10,7 @@ from typing import Optional
|
||||
import oracledb
|
||||
import psycopg2
|
||||
import pymssql
|
||||
import re
|
||||
|
||||
from apps.db.db_sql import get_table_sql, get_field_sql, get_version_sql
|
||||
from common.error import ParseSQLResultError
|
||||
@@ -578,6 +579,8 @@ def exec_sql(ds: CoreDatasource | AssistantOutDsSchema, sql: str, origin_column=
|
||||
|
||||
def check_sql_read(sql: str, dialect=None):
|
||||
try:
|
||||
ansi_escape = re.compile(r'\x1b\[[0-9;]*m')
|
||||
sql = ansi_escape.sub('', sql)
|
||||
|
||||
statements = sqlglot.parse(sql, dialect=dialect)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user