Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cycode/cli/apps/mcp/mcp_command.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@
import uuid
from typing import Annotated, Any, Optional

import anyio
import typer
from pathvalidate import sanitize_filepath
from pydantic import Field
Expand DownExpand Up@@ -65,6 +66,7 @@ def _get_current_executable() -> str:
return 'cycode'


# ruff: disable[ASYNC109]
async def _run_cycode_command(*args: str, timeout: int = _DEFAULT_RUN_COMMAND_TIMEOUT) -> dict[str, Any]:
"""Run a cycode command asynchronously and return the parsed result.

Expand DownExpand Up@@ -109,6 +111,9 @@ async def _run_cycode_command(*args: str, timeout: int = _DEFAULT_RUN_COMMAND_TI
return {'error': f'Failed to run command: {e!s}'}


# ruff: enable[ASYNC109]


def _sanitize_file_path(file_path: str) -> str:
"""Sanitize file path to prevent path traversal and other security issues.

Expand DownExpand Up@@ -238,7 +243,7 @@ async def _cycode_scan_tool(

try:
if paths:
missing = [p for p in paths if not os.path.exists(p)]
missing = [p for p in paths if not await anyio.Path(p).exists()]
if missing:
return json.dumps({'error': f'Paths not found on disk: {missing}'}, indent=2)

Expand Down
Loading
Loading