agent-Specialization/modules/i18n_messages/api_tasks.py
JOJO 1a4e5baa23 fix(security): Docker 多用户模式全面安全加固(安全审计修复)
威胁模型:拥有普通账号的已登录用户攻击服务器。完整审计报告见
_experiments/security_audit_2026-09-02/(不入库),含实测复现记录。

严重/高危修复:
- 彻底移除文件夹打包下载(/api/download/folder 端点删除,gui/api_v1
  目录下载分支改 410):文件型符号链接会被宿主进程解析,实测可读宿主
  任意文件(含 settings.json 全部 LLM 密钥),删除比补校验更彻底
- XFF 伪造防护:get_client_ip 仅信任 ASTRION_TRUSTED_PROXIES
  (默认空=不信 XFF);登录新增账号维度锁定(5 次失败锁 300s);
  注册邀请码加爆破锁定;限流桶/失败表加 2 万键上限+GC 回收
- auth_debug.log 接入大小轮转;/api/client_debug_log 加限流+长度截断
- /host-login 增加 LINUX_SAFETY 检查且仅回环地址可用

容器加固:
- 默认 cpus=1 / memory=1g,新增 pids-limit=512、memory-swap、
  no-new-privileges
- 新增每用户容器配额 MAX_ACTIVE_CONTAINERS_PER_USER(默认 3),
  防止单用户占满全局容器池

api_v1:
- prompts/personalizations 的 name 加白名单校验(^[A-Za-z0-9_-]{1,64}$),
  修复路径穿越写入;对话元数据中的引用名同步加白名单
- workspaces/conversations/messages/upload 四端点加用户维度限流
- 消息体加 MAX_MESSAGE_CHARS 上限(默认 200000,/api/tasks 同步)
- _path_within 加分隔符边界(修复 startswith 前缀碰撞)

其他:
- SVG 预览强制 application/octet-stream(修存储型 XSS 漏网)
- monitor_snapshot 缓存键加 username 维度(修跨用户快照读取)
- ensure/delete_workspace 加 workspace_id 白名单+父目录二次核验
- delete_folder 拒绝删除工作区根(crud_mixin 与容器代理同步修)
- GuiFileManager 死代码加名称校验防复活
- admin_dashboard 静态壳非 admin 访问一律 404
- /api/app/apk/latest 加登录校验+限流(原未认证可拉 133MB)

有意未修(见报告 7.3 遗留清单):容器 egress 过滤(部署层)、
--cap-drop ALL(怕破坏容器内工作流,已先上 no-new-privileges)、
API 用户/子智能体 LLM 按 token 计费(待产品决策)、str(exc) 收口、
WebSocket 限流、network_permission=restricted 容器语义。

验证:全部文件 py_compile 通过;冒烟测试 6/6 通过;关键新逻辑
(名称校验/路径边界/容器代理删除防护/限流回收)已单测级验证;
端点级行为待服务重启后实测复核(清单见报告 7.5)。

Co-authored-by: Astrion powered by Kimi-K3 <astrion-agent@users.noreply.github.com>
2026-09-02 18:31:00 +08:00

