mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-21 17:38:10 +00:00
fix(cmd/files/webui): shell 语义修复 + 根沙箱误判 + 上传注入走 interrupt + UI 区分附件来源
1. cmd_run 改经 /bin/bash -c 执行完整 shell 语法
旧实现 shellUnquote 拆词后直接 exec:'pwd; ls /' 变成执行名为
'pwd;' 的程序(exit -1)、heredoc 被截断、管道/命令替换全部失效——
agent 多次反馈命令解析奇怪即此。危险命令拦截(kill homed 等)保留。
2. files 沙箱根目录判断修复
pathWithinSandbox 在 base='/' 时 prefix 变 '//',所有绝对路径误判
逃逸(生产实锤:files.dir=/ 下 files_read/write/ls 全部报 outside
sandbox)。根沙箱直接放行。
3. webui 文件上传注入改走 interrupt(system 角色)
文件元信息不再混入用户消息气泡;用户附言作为正常消息先行注入,
文件说明紧随其后以 no_memory interrupt 补充——对齐 terminal_watch/
timer 工具提醒模式,聊天流保持干净。
4. 前端附件卡片按 role 区分来源
user=右侧+『你发送的』标签+accent 底色;assistant=左侧+『小宅发送的』。
📌 emoji 按钮换为 SVG 图标,前端 emoji 清零。
This commit is contained in:
@ -201,6 +201,12 @@ func pathWithinSandbox(abs, base string) bool {
|
||||
if equalFoldPath(abs, base) {
|
||||
return true
|
||||
}
|
||||
// 根沙箱(Linux "/")表示整机可访问:Clean("") 会返回 ".",
|
||||
// 而 prefix 变成 "//" 导致所有绝对路径误判逃逸(生产实锤:files.dir=/ 时
|
||||
// 全部 files_read/write 报 path outside sandbox)。根目录直接放行。
|
||||
if base == string(filepath.Separator) {
|
||||
return true
|
||||
}
|
||||
// 卷根沙箱(C:\、D:\ 等)表示整机可访问
|
||||
if isWindowsBuild && len(base) == 3 && base[1] == ':' && base[2] == '\\' {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user