Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix(security): address review feedback on ReDoS and URL pattern fixes

KaifAhmad10365712a8b98
diff --git a/semantica/ingest/email_ingestor.py b/semantica/ingest/email_ingestor.py
index 0f16d9df..0b453def 100644
--- a/semantica/ingest/email_ingestor.py
+++ b/semantica/ingest/email_ingestor.py
@@ -392,7 +392,7 @@ class EmailParser:
# Extract URLs from text using regex
import re
- url_pattern = r"https?://(?:[a-zA-Z0-9]|[$\-_.&+!*(),]|(?:%[0-9a-fA-F]{2}))+"
+ url_pattern = r"https?://(?:[a-zA-Z0-9\-._~!$&'()*+,;=:@/?#\[\]]|%[0-9a-fA-F]{2})+"
text_links = re.findall(url_pattern, email_content)
links.extend(text_links)
diff --git a/semantica/ontology/naming_conventions.py b/semantica/ontology/naming_conventions.py
index 2d4e0e39..51a0d462 100644
--- a/semantica/ontology/naming_conventions.py
+++ b/semantica/ontology/naming_conventions.py
@@ -350,7 +350,7 @@ class NamingConventions:
def _is_noun_phrase(self, name: str) -> bool:
"""Check if name is a noun phrase (basic heuristic)."""
# Basic heuristic: PascalCase words are typically nouns
- return bool(re.match(r"^[A-Z][a-zA-Z0-9]*(?:[A-Z][a-zA-Z0-9]*)*$", name))
+ return bool(name and name[0].isupper() and re.match(r"^[A-Za-z0-9]+$", name))
def _is_verb_phrase(self, name: str) -> bool:
"""Check if name is a verb phrase (basic heuristic)."""