Skip to content

Commit 0502a7b

Browse files
author
David Linko
committed
updated to safer literal_eval
1 parent d953456 commit 0502a7b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

anms-core/anms/routes/ARIs/reports.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# subcontract 1658085.
2323
#
2424
from typing import List
25+
import ast
2526

2627
from fastapi import APIRouter, Depends
2728
from fastapi import status
@@ -113,7 +114,12 @@ async def report_ac(agent_id: int, nonce_cbor: str):
113114
ari = None
114115
dec = ace.ari_cbor.Decoder()
115116
enc = ace.ari_text.Encoder()
116-
nonce_cbor = eval(nonce_cbor)
117+
try:
118+
nonce_cbor = ast.literal_eval(nonce_cbor)
119+
except Exception as e:
120+
logger.error(f"{e} while processing nonce")
121+
return []
122+
117123
agent_id_str =""
118124
agent_id_stmt = select(RegisteredAgent).where(RegisteredAgent.registered_agents_id == agent_id)
119125
async with get_async_session() as session:

0 commit comments

Comments
 (0)