fix(examples): 全插件安全审查修复(qq/a2a/memo/calendar/rss/browser/bili/recoverydiag)

审查发现并修复 7 项问题:
- P1 qq: downloadURL 裸 http.Get 无超时 → 120s client
- P2 a2a: inbound http.Server 零超时 → Read 30s/Write 120s/Idle 60s
- P3 bili: output_dir 配置项零校验 → 系统目录黑名单(/、/etc、/usr、/var 等)
- P4 recoverydiag: db_path LLM 可控任意 sqlite → 强制限制 data 目录内
- P5 memo/calendar/rss: os.WriteFile 直写 → atomicWriteJSON (temp+rename)
- P6 qq: 3 处后台 goroutine(已读/rcon转发/下载)加 panic recover
- P7 browser: dump-dom failback Kill 后补 wait 回收僵尸进程

recoverydiag 此前被 .gitignore 排除,但其 db_path 安全修复
属生产代码,故取消忽略并入库。

全部经 plugindev 重打包升版安装验证 config_kept=true。
This commit is contained in:
JianFeeeee
2026-08-26 17:04:41 +08:00
parent 16b4a56ee8
commit d57c5eaf3e
18 changed files with 1685 additions and 90 deletions

View File

@ -2,14 +2,18 @@
"name": "memo",
"name_zh": "备忘录",
"name_en": "Memo",
"version": "1.0.0",
"version": "1.1.0",
"description": "待办与备忘录插件。待办todo_add/todo_complete/todo_list会主动提醒备忘录memo_create/memo_list/memo_delete纯记事不提醒。",
"author": "HomeAgent",
"entry": "plugin.so",
"tags": ["memo", "todo", "notes"],
"tags": [
"memo",
"todo",
"notes"
],
"targets": "linux/amd64",
"outdir": "dist",
"bundle": true,
"replaces": {},
"source_dirs": []
}
}

View File

@ -224,7 +224,7 @@ func (p *Plugin) saveTodos() {
"next_id": p.nextTID,
}, "", " ")
p.mu.RUnlock()
os.WriteFile(p.todoPath, data, 0644)
atomicWriteJSON(p.todoPath, data)
}
func (p *Plugin) saveMemos() {
@ -234,7 +234,7 @@ func (p *Plugin) saveMemos() {
"next_id": p.nextMID,
}, "", " ")
p.mu.RUnlock()
os.WriteFile(p.memoPath, data, 0644)
atomicWriteJSON(p.memoPath, data)
}
// ── 待办:未完成计数与提醒 ──
@ -500,3 +500,12 @@ func (p *Plugin) cleanupData() {
os.Remove(p.memoPath)
}
}
// atomicWriteJSON 原子写 JSON先写临时文件再 rename避免进程崩溃截断数据文件。
func atomicWriteJSON(path string, data []byte) error {
tmp := path + ".tmp"
if err := os.WriteFile(tmp, data, 0644); err != nil {
return err
}
return os.Rename(tmp, path)
}