fix(qq): keep inbound URL validation off the event loop

Add mixed-DNS, invalid-scheme, cancellation and partial-write coverage. Isolate media roots for activated QQ tests.
This commit is contained in:
Xubin Ren committed 2026-09-15 13:49:49 +08:00
1 parent 9d106bd44d
commit 0afebd4747
3 files changed
+82 -1

No files matched your search

+2 -1
View File
@@ -678,7 +678,8 @@ class QQChannel(BaseChannel):
# Inbound attachment URLs are attacker-influenceable (a compromised or
# redirecting CDN can point at an internal address), so validate them
# like outbound media and refuse redirects — matching napcat/dingtalk.
ok, err = validate_url_target(url)
# The guard resolves DNS synchronously; do not block the gateway loop.
ok, err = await asyncio.to_thread(validate_url_target, url)
if not ok:
self.logger.warning("inbound media URL blocked url={} err={}", url, err)
return None
+8
View File
@@ -0,0 +1,8 @@
"""Keep QQ channel tests out of the user's configured media directory."""
import pytest
@pytest.fixture(autouse=True)
def _isolated_media_root(tmp_path, monkeypatch):
monkeypatch.setattr("nanobot.channels.qq.runtime.get_media_dir", lambda *_: tmp_path)