modelcontextprotocol / modelcontextprotocol/python-sdk

test_safe_join_rejects_symlink_escape fails on Windows without elevation or Developer Mode

Đang mở Phù hợp với người mới
#3,408 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

v2
Ngôn ngữ chính
Python
Star
24.3k
Fork
4k
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
31

Mô tả

Initial Checks
Release line

2.x (current stable)

Description

Running the test suite on Windows as a normal, non-elevated user fails in
tests/shared/test_path_security.py:

tests\shared\test_path_security.py:145: in test_safe_join_rejects_symlink_escape
    (sandbox / "escape").symlink_to(outside)
E   OSError: [WinError 1314] A required privilege is not held by the client

The test creates a symlink unconditionally. Windows only permits symlink creation for an
elevated process, or for a normal user with Developer Mode enabled — neither is the
default state of a Windows machine.

Why CI doesn't catch it: the Windows job in .github/workflows/shared.yml is green, and
this test only passes when symlink_to() succeeds, so those runners evidently do have the
privilege. The failure appears only on an ordinary developer machine, so the suite is
permanently green in CI and permanently red locally.

Why it matters: it denies a Windows contributor a clean baseline. A first uv run pytest
returns a failure unrelated to their change, and the natural assumption — that their own
setup is broken — costs time. Everything else passes: 5791 passed, 1 failed, 16 skipped.
It also weakens the suite's signal, since someone who learns to expect one red test may
not notice a second.

Suggested fix — skip when the platform refuses, leaving every assertion intact so the
test still exercises safe_join wherever symlinks work, including all current CI:

try:
    (sandbox / "escape").symlink_to(outside)
except OSError as exc:
    pytest.skip(f"symlink creation is not permitted here: {exc}")

This is the only test in the suite that creates a symlink. I have this prepared and
verified locally (suite goes to 0 failures; the test skips for the right reason rather
than passing vacuously). Happy to open a PR — following CONTRIBUTING, I'll wait for the
issue to be assigned first.

Example Code
git clone https://github.com/modelcontextprotocol/python-sdk
cd python-sdk
uv sync
uv run pytest tests/shared/test_path_security.py
Python & MCP Python SDK
Python 3.14.7 | Windows-11-10.0.26200-SP0
mcp 2.0.1.dev23+56af447
mcp-types 2.0.1.dev23+56af447
pytest 8.4.2

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Mở tests/shared/test_path_security.py và kiểm tra test_safe_join_rejects_symlink_escape quanh dòng 145. Chạy uv run pytest tests/shared/test_path_security.py trên một máy Windows không có quyền symlink, sau đó xác minh rằng test chỉ bị bỏ qua khi việc tạo symlink bị từ chối và bộ test không có lỗi khi symlink khả dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
testing-qa
Loại issue
Lỗi
Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
88/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.