Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复会话管理存在的sql注入风险 #1299 #1300

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions sql/db_diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ def create_kill_session(request):
if AliyunRdsConfig.objects.filter(instance=instance, is_enable=True).exists():
result = aliyun_create_kill_session(request)
else:
thread_ids = thread_ids.replace('[', '').replace(']', '')
thread_ids = json.loads(thread_ids)
query_engine = get_engine(instance=instance)
sql = "select concat('kill ', id, ';') from information_schema.processlist where id in ({});".format(thread_ids)
sql = "select concat('kill ', id, ';') from information_schema.processlist where id in ({});"\
.format(','.join(str(tid) for tid in thread_ids))
all_kill_sql = query_engine.query('information_schema', sql)
kill_sql = ''
for row in all_kill_sql.rows:
Expand Down Expand Up @@ -99,9 +100,10 @@ def kill_session(request):
if AliyunRdsConfig.objects.filter(instance=instance, is_enable=True).exists():
result = aliyun_kill_session(request)
else:
thread_ids = thread_ids.replace('[', '').replace(']', '')
thread_ids = json.loads(thread_ids)
engine = get_engine(instance=instance)
sql = "select concat('kill ', id, ';') from information_schema.processlist where id in ({});".format(thread_ids)
sql = "select concat('kill ', id, ';') from information_schema.processlist where id in ({});"\
.format(','.join(str(tid) for tid in thread_ids))
all_kill_sql = engine.query('information_schema', sql)
kill_sql = ''
for row in all_kill_sql.rows:
Expand Down