Spaces:
Running
Running
SilverElixir commited on
Commit ·
27a3176
1
Parent(s): c4afae5
Optional mention gate for group TikTok links, stop logging user text
Browse files- lumen_message_core.py +8 -3
- lumen_streaming.py +1 -1
lumen_message_core.py
CHANGED
|
@@ -264,6 +264,11 @@ def _should_only_record_passively(message: Message, t: str, *, is_private: bool,
|
|
| 264 |
if is_private or is_guest or mentioned:
|
| 265 |
return False
|
| 266 |
url = extract_url(t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
return not url or not is_tiktok(url)
|
| 268 |
|
| 269 |
|
|
@@ -482,8 +487,8 @@ async def _handle_message_core(message: Message, extra_media: list[tuple[bytes,
|
|
| 482 |
clean_prompt = bot.clean_mention(t).strip()
|
| 483 |
|
| 484 |
if clean_prompt and _looks_like_injection_probe(clean_prompt):
|
| 485 |
-
# Инъекция: отвечаем без LLM
|
| 486 |
-
log.warning('[injection-probe] Blocked a prompt-injection attempt in chat %s
|
| 487 |
await bot._safe_reply(message, bot._t(message.chat.id, "injection_probe_reply"))
|
| 488 |
return
|
| 489 |
|
|
@@ -545,7 +550,7 @@ async def _handle_message_core(message: Message, extra_media: list[tuple[bytes,
|
|
| 545 |
media_tuple = None
|
| 546 |
if _looks_like_injection_probe(clean_prompt):
|
| 547 |
# Голосовой транскрипт дописывается после первого префильтра (аудит A3-1).
|
| 548 |
-
log.warning('[injection-probe] Blocked a prompt-injection attempt in chat %s
|
| 549 |
await bot._safe_reply(message, bot._t(message.chat.id, "injection_probe_reply"))
|
| 550 |
return
|
| 551 |
|
|
|
|
| 264 |
if is_private or is_guest or mentioned:
|
| 265 |
return False
|
| 266 |
url = extract_url(t)
|
| 267 |
+
if url and is_tiktok(url):
|
| 268 |
+
import bot
|
| 269 |
+
# Групповой TikTok без обращения по умолчанию качается (удобство шаринга);
|
| 270 |
+
# TIKTOK_GROUP_REQUIRE_MENTION=1 оставляет только запись в фон (аудит H2, 10.2026).
|
| 271 |
+
return bool(bot.TIKTOK_GROUP_REQUIRE_MENTION)
|
| 272 |
return not url or not is_tiktok(url)
|
| 273 |
|
| 274 |
|
|
|
|
| 487 |
clean_prompt = bot.clean_mention(t).strip()
|
| 488 |
|
| 489 |
if clean_prompt and _looks_like_injection_probe(clean_prompt):
|
| 490 |
+
# Инъекция: отвечаем без LLM. Текст в лог не пишем, только длину (аудит M5, 10.2026).
|
| 491 |
+
log.warning('[injection-probe] Blocked a prompt-injection attempt in chat %s (prompt_len=%d)', message.chat.id, len(clean_prompt))
|
| 492 |
await bot._safe_reply(message, bot._t(message.chat.id, "injection_probe_reply"))
|
| 493 |
return
|
| 494 |
|
|
|
|
| 550 |
media_tuple = None
|
| 551 |
if _looks_like_injection_probe(clean_prompt):
|
| 552 |
# Голосовой транскрипт дописывается после первого префильтра (аудит A3-1).
|
| 553 |
+
log.warning('[injection-probe] Blocked a prompt-injection attempt in chat %s (prompt_len=%d)', message.chat.id, len(clean_prompt))
|
| 554 |
await bot._safe_reply(message, bot._t(message.chat.id, "injection_probe_reply"))
|
| 555 |
return
|
| 556 |
|
lumen_streaming.py
CHANGED
|
@@ -282,7 +282,7 @@ async def _run_streaming_reply(
|
|
| 282 |
# Проверяем ДО edit_text — утечка не успевает "мигнуть" на экране.
|
| 283 |
tag = "identity-leak" if leak_kind == "identity" else "injection-echo"
|
| 284 |
log.warning(
|
| 285 |
-
'[%s] Stream %s/%s started leaking internal details/echoing an injected instruction — aborting the stream and showing a neutral reply instead
|
| 286 |
)
|
| 287 |
aclose = getattr(piece_agen, "aclose", None)
|
| 288 |
if aclose is not None:
|
|
|
|
| 282 |
# Проверяем ДО edit_text — утечка не успевает "мигнуть" на экране.
|
| 283 |
tag = "identity-leak" if leak_kind == "identity" else "injection-echo"
|
| 284 |
log.warning(
|
| 285 |
+
'[%s] Stream %s/%s started leaking internal details/echoing an injected instruction — aborting the stream and showing a neutral reply instead (accumulated_len=%d)', tag, provider, model_id, len(full_text),
|
| 286 |
)
|
| 287 |
aclose = getattr(piece_agen, "aclose", None)
|
| 288 |
if aclose is not None:
|