Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

[Fix] Enhanced security for OpenAPI and JSON Loader Integration (#1122)

YusukeJustinNakajimaf7696d1dc17e
diff --git a/embedchain/loaders/json.py b/embedchain/loaders/json.py
index 2d090f684..fc0a649cc 100644
--- a/embedchain/loaders/json.py
+++ b/embedchain/loaders/json.py
@@ -35,7 +35,7 @@ class JSONReader:
return ["\n".join(useful_lines)]
-VALID_URL_PATTERN = "^https:\/\/[0-9A-z.]+.[0-9A-z.]+.[a-z]+\/.*\.json$"
+VALID_URL_PATTERN = "^https:\/\/[0-9A-Za-z]+(\.[0-9A-Za-z]+)*\/[0-9A-Za-z_\/]*\.json$"
class JSONLoader(BaseLoader):
diff --git a/embedchain/loaders/openapi.py b/embedchain/loaders/openapi.py
index f898b8efb..0f2164f95 100644
--- a/embedchain/loaders/openapi.py
+++ b/embedchain/loaders/openapi.py
@@ -32,7 +32,7 @@ class OpenAPILoader(BaseLoader):
file_path = content
data_content = []
with OpenAPILoader._get_file_content(content=content) as file:
- yaml_data = yaml.load(file, Loader=yaml.Loader)
+ yaml_data = yaml.load(file, Loader=yaml.SafeLoader)
for i, (key, value) in enumerate(yaml_data.items()):
string_data = f"{key}: {value}"
meta_data = {"url": file_path, "row": i + 1}