fix: python.lang.security.audit.eval-detected.eval-detected-python-helpers-memory.py (#444)
Co-authored-by: Harshit-65 <kira@offgridsec.com>
Harshit committed
Jun 13, 2025 at 17:10 UTC
de39128e7ddd1466d0e143261f004958e6f09238
1 file changed
+2
-1
python/helpers/memory.py
+2
-1
@@ -1,3 +1,4 @@
1
+import ast
2
from datetime import datetime
3
from typing import Any, List, Sequence
4
from langchain.storage import InMemoryByteStore, LocalFileStore
@@ -391,7 +392,7 @@ class Memory:
392
def _get_comparator(condition: str):
393
def comparator(data: dict[str, Any]):
394
try:
394
- return eval(condition, {}, data)
395
+ return ast.literal_eval(condition, {}, data)
396
except Exception as e:
397
# PrintStyle.error(f"Error evaluating condition: {e}")
398
return False