forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_security_hotfix.py
More file actions
37 lines (26 loc) 路 1.07 KB
/
Copy pathtest_security_hotfix.py
File metadata and controls
37 lines (26 loc) 路 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Tests for security hotfix: path traversal, XSS, secret redaction."""
import pytest
from pathlib import Path
import sys
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
from mcp_server import handle_get_lesson
def test_path_traversal_blocked():
"""Path traversal attempts should be blocked."""
result = handle_get_lesson({"path": "../../etc/passwd"})
assert "error" in result
def test_git_config_blocked():
"""Access to .git/config should be blocked."""
result = handle_get_lesson({"path": ".git/config"})
assert "error" in result
def test_non_md_blocked():
"""Non-.md files should be blocked."""
result = handle_get_lesson({"path": "package.json"})
assert "error" in result
def test_valid_lesson_allowed():
"""Valid lesson paths should be allowed."""
result = handle_get_lesson({"path": "lessons/core/dco-auto-fix-workflow.md"})
assert "content" in result
def test_lesson_id_allowed():
"""Lesson ID lookup should work."""
result = handle_get_lesson({"id": "dco-auto-fix-workflow"})
assert "content" in result