From 184e76ebc2b0d33996b3a642aec9a0ea379b2f46 Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 29 Jan 2026 14:09:12 +0800 Subject: [PATCH] fix: check sql only contain read operation #814 --- backend/apps/db/db.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py index 2f3c8b8a..7a9973b3 100644 --- a/backend/apps/db/db.py +++ b/backend/apps/db/db.py @@ -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)