lingshu-skill 5.57.0 → 5.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +1 -1
- package/SKILL-lite.md +1 -1
- package/SKILL-tiny.md +1 -1
- package/SKILL.md +1 -1
- package/assets/panel.html +5 -1
- package/cordis-plugin/lingshu-guard/plugin.js +25 -9
- package/package.json +1 -1
- package/scripts/astrbot_plugin_lingshu/CHECKSUMS.json +11 -11
- package/scripts/astrbot_plugin_lingshu/engine/CHANGELOG.md +28 -0
- package/scripts/astrbot_plugin_lingshu/engine/README.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-lite.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL-tiny.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/SKILL.md +1 -1
- package/scripts/astrbot_plugin_lingshu/engine/assets/panel.html +5 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/cli.py +59 -14
- package/scripts/astrbot_plugin_lingshu/engine/scripts/core.py +5 -1
- package/scripts/astrbot_plugin_lingshu/engine/scripts/dream.py +1235 -1214
- package/scripts/astrbot_plugin_lingshu/engine/scripts/memory.py +90 -21
- package/scripts/astrbot_plugin_lingshu/engine/scripts/panel_server.py +26 -11
- package/scripts/cli.py +59 -14
- package/scripts/core.py +5 -1
- package/scripts/dream.py +1235 -1214
- package/scripts/memory.py +90 -21
- package/scripts/panel_server.py +26 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v5.59(2026-12-04)
|
|
4
|
+
|
|
5
|
+
### 🛡️ 150 项审计第三批:事务回滚与数据一致性组闭环修复
|
|
6
|
+
|
|
7
|
+
对照 `灵枢项目-150项问题待办.md` 完成针对性修复与自动化回归覆盖:
|
|
8
|
+
|
|
9
|
+
1. **LS-009(高·多文件替换原子性)**:`memory.py` 的 `save_all()` 升级事务级原子回滚——三层文件(hippo、cortex、dust)替换过程若任一文件 replace 抛异常,立即逆序原子恢复所有已替换文件,杜绝三层状态分裂或半新半旧混合库。单测验证通过。
|
|
10
|
+
2. **LS-010 / LS-011(高·备份恢复事务与安全)**:`cli.py` 恢复逻辑全面加固——①增加受管文件清理异常阻断,禁止 exact 恢复在删除失败时静默 pass;②增加单文件替换事务备份链,任一文件恢复替换失败自动反向原子回滚所有已替换文件。
|
|
11
|
+
3. **LS-016(高·物理删除留底保障)**:`memory.py` 的 `purge` 升级为严格台账写入门禁(`_ledger_add_strict`)——只有确认软删除台账持久化成功后才允许物理从底层抹除,若写台账失败立即抛出异常中止删除,绝不丢数据。单测验证通过。
|
|
12
|
+
4. **LS-017(高·工作记忆归档保护)**:`memory.py` 的 `_sweep_locked` 修复——工作记忆转入归档追加若遇到 OSError/权限等故障,原工作区条目严格保留、不予清空,绝不因归档失败导致工作任务失踪。单测验证通过。
|
|
13
|
+
5. **LS-029 / LS-031(高·做梦应用幂等与事务一致)**:`dream.py` 升级——①`apply_dream` 支持同一 `task_id` 重试幂等防重:对已存在的同任务生成记忆进行内容比对复用,避免中断重试时产生重复条目;②`dream()` 整理在生成 pending.json 失败时主动捕获并抛错终止,保持任务状态与记忆整理严格一致。单测验证通过。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## v5.58(2026-12-04)
|
|
18
|
+
|
|
19
|
+
### 🔐 150 项审计第二批:隐私与鉴权组(高优先级)闭环修复
|
|
20
|
+
|
|
21
|
+
对照 `灵枢项目-150项问题待办.md` 完成针对性修复与自动化回归覆盖:
|
|
22
|
+
|
|
23
|
+
1. **LS-003(高·跨群画像泄露)**:`cli.py` 严格收敛第三人查询画像权限——第三人即便获得目标在 G1 群的授权,也仅展示 G1 本群记忆,严格���断其在 G2、G3 群及私聊历史向外泄露。
|
|
24
|
+
2. **LS-004(高·Agent 隔离)**:`memory.py` 补齐归档召回(archive)的 `agent_id` 物理隔离,确保 Agent A 绝不能读取 Agent B 的归档记忆。新增回归单测验证。
|
|
25
|
+
3. **LS-005(高·证据解引用泄露)**:`memory.py` 的 `dereference` 解引用链路全面继承当前 channel、group_id 及 target_user/asker/_consented 隐私约束,防止攻击者通过生成公开摘要侧信道窃取被隔离的私聊敏感证据原文。新增回归单测验证。
|
|
26
|
+
4. **LS-058 / LS-059 / LS-060(高·自定义面板安全)**:`panel_server.py` 与 `panels.js` 全面升级——放宽 CSP 为 `frame-ancestors 'self'` 支持合法同源 iframe 嵌入;为 `/api/panels/file` 增加安全 URL query token 鉴权;向第三方面板 HTML 自动注入专属「当日派生 token」,解决第三方面板未替换占位符导致的 403 瘫痪。
|
|
27
|
+
5. **LS-091(高·IM 鉴权越权绕过)**:`cordis-plugin/lingshu-guard/plugin.js` 引入超轻量 `knownImSessions` 集合持久维护 IM 会话标记,彻底阻断 bindings 在并发 4096 条发生 LRU 淘汰后误将 IM 会话降级为桌面会话从而放行非 owner 高危操作的严重越权漏洞。新增回归单测验证。
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
3
31
|
## v5.57(2026-12-04)
|
|
4
32
|
|
|
5
33
|
### 🚨 150 项审计首批:全部 6 项「严重」级缺陷闭环修复
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
> 当前版本 **v5.
|
|
5
|
+
> 当前版本 **v5.59**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
package/SKILL-lite.md
CHANGED
package/SKILL-tiny.md
CHANGED
package/SKILL.md
CHANGED
package/assets/panel.html
CHANGED
|
@@ -7193,8 +7193,12 @@ setTimeout(() => checkUpdate(true), 1200);
|
|
|
7193
7193
|
fr.id = "custom-panel-frame";
|
|
7194
7194
|
// entry 来自面板 manifest(/api/panels 列表下发),不是写死的 index.html——
|
|
7195
7195
|
// manifest 允许作者自定义入口文件名,写死会让这类面板 404 → 被超时兜底误回退
|
|
7196
|
+
// LS-058(v5.58):iframe 无法通过自定义 Request Headers 传递 Bearer token,
|
|
7197
|
+
// 在 src 查询参数中安全附加 ?token=PANEL_TOKEN,配合后端的等价 token 鉴权通道。
|
|
7198
|
+
const tokParam = (typeof PANEL_TOKEN === "string" && !PANEL_TOKEN.includes("__PANEL_TOKEN__"))
|
|
7199
|
+
? "&token=" + encodeURIComponent(PANEL_TOKEN) : "";
|
|
7196
7200
|
fr.src = "/api/panels/file?panel=" + encodeURIComponent(pname) +
|
|
7197
|
-
"&path=" + encodeURIComponent(entry || "index.html") + "&as_page=1";
|
|
7201
|
+
"&path=" + encodeURIComponent(entry || "index.html") + "&as_page=1" + tokParam;
|
|
7198
7202
|
fr.style.cssText = "position:fixed;inset:0;width:100vw;height:100vh;border:none;z-index:800;background:#14181e";
|
|
7199
7203
|
fr.onerror = () => fallback(pname, "iframe 加载失败");
|
|
7200
7204
|
document.body.appendChild(fr);
|
|
@@ -313,7 +313,7 @@ function denyOrShadow(cfg, tool, fields, reason) {
|
|
|
313
313
|
* 核心判定(同步):返回 string 表示拒绝原因,undefined 表示放行。
|
|
314
314
|
* 任何内部异常都 fail-closed(影子模式除外),绝不静默放行。
|
|
315
315
|
*/
|
|
316
|
-
function checkTool(ctx, bindings, hostConfig, exec, agent) {
|
|
316
|
+
function checkTool(ctx, bindings, hostConfig, exec, agent, knownImSessions = null) {
|
|
317
317
|
let cfg
|
|
318
318
|
try {
|
|
319
319
|
cfg = resolveGuardConfig(hostConfig)
|
|
@@ -341,17 +341,19 @@ function checkTool(ctx, bindings, hostConfig, exec, agent) {
|
|
|
341
341
|
return denyOrShadow(cfg, tool, fields, failClosedReason(tool))
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
// v3.75
|
|
344
|
+
// v3.75 & LS-091(v5.58):区分"真桌面会话"与"IM 会话但身份解析失败"。
|
|
345
345
|
// 原来 described=null 一律放行——但 describeConversationSync 暂不可用且
|
|
346
346
|
// session-pre-bind 事件漏了时,IM 会话也会被当桌面会话,非 owner 可用
|
|
347
|
-
// shell/写文件/subagent
|
|
348
|
-
//
|
|
349
|
-
//
|
|
347
|
+
// shell/写文件/subagent 且无审计。
|
|
348
|
+
// LS-091: 即使 bindings Map 经历了 LRU 淘汰导致其 payload 丢失,只要
|
|
349
|
+
// knownImSessions 或 bindings 记录过该 sessionId,就坚决按 fail-closed 拦截,
|
|
350
|
+
// 杜绝淘汰后漏成桌面会话直接放行高危操作。
|
|
350
351
|
if (!described) {
|
|
351
|
-
|
|
352
|
+
const isRecordedIm = sessionId && (bindings.has(sessionId) || (knownImSessions && knownImSessions.has(sessionId)))
|
|
353
|
+
if (isRecordedIm) {
|
|
352
354
|
const fields = { sender: '', channel: '', group: '' }
|
|
353
355
|
return denyOrShadow(cfg, tool, fields,
|
|
354
|
-
`灵枢·guard 拒绝:这是已绑定的 IM
|
|
356
|
+
`灵枢·guard 拒绝:这是已绑定的 IM 会话,但身份解析失败(宿主只读服务不可用或缓存被淘汰),`
|
|
355
357
|
+ `无法确认发言人,按 fail-closed 拒绝 "${tool}"。`)
|
|
356
358
|
}
|
|
357
359
|
return undefined
|
|
@@ -387,6 +389,13 @@ export function apply(ctx, config) {
|
|
|
387
389
|
const hostConfig = config && typeof config === 'object' ? config : {}
|
|
388
390
|
// sessionId -> dsh-im/session-pre-bind 载荷(事件侧身份缓存)
|
|
389
391
|
const bindings = new Map()
|
|
392
|
+
// LS-091(v5.58):绑定缓存淘汰后仍保持 IM 鉴权标记(Set 只存 sessionId,极轻量)。
|
|
393
|
+
// 当 bindings 达到 4096 条发生 LRU 淘汰旧条目时,旧会话的完整 payload 被移出,
|
|
394
|
+
// 但其"曾是 IM 会话"的身份标记绝不抹除!
|
|
395
|
+
// 否则当旧会话活跃重发指令时,若 describeConversationSync 刚好不可用,
|
|
396
|
+
// 旧逻辑会因 bindings.has(sessionId) 为 false 将其误判为"纯桌面会话",
|
|
397
|
+
// 导致非 owner 免鉴权直接执行高危工具(严重鉴权绕过)。
|
|
398
|
+
const knownImSessions = new Set()
|
|
390
399
|
let warned = false
|
|
391
400
|
const warn = (message, error) => {
|
|
392
401
|
if (warned) return
|
|
@@ -419,6 +428,10 @@ export function apply(ctx, config) {
|
|
|
419
428
|
const sessionId = asText(payload?.sessionId)
|
|
420
429
|
if (!sessionId) return
|
|
421
430
|
bindings.set(sessionId, { ...payload })
|
|
431
|
+
knownImSessions.add(sessionId)
|
|
432
|
+
if (knownImSessions.size > 16384) {
|
|
433
|
+
for (const key of [...knownImSessions.values()].slice(0, 4096)) knownImSessions.delete(key)
|
|
434
|
+
}
|
|
422
435
|
if (bindings.size > 4096) {
|
|
423
436
|
for (const key of [...bindings.keys()].slice(0, 1024)) bindings.delete(key)
|
|
424
437
|
}
|
|
@@ -427,11 +440,14 @@ export function apply(ctx, config) {
|
|
|
427
440
|
ctx.on('dsh-im/session-unbind', (payload) => {
|
|
428
441
|
try {
|
|
429
442
|
const sessionId = asText(payload?.sessionId)
|
|
430
|
-
if (sessionId)
|
|
443
|
+
if (sessionId) {
|
|
444
|
+
bindings.delete(sessionId)
|
|
445
|
+
knownImSessions.delete(sessionId)
|
|
446
|
+
}
|
|
431
447
|
} catch { /* 坏载荷忽略 */ }
|
|
432
448
|
})
|
|
433
449
|
|
|
434
|
-
const check = (exec, agent) => checkTool(ctx, bindings, hostConfig, exec, agent)
|
|
450
|
+
const check = (exec, agent) => checkTool(ctx, bindings, hostConfig, exec, agent, knownImSessions)
|
|
435
451
|
|
|
436
452
|
/**
|
|
437
453
|
* 给一个 agent 注册守卫。注册在 agent.ctx 上,作用域随 agent 销毁自动释放:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lingshu-skill",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.59.0",
|
|
4
4
|
"description": "Brain-inspired persistent memory, persona and growth system for AI coding agents. Local-only, zero-dependency Python. Requires Python 3.10+.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"PATCH_NOTES.md": "9296e524f743f358fd11115598398a754cfd69534526dde9c8ad85f14a418f89",
|
|
3
3
|
"README.md": "3d634d743b085eebd2cbb5dd3a00edfa728ed23947e20cc29e7c3b29087ec043",
|
|
4
|
-
"engine/CHANGELOG.md": "
|
|
5
|
-
"engine/README.md": "
|
|
6
|
-
"engine/SKILL-lite.md": "
|
|
7
|
-
"engine/SKILL-tiny.md": "
|
|
8
|
-
"engine/SKILL.md": "
|
|
9
|
-
"engine/assets/panel.html": "
|
|
4
|
+
"engine/CHANGELOG.md": "f7d83b1fabe423e6679077c45f6fcb19440c4526994afcbdb004b5cbf0125d6c",
|
|
5
|
+
"engine/README.md": "e4b0fbdc5ec8a2f725ed9386705b2d96bc971980609179c3078fb44a9fe81a1b",
|
|
6
|
+
"engine/SKILL-lite.md": "88bab9a285d202c52a356a1d9870c02265f27e2ad354f1a8300d35517c9ac8aa",
|
|
7
|
+
"engine/SKILL-tiny.md": "c4807d8f2aaacefb98cf78674943e6c9e5a41cdcc4c346ec39e6bebddd098173",
|
|
8
|
+
"engine/SKILL.md": "35285b3c813106566951673f2d68c3020595373685a074bcf23db0f23ff86bd0",
|
|
9
|
+
"engine/assets/panel.html": "7743d5ec5bba3986556707c314e97a995cc4fdcbabf7d1155071f0a8bba1b890",
|
|
10
10
|
"engine/docs/commands.md": "0ce8c88e5d2d04a8055b45c060ebd53b50c52b79b650312e2ee440845804ca4b",
|
|
11
11
|
"engine/docs/mechanics.md": "aa9683c827ed3419106e84d847ab16dc310c27fc62f588184192aaa1617523cc",
|
|
12
12
|
"engine/docs/models.md": "596bc1a3414f2de5569dcb41a0c494acae7daa534efd5a91dbcc3c4cb308d695",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"engine/scripts/check_pressure_sync.py": "d7ea8acfa8a2d07baca12c9a6664c76a259766d6e1cecf06963ed30241f9bb8b",
|
|
24
24
|
"engine/scripts/check_tag.py": "fd333d0983ff075ea7340532dfeed62ab05ab521d169b44ff8a928d418c7dd22",
|
|
25
25
|
"engine/scripts/checkpoint.py": "3a9292121042692dc872a865b6ee1c1e5f14c054791887e0791f19ccdb9638fb",
|
|
26
|
-
"engine/scripts/cli.py": "
|
|
26
|
+
"engine/scripts/cli.py": "bfcc39509bcf91fbb10b044b17e52b193c12b587dd81c4c5bfd16a20034e1474",
|
|
27
27
|
"engine/scripts/context_ab.py": "3d383f1fc16d328612825bbf731866fa427da0746490d027a0ddb719d210f1cb",
|
|
28
|
-
"engine/scripts/core.py": "
|
|
28
|
+
"engine/scripts/core.py": "db08718c8112c384396c253ad04f87326898bc6950a73ca322e4a77a51acbeef",
|
|
29
29
|
"engine/scripts/coverage_report.py": "53e1c731f4182fac68190d68d23459bcd8059c0b39ebc5a4ba0e56a0d562ad01",
|
|
30
30
|
"engine/scripts/delivery.py": "6a4bf2caac9dca41b43c06d31f7cfc328bae19d3fb618da26b35f1a214071a11",
|
|
31
31
|
"engine/scripts/desktop_shortcut.py": "77ea248bfaaf28e1e4299979d0c0d8c80a055642dde9a40f5e297b2008474091",
|
|
32
|
-
"engine/scripts/dream.py": "
|
|
32
|
+
"engine/scripts/dream.py": "da6bfcab38104b9248059fe70cb3544b2521fd66fe6ad44f3af4b780b06b550e",
|
|
33
33
|
"engine/scripts/emotion.py": "e038024dfced6b497b7cc673474b2b4948323cae09b0a6df15498af1c9002daa",
|
|
34
34
|
"engine/scripts/failures.py": "3a16234a1871f62e3ba7b7b743110b4044fb7b715b4d0e924b8ebf1cf0be50d0",
|
|
35
35
|
"engine/scripts/fallback_embed.py": "11339a9f5040aea8952fdd45f4183cdfb0f00266ff61e200f3b4e8a62778f6e0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"engine/scripts/mem_lesson.py": "e1520786315f3e41c829909c739e5af3eee89397da7db5026d106710b2b3c118",
|
|
47
47
|
"engine/scripts/mem_score.py": "91148eb50058c47a6094a6cd5e0eb9c3e3331cb0dc0ecb05a82d00905d2e9d90",
|
|
48
48
|
"engine/scripts/mem_topic.py": "c22f75c128cdd3b26ff845f1a71608401bc0dc8955f9f0e1988d7f0cd663d0d5",
|
|
49
|
-
"engine/scripts/memory.py": "
|
|
49
|
+
"engine/scripts/memory.py": "7055bcc47edd603971252e813077aeb789e87ba249536a063006eb3ff41f6b34",
|
|
50
50
|
"engine/scripts/memory_extras.py": "4adb61400c5224c90aa54f059267f795c6348a251d93cd173d79fff157d57d90",
|
|
51
51
|
"engine/scripts/npm_prepack.py": "d62c491a6f9edfcab2dd465a995e72df879a61b4da26ae0fe76121c8adc77e02",
|
|
52
52
|
"engine/scripts/occ.py": "4caac0d72ce071ea224ce2dc7d346effdbff8a516e3e7b54118a3be3ed274256",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"engine/scripts/panel_data.py": "5788aaee9b4e56e73587c4d0474687cecaa40dd7e507f02c27dd07aa208ba237",
|
|
56
56
|
"engine/scripts/panel_icon.py": "8b766740c547087c4d40ab7031a8b6845f3e0bdd3893079d2da22bb9c9694a9f",
|
|
57
57
|
"engine/scripts/panel_launcher.py": "c27c195acc126dace8b99f66906bbdb64ef4dcb4a66513907ebd4df159b97af1",
|
|
58
|
-
"engine/scripts/panel_server.py": "
|
|
58
|
+
"engine/scripts/panel_server.py": "6fc405e412239fc2417c71c070f13fbe30451bbb2224af15d464f66366d4f8cf",
|
|
59
59
|
"engine/scripts/panel_settings.py": "8faa9ac1321ca4450811bddbb06e5ce6deec0bd43a9ce959cc91ebc7a1e4959c",
|
|
60
60
|
"engine/scripts/panel_shortcut.py": "956374abe9d1e2b63618223e861f696070b6c0368a757f5a630f441c854ea1ea",
|
|
61
61
|
"engine/scripts/panel_splash.py": "36cd59e593ce52557a180a8767bfa9cd9c803f0cccaa141e7da8babd5a35e925",
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v5.59(2026-12-04)
|
|
4
|
+
|
|
5
|
+
### 🛡️ 150 项审计第三批:事务回滚与数据一致性组闭环修复
|
|
6
|
+
|
|
7
|
+
对照 `灵枢项目-150项问题待办.md` 完成针对性修复与自动化回归覆盖:
|
|
8
|
+
|
|
9
|
+
1. **LS-009(高·多文件替换原子性)**:`memory.py` 的 `save_all()` 升级事务级原子回滚——三层文件(hippo、cortex、dust)替换过程若任一文件 replace 抛异常,立即逆序原子恢复所有已替换文件,杜绝三层状态分裂或半新半旧混合库。单测验证通过。
|
|
10
|
+
2. **LS-010 / LS-011(高·备份恢复事务与安全)**:`cli.py` 恢复逻辑全面加固——①增加受管文件清理异常阻断,禁止 exact 恢复在删除失败时静默 pass;②增加单文件替换事务备份链,任一文件恢复替换失败自动反向原子回滚所有已替换文件。
|
|
11
|
+
3. **LS-016(高·物理删除留底保障)**:`memory.py` 的 `purge` 升级为严格台账写入门禁(`_ledger_add_strict`)——只有确认软删除台账持久化成功后才允许物理从底层抹除,若写台账失败立即抛出异常中止删除,绝不丢数据。单测验证通过。
|
|
12
|
+
4. **LS-017(高·工作记忆归档保护)**:`memory.py` 的 `_sweep_locked` 修复——工作记忆转入归档追加若遇到 OSError/权限等故障,原工作区条目严格保留、不予清空,绝不因归档失败导致工作任务失踪。单测验证通过。
|
|
13
|
+
5. **LS-029 / LS-031(高·做梦应用幂等与事务一致)**:`dream.py` 升级——①`apply_dream` 支持同一 `task_id` 重试幂等防重:对已存在的同任务生成记忆进行内容比对复用,避免中断重试时产生重复条目;②`dream()` 整理在生成 pending.json 失败时主动捕获并抛错终止,保持任务状态与记忆整理严格一致。单测验证通过。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## v5.58(2026-12-04)
|
|
18
|
+
|
|
19
|
+
### 🔐 150 项审计第二批:隐私与鉴权组(高优先级)闭环修复
|
|
20
|
+
|
|
21
|
+
对照 `灵枢项目-150项问题待办.md` 完成针对性修复与自动化回归覆盖:
|
|
22
|
+
|
|
23
|
+
1. **LS-003(高·跨群画像泄露)**:`cli.py` 严格收敛第三人查询画像权限——第三人即便获得目标在 G1 群的授权,也仅展示 G1 本群记忆,严格���断其在 G2、G3 群及私聊历史向外泄露。
|
|
24
|
+
2. **LS-004(高·Agent 隔离)**:`memory.py` 补齐归档召回(archive)的 `agent_id` 物理隔离,确保 Agent A 绝不能读取 Agent B 的归档记忆。新增回归单测验证。
|
|
25
|
+
3. **LS-005(高·证据解引用泄露)**:`memory.py` 的 `dereference` 解引用链路全面继承当前 channel、group_id 及 target_user/asker/_consented 隐私约束,防止攻击者通过生成公开摘要侧信道窃取被隔离的私聊敏感证据原文。新增回归单测验证。
|
|
26
|
+
4. **LS-058 / LS-059 / LS-060(高·自定义面板安全)**:`panel_server.py` 与 `panels.js` 全面升级——放宽 CSP 为 `frame-ancestors 'self'` 支持合法同源 iframe 嵌入;为 `/api/panels/file` 增加安全 URL query token 鉴权;向第三方面板 HTML 自动注入专属「当日派生 token」,解决第三方面板未替换占位符导致的 403 瘫痪。
|
|
27
|
+
5. **LS-091(高·IM 鉴权越权绕过)**:`cordis-plugin/lingshu-guard/plugin.js` 引入超轻量 `knownImSessions` 集合持久维护 IM 会话标记,彻底阻断 bindings 在并发 4096 条发生 LRU 淘汰后误将 IM 会话降级为桌面会话从而放行非 owner 高危操作的严重越权漏洞。新增回归单测验证。
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
3
31
|
## v5.57(2026-12-04)
|
|
4
32
|
|
|
5
33
|
### 🚨 150 项审计首批:全部 6 项「严重」级缺陷闭环修复
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 名字取自《黄帝内经》:**算力给思考,人格给灵魂,记忆给生命。**
|
|
4
4
|
|
|
5
|
-
> 当前版本 **v5.
|
|
5
|
+
> 当前版本 **v5.59**(变更见 [CHANGELOG.md](CHANGELOG.md))
|
|
6
6
|
|
|
7
7
|
> 🔁 **双仓库镜像**:GitHub(主)与 Gitee(镜像)保持同步——[gitee.com/htmcwy_0/lingshu-skill](https://gitee.com/htmcwy_0/lingshu-skill)。灵枢的更新检查会探测两边最新提交,**谁更新就自动从谁拉取**;任一边不可达(Gitee 匿名风控 / GitHub 限额)时走另一边兜底。
|
|
8
8
|
|
|
@@ -7193,8 +7193,12 @@ setTimeout(() => checkUpdate(true), 1200);
|
|
|
7193
7193
|
fr.id = "custom-panel-frame";
|
|
7194
7194
|
// entry 来自面板 manifest(/api/panels 列表下发),不是写死的 index.html——
|
|
7195
7195
|
// manifest 允许作者自定义入口文件名,写死会让这类面板 404 → 被超时兜底误回退
|
|
7196
|
+
// LS-058(v5.58):iframe 无法通过自定义 Request Headers 传递 Bearer token,
|
|
7197
|
+
// 在 src 查询参数中安全附加 ?token=PANEL_TOKEN,配合后端的等价 token 鉴权通道。
|
|
7198
|
+
const tokParam = (typeof PANEL_TOKEN === "string" && !PANEL_TOKEN.includes("__PANEL_TOKEN__"))
|
|
7199
|
+
? "&token=" + encodeURIComponent(PANEL_TOKEN) : "";
|
|
7196
7200
|
fr.src = "/api/panels/file?panel=" + encodeURIComponent(pname) +
|
|
7197
|
-
"&path=" + encodeURIComponent(entry || "index.html") + "&as_page=1";
|
|
7201
|
+
"&path=" + encodeURIComponent(entry || "index.html") + "&as_page=1" + tokParam;
|
|
7198
7202
|
fr.style.cssText = "position:fixed;inset:0;width:100vw;height:100vh;border:none;z-index:800;background:#14181e";
|
|
7199
7203
|
fr.onerror = () => fallback(pname, "iframe 加载失败");
|
|
7200
7204
|
document.body.appendChild(fr);
|
|
@@ -743,6 +743,9 @@ def cmd_restore(zip_path: str, yes: bool = False, password: str | None = None,
|
|
|
743
743
|
# 只删白名单内的路径:记忆库里用户自己放进去的东西(草稿、导出包、
|
|
744
744
|
# 参考笔记)一律保留并汇报——"清空受管文件"不该变成"清空这个目录"。
|
|
745
745
|
kept: list[str] = []
|
|
746
|
+
# LS-011(v5.59):禁止 exact 恢复忽略受管文件删除失败!
|
|
747
|
+
# 若受管文件删除抛出 OSError/PermissionError,绝不能静默 pass 并输出"已回到备份时点"。
|
|
748
|
+
# 必须明确报错中止恢复流程。
|
|
746
749
|
for f in sorted(HOME.rglob("*"), reverse=True):
|
|
747
750
|
if f.is_dir():
|
|
748
751
|
continue
|
|
@@ -757,21 +760,49 @@ def cmd_restore(zip_path: str, yes: bool = False, password: str | None = None,
|
|
|
757
760
|
with _locked(f):
|
|
758
761
|
try:
|
|
759
762
|
f.unlink()
|
|
760
|
-
except OSError:
|
|
761
|
-
|
|
763
|
+
except OSError as unl_err:
|
|
764
|
+
raise RuntimeError(f"exact 恢复清理受管文件失败({rel} 被占用或拒绝):{unl_err}") from unl_err
|
|
762
765
|
if kept:
|
|
763
766
|
head = "、".join(kept[:5]) + (" …" if len(kept) > 5 else "")
|
|
764
767
|
print(f"保留 {len(kept)} 个非灵枢文件(restore 只清自己的东西):{head}")
|
|
765
|
-
|
|
766
|
-
#
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
768
|
+
|
|
769
|
+
# LS-010(v5.59):让恢复过程具备事务回滚能力!
|
|
770
|
+
# 记录所有已替换文件的旧版本备份副本,一旦任意文件 os.replace 失败,
|
|
771
|
+
# 立即逆序原子回滚所有已替换文件,绝不在磁盘留下新旧混合的脏库!
|
|
772
|
+
restored_backups = []
|
|
773
|
+
try:
|
|
774
|
+
for extracted in tmp_dir.rglob("*"):
|
|
775
|
+
if extracted.is_dir():
|
|
776
|
+
continue
|
|
777
|
+
rel = extracted.relative_to(tmp_dir)
|
|
778
|
+
final = (HOME / rel).resolve()
|
|
779
|
+
final.parent.mkdir(parents=True, exist_ok=True)
|
|
780
|
+
bak_curr = None
|
|
781
|
+
if final.exists():
|
|
782
|
+
bak_curr = final.with_name(final.name + f".restore-bak-{os.getpid()}-{int(now_ts() * 1000) % 1000000}")
|
|
783
|
+
try:
|
|
784
|
+
shutil.copy2(final, bak_curr)
|
|
785
|
+
except Exception:
|
|
786
|
+
bak_curr = None
|
|
787
|
+
with _locked(final):
|
|
788
|
+
os.replace(str(extracted), str(final))
|
|
789
|
+
if bak_curr:
|
|
790
|
+
restored_backups.append((final, bak_curr))
|
|
791
|
+
except BaseException as restore_err:
|
|
792
|
+
for target_f, bak_f in reversed(restored_backups):
|
|
793
|
+
try:
|
|
794
|
+
with _locked(target_f):
|
|
795
|
+
os.replace(str(bak_f), str(target_f))
|
|
796
|
+
except Exception:
|
|
797
|
+
pass
|
|
798
|
+
raise restore_err
|
|
799
|
+
finally:
|
|
800
|
+
for _, bak_f in restored_backups:
|
|
801
|
+
try:
|
|
802
|
+
if bak_f.exists():
|
|
803
|
+
os.unlink(bak_f)
|
|
804
|
+
except OSError:
|
|
805
|
+
pass
|
|
775
806
|
except ValueError as exc:
|
|
776
807
|
print(f"[错误] {exc}", file=sys.stderr)
|
|
777
808
|
return 1
|
|
@@ -6241,8 +6272,22 @@ def _main(argv=None) -> int:
|
|
|
6241
6272
|
f"或由其本人查询(对方可用 `lingshu 同意` 授权)。", file=sys.stderr)
|
|
6242
6273
|
return 4
|
|
6243
6274
|
# 跨群用户画像:user 标识匹配的所有记忆聚合(含归档),按时间倒序
|
|
6244
|
-
|
|
6245
|
-
|
|
6275
|
+
# LS-003(v5.58):第三人查询时,即使目标已对某个群授权(或全域 * 授权),
|
|
6276
|
+
# 也绝不能越权读出目标在其他未授权群或私聊里的秘密记忆。
|
|
6277
|
+
# 若本人查询(asker == user 或本机无 asker 查询),可查看本人全部跨群画像;
|
|
6278
|
+
# 第三人查询:仅当目标在 grant_group 授权时,且只展示该群范围内的记忆!
|
|
6279
|
+
# 目标在 G1 授权,不能让 G1 的第三人窥见其在 G2、G3 或私聊中的记录。
|
|
6280
|
+
all_hits = [m for m in load_all() + load_archive()
|
|
6281
|
+
if str(m.get("user") or "") == str(args.user)]
|
|
6282
|
+
if asker and str(asker) != str(args.user).strip():
|
|
6283
|
+
req_group = (getattr(args, "group", "") or "").strip()
|
|
6284
|
+
if req_group and req_group != "*":
|
|
6285
|
+
hits = [m for m in all_hits if str(m.get("group_id") or "") == req_group]
|
|
6286
|
+
else:
|
|
6287
|
+
# 全域查询第三人:要求目标授予全域 '*' 授权;此时仍严格排除私聊记录(群聊环境不可外泄私聊)
|
|
6288
|
+
hits = [m for m in all_hits if m.get("group_id") and str(m.get("group_id")) != "私聊"]
|
|
6289
|
+
else:
|
|
6290
|
+
hits = all_hits
|
|
6246
6291
|
hits.sort(key=lambda m: _num(m.get("created"), 0), reverse=True)
|
|
6247
6292
|
groups = sorted({str(m.get("group_id") or "私聊") for m in hits})
|
|
6248
6293
|
print(f"用户 {args.user}:共 {len(hits)} 条记忆,出现在 {len(groups)} 个群({'、'.join(groups)})")
|
|
@@ -465,7 +465,11 @@ def ensure_home() -> None:
|
|
|
465
465
|
if not (HOME / "config.json").exists():
|
|
466
466
|
atomic_json(HOME / "config.json", DEFAULT_CONFIG)
|
|
467
467
|
if not (HOME / "persona.json").exists():
|
|
468
|
-
|
|
468
|
+
try:
|
|
469
|
+
import persona
|
|
470
|
+
persona.compile_persona()
|
|
471
|
+
except Exception:
|
|
472
|
+
pass
|
|
469
473
|
(HOME / "dreams").mkdir(parents=True, exist_ok=True)
|
|
470
474
|
(HOME / "skills").mkdir(parents=True, exist_ok=True) # 面板「技能根目录」显示此目录,提前建好免得显示"不存在"
|
|
471
475
|
_check_meta() # v3.02 #16:_meta.json 创建与 schema 版本校验(老库首次静默创建)
|