Removed eval, fixed security vulnerability

This commit is contained in:
mirai
2023-11-27 05:45:45 +03:00
parent 5506b2d8a6
commit 8c4799c634
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -1,3 +1,4 @@
import ast
from sanic import Websocket
from cmd_chat.server.models import Message
@@ -5,7 +6,8 @@ from cmd_chat.server.models import Message
async def _get_bytes_and_serialize(
ws: Websocket
) -> dict:
return eval(await ws.recv())
ws_data = await ws.recv()
return ast.literal_eval(ws_data.decode('utf-8'))
async def _check_ws_for_close_status(