143 lines
5.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""API tasks message pack.
User-visible messages produced by server/tasks/api.py / models.py / skills.py
(REST responses and the error dicts they pass through to the frontend).
Pure data only — do not import anything here; merged into modules.i18n at import time.
Keys are prefixed with ``tasks.``.
"""
MESSAGES = {
# ── api.pyrunning-status / create_task 校验 ──
"tasks.missing_conversation_id": {
"zh-CN": "缺少 conversation_id",
"en-US": "Missing conversation_id",
},
"tasks.message_empty": {
"zh-CN": "消息不能为空",
"en-US": "Message cannot be empty",
},
"tasks.message_too_long": {
"zh-CN": "消息内容过长",
"en-US": "Message is too long",
},
"tasks.workspace_unavailable": {
"zh-CN": "工作区不可用",
"en-US": "Workspace is unavailable",
},
"tasks.read_skill_failed": {
"zh-CN": "读取 skill 失败",
"en-US": "Failed to load skill",
},
"tasks.task_not_found": {
"zh-CN": "任务不存在",
"en-US": "Task not found",
},
"tasks.task_status_not_allowed": {
"zh-CN": "任务状态不允许",
"en-US": "Task status does not allow this action",
},
"tasks.guidance_content_empty": {
"zh-CN": "引导内容不能为空",
"en-US": "Guidance content cannot be empty",
},
"tasks.message_not_found": {
"zh-CN": "消息不存在",
"en-US": "Message not found",
},
"tasks.delete_failed": {
"zh-CN": "删除失败",
"en-US": "Failed to delete",
},
# ── api.py运行时引导/排队接口的兜底文案 ──
"tasks.guidance_enqueue_failed": {
"zh-CN": "追加引导失败",
"en-US": "Failed to enqueue guidance",
},
"tasks.message_enqueue_failed": {
"zh-CN": "追加消息失败",
"en-US": "Failed to enqueue the message",
},
"tasks.guidance_failed": {
"zh-CN": "引导失败",
"en-US": "Guidance failed",
},
# ── models.py运行队列 / 引导队列操作返回的 error dict ──
"tasks.task_not_running_append_message": {
"zh-CN": "任务已结束,无法追加消息",
"en-US": "Task has ended; cannot append a message",
},
"tasks.queue_full_max": {
"zh-CN": "堆积消息已满(最多 {limit} 条)",
"en-US": "Queued messages are full (max {limit})",
},
"tasks.invalid_message_id": {
"zh-CN": "消息ID无效",
"en-US": "Invalid message ID",
},
"tasks.task_not_running_guide": {
"zh-CN": "任务已结束,无法引导",
"en-US": "Task has ended; cannot guide",
},
"tasks.guidance_queue_full_max": {
"zh-CN": "引导队列已满(最多 {guidance_limit} 条)",
"en-US": "Guidance queue is full (max {guidance_limit})",
},
"tasks.message_content_empty": {
"zh-CN": "消息内容为空",
"en-US": "Message content is empty",
},
"tasks.task_not_running_append_guidance": {
"zh-CN": "任务已结束,无法追加引导",
"en-US": "Task has ended; cannot append guidance",
},
# ── server/tasks/models.py 补充(代理 24 中断遗留) ──
"tasks.invalid_run_mode": {
"zh-CN": "run_mode 只支持 fast/thinking/deep",
"en-US": "run_mode only supports fast/thinking/deep",
},
"tasks.task_already_running": {
"zh-CN": "当前对话已有运行中的任务,请稍后再试。",
"en-US": "This conversation already has a running task. Please try again later.",
},
"tasks.system_not_initialized": {
"zh-CN": "系统未初始化",
"en-US": "System not initialized",
},
"tasks.conversation_load_failed": {
"zh-CN": "对话加载失败: {error}",
"en-US": "Failed to load the conversation: {error}",
},
# ── server/tasks/skills.py ──
"tasks.skill_dir_unavailable": {
"zh-CN": "无法定位工作区 skills 目录: {error}",
"en-US": "Cannot locate the workspace skills directory: {error}",
},
"tasks.skill_path_resolve_failed": {
"zh-CN": "skill 路径解析失败: {error}",
"en-US": "Failed to resolve the skill path: {error}",
},
"tasks.skill_path_not_skillmd": {
"zh-CN": "skill 路径必须指向 SKILL.md: {name}",
"en-US": "The skill path must point to SKILL.md: {name}",
},
"tasks.skill_path_outside": {
"zh-CN": "skill 路径必须位于当前工作区 .astrion/skills/ 内",
"en-US": "The skill path must be inside the current workspace's .astrion/skills/",
},
"tasks.skill_not_found": {
"zh-CN": "skill 文件不存在",
"en-US": "Skill file not found",
},
"tasks.skill_encoding_error": {
"zh-CN": "skill 文件编码错误,无法读取: {name}",
"en-US": "Skill file encoding error; cannot read: {name}",
},
"tasks.skill_read_failed": {
"zh-CN": "读取 skill 文件失败: {error}",
"en-US": "Failed to read the skill file: {error}",
},
}