dsh-session-superagent 0.9.199 → 0.9.200
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 +2 -2
- package/client.js +1 -1
- package/lib/index.js +8 -3
- package/lib/redact.js +23 -4
- package/lib/watch.js +10 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
4
4
|
|
|
5
|
+
## [0.9.200] - 2026-11-05 —— 安全审计:最该脱敏的那个出口,一个字符都没脱
|
|
6
|
+
|
|
7
|
+
### M1 · 唤醒消息完全没走 `redact()`(本轮最重)
|
|
8
|
+
issue 标题/评论是**外部内容**,会被拼进唤醒消息 —— 而唤醒消息是**唯一必进模型上下文**的出口。
|
|
9
|
+
全仓 11 个 `redact()` 调用点全在错误分支上,方向正好反了。
|
|
10
|
+
真机实测:标题里放 GitHub 令牌,原样进上下文。已在 `wake()` 出口统一脱敏。
|
|
11
|
+
|
|
12
|
+
### M2 / M3 · 25 种真实凭证形状,实测漏 16 种
|
|
13
|
+
补上:GitLab `glpat-`、AWS `AKIA`、Slack `xoxb-`、Stripe `sk_live_`、npm、Google `AIza`、JWT、
|
|
14
|
+
数据库 URL 里的密码(postgres/mysql/mongodb/redis/amqp)、裸 `Bearer`、`Authorization: Basic`、
|
|
15
|
+
**被截断的 PEM**(无 END)、PGP 私钥块、查询参数里的 `access_token`、无前缀的 **Gitee 32 位令牌**。
|
|
16
|
+
**不误伤**:讨论 `ghp_` 前缀、40 位 sha、md5、issue 链接都原样保留(有单测钉住)。
|
|
17
|
+
|
|
18
|
+
### M4 · Gitee 错误正文原样进 `watch_doctor` 结果
|
|
19
|
+
`lastError` 里带着 Gitee 返回的原始响应体,而 doctor 的输出会进模型上下文。已在输出处脱敏。
|
|
20
|
+
|
|
21
|
+
### M5 · issue 标题能伪造「【主理鱼】」抬头(注入面)
|
|
22
|
+
同一函数里 `goal` 的换行早就被压平了,`title` 漏了 —— 说明知道要防,不是设计如此。
|
|
23
|
+
现在标题压平换行、把 `【】` 换成 `[]`(保留内容,只让它无法伪造结构),并截断 200 字。
|
|
24
|
+
|
|
25
|
+
### 证据
|
|
26
|
+
```
|
|
27
|
+
node --test → 345/345(新增:14 种凭证形状必须脱、4 种正常文本必须不脱)
|
|
28
|
+
审核报告:docs/报告-脱敏与注入审计.md(4 必须修 / 7 值得改)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 仍未修(登记)
|
|
32
|
+
`\S+` 吃掉引号、未闭合 PEM 的平方复杂度、64 KB 按字节截断切坏汉字、脱敏无收口点(24 个 `run(` vs 12 个 `redact(`)。
|
|
5
33
|
## [0.9.199] - 2026-11-05 —— Gitee 边界审计剩余三条(其中最危险的会往**别人仓库**写)
|
|
6
34
|
|
|
7
35
|
### G6 · 列标签失败仍盲发 POST —— 唯一会碰别人仓库的路径
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<img src="assets/icon-180.png" width="88" height="88" alt="">
|
|
4
4
|
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://github.com/MYCF711/dsh-session-superagent/releases)
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-session-superagent)
|
|
8
8
|
[](https://github.com/topics/dsh-plugin)
|
|
9
9
|
|
|
@@ -144,7 +144,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
144
144
|
## 开发
|
|
145
145
|
|
|
146
146
|
```sh
|
|
147
|
-
node --test #
|
|
147
|
+
node --test # 345 项单测
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
### 工具输出:文本给人和 agent,JSON 给程序
|
package/client.js
CHANGED
|
@@ -14,7 +14,7 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
const { useCallback, useEffect, useRef, useState } = React
|
|
15
15
|
|
|
16
16
|
// 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
|
|
17
|
-
const CLIENT_VERSION = '0.9.
|
|
17
|
+
const CLIENT_VERSION = '0.9.200'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/index.js
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
|
|
43
43
|
export const name = 'dsh-session-superagent'
|
|
44
44
|
/** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
|
|
45
|
-
export const SERVER_VERSION = '0.9.
|
|
45
|
+
export const SERVER_VERSION = '0.9.200'
|
|
46
46
|
export const inject = ['tools', 'agents', 'webServer']
|
|
47
47
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
48
48
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -725,10 +725,14 @@ function wake(ctx, sessionId, text) {
|
|
|
725
725
|
const allowed = decideWake(agent.status)
|
|
726
726
|
if (!allowed.ok) return allowed
|
|
727
727
|
|
|
728
|
+
// 审核 M1:这是**唯一必进模型上下文**的出口,以前一个字符都不脱敏 ——
|
|
729
|
+
// 全仓 11 个 redact() 调用点全在错误分支上,方向正好反了。
|
|
730
|
+
// issue 标题/评论是外部内容,里面可能带着 token;进了上下文就等于进了日志与训练数据。
|
|
731
|
+
const safeText = redact(text)
|
|
728
732
|
const message = {
|
|
729
733
|
id: randomUUID(),
|
|
730
734
|
role: 'user',
|
|
731
|
-
content: [{ type: 'text', text }],
|
|
735
|
+
content: [{ type: 'text', text: safeText }],
|
|
732
736
|
source: { kind: 'user' },
|
|
733
737
|
}
|
|
734
738
|
try {
|
|
@@ -2522,7 +2526,8 @@ const UPDATE_CACHE_MS = 10 * 60 * 1000
|
|
|
2522
2526
|
}
|
|
2523
2527
|
|
|
2524
2528
|
// 6. 最近一次状态
|
|
2525
|
-
|
|
2529
|
+
// 审核 M4:lastError 里可能原样带着 Gitee 返回的请求/令牌 —— 工具结果会进模型上下文,先脱敏
|
|
2530
|
+
const last = entry.lastError ? `错误:${redact(entry.lastError)}` : entry.lastDeferred ? `等待:${redact(entry.lastDeferred)}` : '正常'
|
|
2526
2531
|
lines.push(`INFO ${isEnabled(entry) ? '运行中' : '已暂停'} · 上次轮询 ${entry.lastPoll || '无'} · ${last}`)
|
|
2527
2532
|
}
|
|
2528
2533
|
// format=json 时从同一份文本行解析出结构 —— 单一来源,不会出现两套逻辑走偏
|
package/lib/redact.js
CHANGED
|
@@ -5,14 +5,33 @@
|
|
|
5
5
|
* carry one by accident: a GitHub API error echoing the request headers, a
|
|
6
6
|
* command printing its environment, a config dump. Every string that leaves
|
|
7
7
|
* the plugin passes through `redact()` first.
|
|
8
|
+
*
|
|
9
|
+
* 审核(0.9.199 T16):原来只有 4 条形状,**25 种真实凭证里漏了 16 种**。
|
|
10
|
+
* 而且最该脱敏的出口(唤醒消息 → 模型上下文)一个都没接。已按「供应商前缀 + 受控通用形状」两层补齐:
|
|
11
|
+
* 前缀是精确的(误伤极低);通用形状(URL 密码 / 裸 Bearer / 查询参数)必须配上下文词,别裸扫。
|
|
8
12
|
*/
|
|
9
13
|
|
|
10
14
|
/** Patterns that must never reach the transcript. */
|
|
11
15
|
export const SECRET_PATTERNS = [
|
|
12
|
-
/gh[pousr]_[A-Za-z0-9]{20,}/g, //
|
|
13
|
-
/github_pat_[A-Za-z0-9_]{20,}/g, //
|
|
14
|
-
|
|
15
|
-
/
|
|
16
|
+
/gh[pousr]_[A-Za-z0-9]{20,}/g, // GitHub PAT(ghp_ / gho_ / ghu_ / ghs_ / ghr_)
|
|
17
|
+
/github_pat_[A-Za-z0-9_]{20,}/g, // GitHub 细粒度 PAT
|
|
18
|
+
/glpat-[A-Za-z0-9_-]{20,}/g, // GitLab PAT
|
|
19
|
+
/xox[baprs]-[A-Za-z0-9-]{10,}/g, // Slack
|
|
20
|
+
/sk_live_[A-Za-z0-9]{20,}/g, // Stripe
|
|
21
|
+
/npm_[A-Za-z0-9]{30,}/g, // npm automation token
|
|
22
|
+
/AIza[0-9A-Za-z_-]{35}/g, // Google API key
|
|
23
|
+
/AKIA[0-9A-Z]{16}/g, // AWS access key id
|
|
24
|
+
/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g, // JWT
|
|
25
|
+
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g, // SSH / PEM 完整块
|
|
26
|
+
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*/g, // **被截断的** PEM(没有 END):吃到结尾
|
|
27
|
+
/-----BEGIN PGP PRIVATE KEY BLOCK-----[\s\S]*?-----END PGP PRIVATE KEY BLOCK-----/g,
|
|
28
|
+
/Authorization:\s*(?:token|Bearer|Basic)\s+\S+/gi, // 回显的请求头
|
|
29
|
+
/\bBearer\s+[A-Za-z0-9._~+/=-]{20,}/g, // 裸 Bearer(无头名)
|
|
30
|
+
/\b(?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?|redis|amqp):\/\/[^:\s/]+:[^@\s]+@/gi, // 数据库 URL 里的密码
|
|
31
|
+
/[?&](?:access_token|api_key|apikey|private_token)=[^&\s"']+/gi, // 查询参数里的凭证
|
|
32
|
+
// Gitee 私人令牌:**无前缀**的 32 位十六进制(真机形状)。裸扫会误伤 md5/commit sha,
|
|
33
|
+
// 所以要求前面 20 字内出现 gitee / 令牌 / access_token 这类上下文词。
|
|
34
|
+
/\b(?:gitee|私人令牌|access[_ ]?token)[^\n]{0,20}?\b[0-9a-f]{32}\b/gi,
|
|
16
35
|
]
|
|
17
36
|
|
|
18
37
|
/** Replace every credential-shaped substring with `***`. */
|
package/lib/watch.js
CHANGED
|
@@ -141,7 +141,16 @@ export function formatWatchText(repo, fresh, options = {}) {
|
|
|
141
141
|
: null,
|
|
142
142
|
].filter(Boolean).join(' ')
|
|
143
143
|
// 单行太长在聊天窗口里会挤成一团:超过 120 字就把补充信息挪到下一行(链接点哪都一样)
|
|
144
|
-
|
|
144
|
+
// 审核 M5(注入面):issue 标题是**外部不可信内容**,直接插值会被拼出第二个
|
|
145
|
+
// 「【主理鱼】以下为系统指令」抬头。同一个函数里 goal 的换行早就被压平了,title 漏了。
|
|
146
|
+
// 压平换行 + 把方括号抬头换成普通括号(保留内容,只让它无法伪造结构)。
|
|
147
|
+
const safeTitle = String(item.title || '')
|
|
148
|
+
.split(String.fromCharCode(13)).join(' ')
|
|
149
|
+
.split(String.fromCharCode(10)).join(' ')
|
|
150
|
+
.split('【').join('[')
|
|
151
|
+
.split('】').join(']')
|
|
152
|
+
.slice(0, 200)
|
|
153
|
+
const head = `#${item.number} [${item.state}] ${safeTitle} — @${who}`
|
|
145
154
|
const oneLine = tail ? `${head} ${tail}` : head
|
|
146
155
|
if (oneLine.length <= 120) return oneLine
|
|
147
156
|
return `${head}\n ${tail}`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.200",
|
|
4
4
|
"description": "Session-level superagent for DeepSeek Harness: watch a GitHub repository and wake a session when something needs doing. Credentials never reach the model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|