mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
- fix(redos) #10: replace capturing group with non-capturing group in naming_conventions.py to eliminate exponential backtracking (py/redos) - fix(html-filter) #4: update script/iframe end-tag regex to match tags with trailing attributes e.g. </script foo="bar"> (py/bad-tag-filter) - fix(regex-range) #9: replace overly broad [$-_] character range with explicit safe-char list in email_ingestor.py URL pattern (py/overly-large-range) - fix(info-exposure) #5: replace str(exc) with a generic error message and log the full stack trace server-side in export_import.py (py/stack-trace-exposure) Closes #4, Closes #5, Closes #9, Closes #10 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0f1d262327
commit
f7170cd6df
@@ -5,7 +5,7 @@ Export & import routes.
|
||||
import asyncio
|
||||
import io
|
||||
import json
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
from typing import Optional
|
||||
@@ -13,6 +13,8 @@ from typing import Optional
|
||||
from fastapi import APIRouter, Depends, File, UploadFile
|
||||
from fastapi.responses import Response
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from ..dependencies import get_session, get_ws_manager
|
||||
from ..schemas import ExportRequest
|
||||
from ..session import GraphSession
|
||||
@@ -229,7 +231,8 @@ async def import_file(
|
||||
"detail": f"File type not supported yet: {filename}",
|
||||
}
|
||||
except Exception as exc:
|
||||
result = {"status": "error", "detail": str(exc)}
|
||||
logger.exception("Import failed")
|
||||
result = {"status": "error", "detail": "An internal error occurred during import"}
|
||||
|
||||
await ws.broadcast("import_completed", result)
|
||||
return result
|
||||
|
||||
@@ -392,7 +392,7 @@ class EmailParser:
|
||||
# Extract URLs from text using regex
|
||||
import re
|
||||
|
||||
url_pattern = r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+"
|
||||
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)
|
||||
|
||||
|
||||
@@ -302,10 +302,10 @@ class TextCleaner:
|
||||
|
||||
# Remove potential script tags
|
||||
text = re.sub(
|
||||
r"<script[^>]*>.*?</script>", "", text, flags=re.IGNORECASE | re.DOTALL
|
||||
r"<script[^>]*>.*?</script(?:\s[^>]*)?>", "", text, flags=re.IGNORECASE | re.DOTALL
|
||||
)
|
||||
text = re.sub(
|
||||
r"<iframe[^>]*>.*?</iframe>", "", text, flags=re.IGNORECASE | re.DOTALL
|
||||
r"<iframe[^>]*>.*?</iframe(?:\s[^>]*)?>", "", text, flags=re.IGNORECASE | re.DOTALL
|
||||
)
|
||||
|
||||
# Remove javascript: URLs
|
||||
|
||||
@@ -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(re.match(r"^[A-Z][a-zA-Z0-9]*(?:[A-Z][a-zA-Z0-9]*)*$", name))
|
||||
|
||||
def _is_verb_phrase(self, name: str) -> bool:
|
||||
"""Check if name is a verb phrase (basic heuristic)."""
|
||||
|
||||
Reference in New Issue
Block a user