fix: CWE problem in recommend_questions

This commit is contained in:
ulleo
2026-08-03 16:47:33 +08:00
committed by ulleo
parent 4c6fce89e9
commit 6a175b0124
+16
View File
@@ -196,6 +196,14 @@ async def ask_recommend_questions(session: SessionDep, current_user: CurrentUser
if not record:
return StreamingResponse(_return_empty(), media_type="text/event-stream")
chat = session.get(Chat, record.chat_id)
if not chat:
return StreamingResponse(_return_empty(), media_type="text/event-stream")
if chat.oid != current_user.oid:
raise Exception(f"Chat Record with id {chat_record_id} does not belong to current workspace")
if chat.create_by != current_user.id:
raise Exception(f"Chat Record with id {chat_record_id} not Owned by the current user")
request_question = ChatQuestion(chat_id=record.chat_id, question=record.question if record.question else '')
llm_service = await LLMService.create(session, current_user, request_question, current_assistant, True)
@@ -404,6 +412,14 @@ async def analysis_or_predict(session: SessionDep, current_user: CurrentUser, ch
if not record:
raise Exception(f"Chat record with id {chat_record_id} not found")
chat = session.get(Chat, record.chat_id)
if not chat:
raise Exception(f"Chat with id {chat.id} not found")
if chat.oid != current_user.oid:
raise Exception(f"Chat Record with id {chat_record_id} does not belong to current workspace")
if chat.create_by != current_user.id:
raise Exception(f"Chat Record with id {chat_record_id} not Owned by the current user")
if not record.chart:
raise Exception(
f"Chat record with id {chat_record_id} has not generated chart, do not support to analyze it")