Skip to content

Commit cfeac7d

Browse files
committed
get tests working cp 2
Signed-off-by: Joe P <joe@basicmemory.com>
1 parent ae34978 commit cfeac7d

2 files changed

Lines changed: 355 additions & 17 deletions

File tree

src/basic_memory/mcp/tools/read_note.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from basic_memory.mcp.tools.utils import call_get
1212
from basic_memory.mcp.project_session import get_active_project
1313
from basic_memory.schemas.memory import memory_url_path
14+
from basic_memory.utils import validate_project_path
1415

1516

1617
@mcp.tool(
@@ -55,6 +56,20 @@ async def read_note(
5556
# Get the active project first to check project-specific sync status
5657
active_project = get_active_project(project)
5758

59+
# Validate identifier to prevent path traversal attacks
60+
# We need to check both the raw identifier and the processed path
61+
processed_path = memory_url_path(identifier)
62+
project_path = active_project.home
63+
64+
if not validate_project_path(identifier, project_path) or not validate_project_path(processed_path, project_path):
65+
logger.warning(
66+
"Attempted path traversal attack blocked",
67+
identifier=identifier,
68+
processed_path=processed_path,
69+
project=active_project.name,
70+
)
71+
return f"# Error\n\nIdentifier '{identifier}' is not allowed - paths must stay within project boundaries"
72+
5873
# Check migration status and wait briefly if needed
5974
from basic_memory.mcp.tools.utils import wait_for_migration_or_return_status
6075

0 commit comments

Comments
 (0)