Repository navigation
feat(P2-2): SSH 运维模块(终端 POST 轮询/批量执行/片段/日志跟踪) - #551
Merged
Merged
Conversation
按 FastHub 移植清单落地 P2-2;**不含本机终端/本机文件/run_host_command**(多租户下等于 RCE,按需求排除)。 后端(新模块 app/modules/ops/ssh) - model:ops_ssh_host(密码/私钥/口令 Fernet 加密,出参只回 has_password/has_private_key)、 ops_ssh_snippet(命令片段) - 主机:CRUD + 唯一名 + 认证方式校验(password 必须有密码、key 必须有私钥)+ 按凭据测试连接 (look_for_keys=False/allow_agent=False,只用显式凭据;私钥支持 Ed25519/RSA/ECDSA) - 终端会话(terminal.py):进程内会话表 + 读取线程 + 队列;**POST 轮询**(不依赖 WebSocket); 归属校验(跨用户 403)、单用户 3 个/全局 50 个上限、空闲 30 分钟回收、resize/resync/close - 日志跟踪:在交互 shell 内执行 ,复用轮询会话 - 批量执行:多主机同命令(并发 5、单机超时 15s 可调、stdout/stderr 截断、单机失败不影响其它主机); 执行记录写审计日志(用户/主机/命令截断 200 字) - 路由 /ops/ssh/*(19 条),全部走 AuthPermission + OperationLogRoute 前端 - api/module_ops/ssh.ts + views/module_ops/ssh/index.vue:主机管理/命令片段/批量执行/终端四个 tab; 终端为轮询式(700ms 拉取,base64 传输,自动滚动,可关闭);日志跟踪入口 - router:/ops/ssh 懒加载静态路由(隐藏菜单,直接访问) 测试:tests/test_ops_ssh_terminal.py(7 项)+ tests/test_ops_ssh_service.py(12 项) 验证:后端 pytest **219 passed**、ruff 通过、basedpyright 0 errors; 前端 vue-tsc 通过、eslint 无错、prettier 通过、vitest **41 passed**。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
P2-2 SSH 运维模块
按需求不移植本机终端 / 本机文件 /
run_host_command(多租户 Web 下等于 RCE 面)。后端(
app/modules/ops/ssh)has_password/has_private_key;认证方式校验(password 必须有密码、key 必须有私钥);连接只用显式凭据(禁用 agent/默认密钥),
私钥支持 Ed25519 / RSA / ECDSA
会话归属校验(跨用户 403)、单用户 3 个 / 全局 50 个上限、空闲 30 分钟回收、resize/resync/close
tail -n N -F -- <quoted path>,复用轮询会话执行写审计日志
前端
/ops/ssh页面:主机管理 / 命令片段 / 批量执行 / 终端 四个 tab;终端为轮询式(base64 传输、自动滚动、可关闭)验证
pytest219 passed(新增 19 项)、ruff通过、basedpyright0 errorsvue-tsc通过、eslint无错、prettier通过、vitest41 passed