Skip to content

Commit

Permalink
修复注入漏洞
Browse files Browse the repository at this point in the history
  • Loading branch information
myhhub committed Dec 12, 2024
1 parent 515a78b commit 13cbc64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions instock/web/dataIndicatorsHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ def get(self):
try:
table_name = tbs.TABLE_CN_STOCK_ATTENTION['name']
if otype == '1':
sql = f"DELETE FROM `{table_name}` WHERE `code` = '{code}'"
# sql = f"DELETE FROM `{table_name}` WHERE `code` = '{code}'"
sql = f"DELETE FROM `{table_name}` WHERE `code` = %s"
self.db.query(sql,code)
else:
sql = f"INSERT INTO `{table_name}`(`datetime`, `code`) VALUE('{datetime.datetime.now()}','{code}')"
self.db.query(sql)
# sql = f"INSERT INTO `{table_name}`(`datetime`, `code`) VALUE('{datetime.datetime.now()}','{code}')"
sql = f"INSERT INTO `{table_name}`(`datetime`, `code`) VALUE(%s, %s)"
self.db.query(sql,datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),code)
except Exception as e:
err = {"error": str(e)}
logging.info(err)
self.write(err)
return
# logging.info(err)
# self.write(err)
# return
self.write("{\"data\":[{}]}")
6 changes: 4 additions & 2 deletions instock/web/dataTableHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ def get(self):
date = self.get_argument("date", default=None, strip=False)
web_module_data = sswmd.stock_web_module_data().get_data(name)
self.set_header('Content-Type', 'application/json;charset=UTF-8')

if date is None:
where = ""
else:
where = f" WHERE `date` = '{date}'"
# where = f" WHERE `date` = '{date}'"
where = f" WHERE `date` = %s"

order_by = ""
if web_module_data.order_by is not None:
Expand All @@ -64,6 +66,6 @@ def get(self):
order_columns = f",{web_module_data.order_columns}"

sql = f" SELECT *{order_columns} FROM `{web_module_data.table_name}`{where}{order_by}"
data = self.db.query(sql,date)

data = self.db.query(sql)
self.write(json.dumps(data, cls=MyEncoder))
2 changes: 1 addition & 1 deletion instock/web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ <h3>功能介绍</h3>
二日K线模式,分多头母子与空头母子,两者相反,以多头母子为例,在下跌趋势中,第一日K线长阴, 第二日开盘价收盘价在第一日价格振幅之内,为阳线,预示趋势反转,股价上升。

27、十字孕线
二日K线模式,与母子县类似,若第二日K线是十字线, 便称为十字孕线,预示着趋势反转。
二日K线模式,与母子线类似,若第二日K线是十字线, 便称为十字孕线,预示着趋势反转。

28、风高浪大线
三日K线模式,具有极长的上/下影线与短的实体,预示着趋势反转。
Expand Down

0 comments on commit 13cbc64

Please sign in to comment.