e833b923c8
接入 Playwright Worker、会话 WebSocket 与全局浏览器面板(固定于 App Bar 下); 含验证码 stealth、设置项默认音与 URL 安全校验;附带 worker 部署与设计文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
764 B
Python
31 lines
764 B
Python
"""SSRF URL validation for remote browser."""
|
|
|
|
import pytest
|
|
|
|
from server.utils.browser_url_safe import validate_navigation_url
|
|
|
|
|
|
def test_accepts_https_public():
|
|
url, err = validate_navigation_url("https://example.com/path")
|
|
assert err is None
|
|
assert url is not None
|
|
assert url.startswith("https://example.com")
|
|
|
|
|
|
def test_rejects_javascript():
|
|
url, err = validate_navigation_url("javascript:alert(1)")
|
|
assert url is None
|
|
assert err is not None
|
|
|
|
|
|
def test_rejects_localhost():
|
|
url, err = validate_navigation_url("http://127.0.0.1")
|
|
assert url is None
|
|
assert err is not None
|
|
|
|
|
|
def test_rejects_private_ip_literal():
|
|
url, err = validate_navigation_url("http://10.0.0.1")
|
|
assert url is None
|
|
assert err is not None
|