fix(im): harden Yunzhijia image download and prune dead validation

- Follow a single download redirect while re-validating the target stays
  within the allowed host suffix; never forward the bearer token across it.
  The shared http client disables auto-redirects for SSRF safety, so a 302
  from downloadfileOpen previously failed the download outright.
- Cap in-memory download size at 32 MiB via a limited read-closer that
  errors instead of silently truncating, avoiding OOM on large responses.
- Remove dead frontend host-suffix validation branch (normalize always
  fills the default) and drop the now-unused i18n keys
  yunzhijiaAllowedHostSuffixRequired / yunzhijiaRequiredCredentials.
- Add tests for redirect follow/reject and the size limit.
This commit is contained in:
wizardchen
2026-07-23 12:34:36 +08:00
committed by lyingbug
parent 85c9b61ad0
commit 0869f3e829
7 changed files with 211 additions and 21 deletions
+2 -4
View File
@@ -1034,15 +1034,13 @@ async function handleSave() {
return;
}
if (formData.value.platform === 'yunzhijia') {
// normalize fills in the default allowed host suffix, so only the send URL
// needs explicit validation here.
normalizeYunzhijiaCredentials();
if (!String(formData.value.credentials.send_msg_url || '').trim()) {
MessagePlugin.warning(t('agentEditor.im.yunzhijiaSendMsgUrlRequired'));
return;
}
if (!String(formData.value.credentials.allowed_webhook_host_suffix || '').trim()) {
MessagePlugin.warning(t('agentEditor.im.yunzhijiaAllowedHostSuffixRequired'));
return;
}
}
if (editingChannel.value) {
-2
View File
@@ -5985,9 +5985,7 @@ export default {
yunzhijiaTimeoutHint: 'Timeout for sending replies via Send Message URL, default 10 seconds',
yunzhijiaAllowedHostSuffix: 'Allowed Host Suffix',
yunzhijiaAllowedHostSuffixHint: 'Restrict Send Message URL host to this suffix for security (e.g. yunzhijia.com)',
yunzhijiaRequiredCredentials: 'Enter the Send Message URL and allowed host suffix',
yunzhijiaSendMsgUrlRequired: 'Enter the Send Message URL from Yunzhijia robot settings',
yunzhijiaAllowedHostSuffixRequired: 'Enter the allowed host suffix',
mattermostModeHint: 'Mattermost only supports Webhook mode (outgoing webhook + bot token).',
mattermostPostToMain: 'Post replies in channel timeline',
mattermostPostToMainHint:
-2
View File
@@ -5916,9 +5916,7 @@ export default {
yunzhijiaTimeoutHint: "메시지 전송 URL을 통한 응답 전송 타임아웃, 기본 10초",
yunzhijiaAllowedHostSuffix: "허용 호스트 접미사",
yunzhijiaAllowedHostSuffixHint: "보안을 위해 메시지 전송 URL 호스트를 이 접미사로 제한 (예: yunzhijia.com)",
yunzhijiaRequiredCredentials: "메시지 전송 URL과 허용 호스트 접미사를 입력하세요",
yunzhijiaSendMsgUrlRequired: "Yunzhijia 로봇 설정의 메시지 전송 URL을 입력하세요",
yunzhijiaAllowedHostSuffixRequired: "허용 호스트 접미사를 입력하세요",
mattermostModeHint: "Mattermost는 Webhook(아웃고잉 웹훅 + 봇 토큰)만 지원합니다.",
mattermostPostToMain: "답변을 채널 메인 타임라인에 표시",
mattermostPostToMainHint:
-2
View File
@@ -5488,9 +5488,7 @@ export default {
yunzhijiaTimeoutHint: 'Таймаут отправки ответов через URL отправки сообщений, по умолчанию 10 секунд',
yunzhijiaAllowedHostSuffix: 'Допустимый суффикс хоста',
yunzhijiaAllowedHostSuffixHint: 'Ограничить хост URL отправки сообщений этим суффиксом для безопасности (напр. yunzhijia.com)',
yunzhijiaRequiredCredentials: 'Укажите URL отправки сообщений и допустимый суффикс хоста',
yunzhijiaSendMsgUrlRequired: 'Укажите URL отправки сообщений из настроек робота Yunzhijia',
yunzhijiaAllowedHostSuffixRequired: 'Укажите допустимый суффикс хоста',
mattermostModeHint: 'Mattermost поддерживает только режим Webhook (исходящий вебхук + токен бота).',
mattermostPostToMain: 'Ответы в основной ленте канала',
mattermostPostToMainHint:
-2
View File
@@ -5969,9 +5969,7 @@ export default {
yunzhijiaTimeoutHint: "通过发送消息地址回复的超时时间,默认 10 秒",
yunzhijiaAllowedHostSuffix: "允许的主机后缀",
yunzhijiaAllowedHostSuffixHint: "限制发送消息地址的目标域名后缀,提升安全性(如 yunzhijia.com)",
yunzhijiaRequiredCredentials: "请填写发送消息地址和允许的主机后缀",
yunzhijiaSendMsgUrlRequired: "请填写云之家机器人设置中的发送消息地址",
yunzhijiaAllowedHostSuffixRequired: "请填写允许的主机后缀",
mattermostModeHint: "Mattermost 仅支持 Webhook(出站 Webhook + Bot Token)。",
mattermostPostToMain: "回复显示在频道主时间线",
mattermostPostToMainHint: