Skip to content

Agent Zero AI framework

fix: python.lang.security.audit.eval-detected.eval-detected-python-helpers-memory.py (#444)

Harshitde39128e7ddd
diff --git a/python/helpers/memory.py b/python/helpers/memory.py
index 60e60e2d3..a56cd9cfb 100644
--- a/python/helpers/memory.py
+++ b/python/helpers/memory.py
@@ -1,3 +1,4 @@
+import ast
from datetime import datetime
from typing import Any, List, Sequence
from langchain.storage import InMemoryByteStore, LocalFileStore
@@ -391,7 +392,7 @@ class Memory:
def _get_comparator(condition: str):
def comparator(data: dict[str, Any]):
try:
- return eval(condition, {}, data)
+ return ast.literal_eval(condition, {}, data)
except Exception as e:
# PrintStyle.error(f"Error evaluating condition: {e}")
return False