Skip to content

Commit 0ccf47d

Browse files
committed
fix: Fix possible SQL injection vulnerabilities
1 parent c3d4c64 commit 0ccf47d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

backend/apps/db/db.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ def get_schema(ds: CoreDatasource):
233233
with get_session(ds) as session:
234234
sql: str = ''
235235
if ds.type == "sqlServer":
236-
sql = f"""select name from sys.schemas"""
236+
sql = """select name from sys.schemas"""
237237
elif ds.type == "pg" or ds.type == "excel":
238238
sql = """SELECT nspname
239239
FROM pg_namespace"""
240240
elif ds.type == "oracle":
241-
sql = f"""select * from all_users"""
241+
sql = """select * from all_users"""
242242
with session.execute(text(sql)) as result:
243243
res = result.fetchall()
244244
res_list = [item[0] for item in res]
@@ -247,15 +247,15 @@ def get_schema(ds: CoreDatasource):
247247
if ds.type == 'dm':
248248
with dmPython.connect(user=conf.username, password=conf.password, server=conf.host,
249249
port=conf.port) as conn, conn.cursor() as cursor:
250-
cursor.execute(f"""select OBJECT_NAME from dba_objects where object_type='SCH'""", timeout=conf.timeout)
250+
cursor.execute("""select OBJECT_NAME from dba_objects where object_type='SCH'""", timeout=conf.timeout)
251251
res = cursor.fetchall()
252252
res_list = [item[0] for item in res]
253253
return res_list
254254
elif ds.type == 'redshift':
255255
with redshift_connector.connect(host=conf.host, port=conf.port, database=conf.database, user=conf.username,
256256
password=conf.password,
257257
timeout=conf.timeout) as conn, conn.cursor() as cursor:
258-
cursor.execute(f"""SELECT nspname FROM pg_namespace""")
258+
cursor.execute("""SELECT nspname FROM pg_namespace""")
259259
res = cursor.fetchall()
260260
res_list = [item[0] for item in res]
261261
return res_list

backend/apps/db/db_sql.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55

66
def get_version_sql(ds: CoreDatasource, conf: DatasourceConf):
77
if ds.type == "mysql" or ds.type == "doris":
8-
return f"""
8+
return """
99
SELECT VERSION()
1010
"""
1111
elif ds.type == "sqlServer":
12-
return f"""
12+
return """
1313
select SERVERPROPERTY('ProductVersion')
1414
"""
1515
elif ds.type == "pg" or ds.type == "excel":
16-
return f"""
16+
return """
1717
SELECT current_setting('server_version')
1818
"""
1919
elif ds.type == "oracle":
20-
return f"""
20+
return """
2121
SELECT version FROM v$instance
2222
"""
2323
elif ds.type == "ck":
24-
return f"""
24+
return """
2525
select version()
2626
"""
2727
elif ds.type == 'dm':
28-
return f"""
28+
return """
2929
SELECT * FROM v$version
3030
"""
3131
elif ds.type == 'redshift':

0 commit comments

Comments
 (0)