Your Name
|
91ab429e5b
|
feat: cat 完全放行,不再限制路径
- 移除 _SAFE_CAT_FILES / _SAFE_CAT_DIRS / _is_safe_cat_path 及相关检查
- cat 在 SHELL_READ_ONLY_COMMANDS 为 None(任意参数均可)
- cat /etc/shadow 等所有路径现在都能正常通过
|
2026-07-25 14:54:19 +08:00 |
|
Your Name
|
00d95c4c5e
|
feat: 全面放开 shell 命令连接符(; && || > >> < 等)
现在 AI Agent 支持在单条命令中使用:
- 管道 (|): crictl ps -a | grep nginx | head -5
- 重定向 (> / >>): journalctl -u kubelet > /tmp/log
- 分号 (;): systemctl status kubelet; df -h
- 逻辑连接符 (&& / ||): df -h && free -m
安全策略:
- FORBIDDEN_TOKENS 清空,所有 shell 操作符均放行
- 新增 _split_into_commands() 按操作符分割命令段
- 新增 _command_has_dangerous_cmds() 扫描所有段中的武器级命令
- 永远拒绝: sh/bash/dash/zsh/dd/format/.../parted 等
- 检查第一条命令的白名单,cat 不安全路径检查
- 只读白名单新增 echo printf cd pwd export test [
|
2026-07-25 14:48:32 +08:00 |
|
Your Name
|
3c3b7abda5
|
feat: rm/cp/mv/chmod/chown 等文件操作命令支持(需人工审批)
- SHELL_WRITE_COMMANDS 新增 rm cp mv chmod chown mkdir touch ln
所有文件操作命令任意参数都需人工审批
- _PIPE_DANGEROUS_TARGETS 移除 rm mv chmod chown,它们现在在
写白名单中审批执行,不再直接拒绝
- 管道分支增加写表子命令不匹配时的回退处理
|
2026-07-25 14:42:30 +08:00 |
|
Your Name
|
8852e6d0ca
|
fix: 允许 AI Agent 使用管道(|)和重定向(>)进行精准排查
之前禁止所有 shell 操作符,导致 crictl ps -a|tail / df -h | grep vda
这类常用诊断管道无法使用。
改动:
1. FORBIDDEN_TOKENS 移除了 | > >> $,保留 ; || && < << `
2. 新增 _has_shell_operators() 检测命令是否需要 shell 执行
3. 新增 _pipe_to_dangerous_target() 阻止管道后执行 sh/bash/rm 等危险命令
4. classify_shell_command 对含管道命令: 只检查管道前 binary 白名单,
子命令不做限制(管道后工具多样,精确分类无意义)
5. execute_command 对 needs_shell=True 的命令用 create_subprocess_shell 执行
6. AI Prompt 第1条安全规则改为允许管道和重定向
7. 分号仍然禁止;cat 不安全路径检查对管道场景同样生效
|
2026-07-25 14:40:12 +08:00 |
|
Your Name
|
a5399bd69d
|
chore: 移除不存在的 etcdutl 命令及其相关逻辑和测试
|
2026-07-25 14:23:04 +08:00 |
|
cnbugs
|
4f37c65f18
|
feat: Agent 支持 etcdctl/etcdutl 诊断命令
etcd 是 K8S 控制平面的关键组件,缺少 etcd 诊断会导致很多故障无法
继续排查。本次将 etcdctl 和 etcdutl 纳入命令白名单:
只读 (自动执行):
- etcdctl endpoint status/health/hashkv - 端点健康
- etcdctl member list - 成员列表
- etcdctl alarm list - 告警
- etcdctl auth/user/role status|list - 认证与权限查看
- etcdctl check perf/datascale - 性能检查
- etcdctl get/watch - 读取 key
- etcdctl version
- etcdutl snapshot status/hash - 快照检查
- etcdutl version
写操作 (人工审批):
- etcdctl put/del/compact/txn - 数据修改
- etcdctl snapshot save - 保存快照
- etcdctl member add/remove/update - 成员管理
- etcdctl alarm disarm - 解除告警
- etcdctl auth enable/disable - 认证开关
- etcdctl user/role add/delete/grant/revoke - 权限管理
- etcdutl snapshot restore - 恢复快照
实现细节:
- etcdctl/etcdutl 命令支持全局 flag (--endpoints/--cacert 等在子命令前)
- 两段式命令按 (verb, subverb) 组合精确分类,避免 member list (只读)
和 member remove (写) 混淆
- 新增 12 个 etcd 命令分类测试,全部 56 个测试通过
|
2026-07-25 13:50:34 +08:00 |
|
cnbugs
|
32bea0d4ea
|
feat: AI 诊断 Agent 支持执行系统诊断 shell 命令
扩展 Agent 命令工具,除 kubectl 外新增节点宿主机系统诊断命令支持:
- agent_tools.py: 新增 shell 命令白名单分类器 (classify_shell_command)
- 只读白名单: systemctl status/is-active、journalctl、crictl ps/logs、
docker ps/logs、df、free、ss、ip addr、ps、mount、lsmod、dmesg、
ping、nslookup、cat (限 /proc /sys /etc/kubernetes 等安全路径) 等 30+ 命令
- 写白名单: systemctl restart/stop/start/reload 等需人工审批
- 统一分发器 classify_agent_command 按命令前缀路由
- 统一执行入口 execute_command 走 subprocess_exec (无 shell 注入风险)
- ai_agent.py: 更新 AGENT_SYSTEM_PROMPT 告知 AI 两类可用工具及安全规则
- 三个调用点 (初始探测/分类/执行) 切换到统一接口
- main.py: 审批执行处改用 execute_command
- tests: 新增 19 个用例覆盖 shell 命令分类、混合执行、白名单拒绝
- 全部 44 个测试通过
- 前端/README: 文案与文档补充 shell 命令支持说明
安全策略不变: 禁止 shell 操作符/管道/重定向/多命令拼接,
非白名单命令 (rm/vi/apt 等) 直接拒绝。
|
2026-07-25 13:38:48 +08:00 |
|
cnbugs
|
4f3a7833a0
|
feat: 增加 AI Agent 自主诊断执行模式
|
2026-07-25 12:21:54 +08:00 |
|