dsh-session-superagent 0.9.198 → 0.9.199
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 +24 -0
- package/README.md +2 -2
- package/client.js +1 -1
- package/lib/gitee.js +23 -2
- package/lib/index.js +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
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.199] - 2026-11-05 —— Gitee 边界审计剩余三条(其中最危险的会往**别人仓库**写)
|
|
6
|
+
|
|
7
|
+
### G6 · 列标签失败仍盲发 POST —— 唯一会碰别人仓库的路径
|
|
8
|
+
`ensureGiteeLabel()` 先 `GET /labels` 查重,再 `POST` 建。但**查失败时它也照发**:
|
|
9
|
+
读不到现有标签就建 —— 等于在**别人仓库**里造重复标签。现在读失败就老实回报 `list-failed`。
|
|
10
|
+
实测:403 时 POST 次数 = **0**。
|
|
11
|
+
|
|
12
|
+
### G7 · 每条 Gitee 守都恒挂「只读」徽章
|
|
13
|
+
`mapGiteeRepoAccess()` 读 `permissions.push`,而 Gitee 的仓库对象里**根本没有** `permissions` 字段(67 个键都没有它)。
|
|
14
|
+
`undefined === true` 恒 false → 每条 Gitee 守都显示「只读」+「你只有读权限」假警告。
|
|
15
|
+
改成「字段不存在 → `push: null`(不知道)」,面板按 `=== false` 才提示只读。
|
|
16
|
+
|
|
17
|
+
### G3 · 只取一页,截断的部分静默消失
|
|
18
|
+
`listGiteeItems()` 只读一页且不告诉调用方「满了」。停机恢复/首次轮询时最危险:
|
|
19
|
+
**攒了 30 条只看到 20 条,另外 10 条永远不再出现**(`cursor` 还会推进过去)。
|
|
20
|
+
现在回 `truncated: true`,轮询路径**这一轮不推进水位**并留一条事件。
|
|
21
|
+
|
|
22
|
+
### 证据
|
|
23
|
+
```
|
|
24
|
+
node --test → 343/343(新增:盲发 POST 守卫、permissions 缺失、truncated 三条)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 仍未修(登记)
|
|
28
|
+
G2(`request()` 不读响应头)、G4(Gitee 分支沿用 GitHub 措辞)。
|
|
5
29
|
## [0.9.198] - 2026-11-05 —— Gitee 边界审计「值得改」三条:403 限流、404 被抢、非数组抛错
|
|
6
30
|
|
|
7
31
|
### G1 · 线上 Gitee 限流回的是 **403**,不是 429
|
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 # 343 项单测
|
|
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.199'
|
|
18
18
|
let BASE = '/session-superagent'
|
|
19
19
|
/**
|
|
20
20
|
* 挑「最新的那个服务端实例」。
|
package/lib/gitee.js
CHANGED
|
@@ -106,7 +106,8 @@ export async function listGiteeItems({ repo, token = '', perPage = 20, since = '
|
|
|
106
106
|
// 真机验证:since 传给未来时间 → 返回 [];传今天 → 只返回今天之后更新的。
|
|
107
107
|
// 两个端点都支持,缺了它就只能每轮全量读。
|
|
108
108
|
const sinceQ = since ? '&since=' + encodeURIComponent(String(since)) : ''
|
|
109
|
-
const
|
|
109
|
+
const size = Math.max(1, Math.min(100, Number(perPage) || 20))
|
|
110
|
+
const q = 'state=all&sort=updated&direction=desc&per_page=' + size + sinceQ
|
|
110
111
|
const [issues, pulls] = await Promise.all([
|
|
111
112
|
request(`/repos/${repo}/issues?${q}`, { token, fetchImpl }),
|
|
112
113
|
request(`/repos/${repo}/pulls?${q}`, { token, fetchImpl }),
|
|
@@ -114,11 +115,16 @@ export async function listGiteeItems({ repo, token = '', perPage = 20, since = '
|
|
|
114
115
|
if (!issues.ok && !pulls.ok) {
|
|
115
116
|
return { ok: false, status: issues.status || pulls.status, error: issues.error || pulls.error }
|
|
116
117
|
}
|
|
118
|
+
// 审核 G3:只取一页时,超出的部分会**静默消失**,而 cursor 还会推进过去 ——
|
|
119
|
+
// 停机恢复/首次轮询时最危险(攒了 30 条只看到 20 条,另外 10 条永远不再出现)。
|
|
120
|
+
// 这里如实告诉调用方「满了,可能被截断」,由它决定是否推迟推进水位。
|
|
121
|
+
const truncated = [issues, pulls].some((res) => res.ok && Array.isArray(res.data) && res.data.length >= size)
|
|
117
122
|
return {
|
|
118
123
|
ok: true,
|
|
119
124
|
items: normalizeGiteeList(issues.ok ? issues.data : [], pulls.ok ? pulls.data : []),
|
|
120
125
|
// 一半成功也要说清楚:否则客户以为 PR 一条都没有
|
|
121
126
|
partial: !issues.ok || !pulls.ok ? (issues.ok ? 'pulls' : 'issues') : null,
|
|
127
|
+
truncated,
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
@@ -172,9 +178,14 @@ export async function giteeRepo({ repo, token = '', fetchImpl } = {}) {
|
|
|
172
178
|
*/
|
|
173
179
|
export function mapGiteeRepoAccess(repo, info = {}) {
|
|
174
180
|
const perms = info.permissions || {}
|
|
181
|
+
// 审核 G7:Gitee 的仓库对象里**没有** `permissions` 字段(67 个键都没有它)。
|
|
182
|
+
// 以前 `perms.push === true` 恒 false → 每条 Gitee 守都恒挂「只读」徽章 + 「你只有读权限」假警告。
|
|
183
|
+
// 没有这个字段时 `push` 应该是 `null`(不知道),不是 `false`(只读)——
|
|
184
|
+
// 调用方按 `=== false` 才提示只读。
|
|
185
|
+
const known = info.permissions && typeof info.permissions === 'object'
|
|
175
186
|
return {
|
|
176
187
|
repo,
|
|
177
|
-
push: perms.push === true || perms.admin === true,
|
|
188
|
+
push: known ? (perms.push === true || perms.admin === true) : null,
|
|
178
189
|
private: info.private === true,
|
|
179
190
|
fork: Boolean(info.parent) || info.fork === true,
|
|
180
191
|
hasIssues: info.has_issues !== false,
|
|
@@ -221,6 +232,16 @@ export async function ensureGiteeLabel({ repo, token = '', label, color = 'edede
|
|
|
221
232
|
if (listed.ok) {
|
|
222
233
|
const names = (Array.isArray(listed.data) ? listed.data : []).map((item) => String(item && item.name || ''))
|
|
223
234
|
if (names.includes(name)) return { ok: true, created: false, reason: 'already-exists' }
|
|
235
|
+
} else {
|
|
236
|
+
// 审核 G6:**列标签失败时不许盲发 POST**。
|
|
237
|
+
// 这是唯一会往「别人仓库」写的路径 —— 读不到现有标签就去建,等于在别人仓库里造重复标签。
|
|
238
|
+
// 读失败就老实回报失败,让客户知道是「查不到」而不是「没有」。
|
|
239
|
+
return {
|
|
240
|
+
ok: false,
|
|
241
|
+
reason: 'list-failed',
|
|
242
|
+
status: listed.status,
|
|
243
|
+
error: '查不到现有标签(HTTP ' + (listed.status || '?') + '):' + String(listed.error || '').slice(0, 120),
|
|
244
|
+
}
|
|
224
245
|
}
|
|
225
246
|
const created = await request(`/repos/${repo}/labels`, { token, method: 'POST', body: { name, color }, fetchImpl })
|
|
226
247
|
if (created.ok) return { ok: true, created: true, reason: 'created' }
|
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.199'
|
|
46
46
|
export const inject = ['tools', 'agents', 'webServer']
|
|
47
47
|
/** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
|
|
48
48
|
// 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
|
|
@@ -1097,6 +1097,14 @@ async function pollOnce(ctx, entry, baseMs) {
|
|
|
1097
1097
|
}
|
|
1098
1098
|
// 一半成功(issue 拿到、PR 没拿到)要说出来,否则客户以为 PR 一条都没有
|
|
1099
1099
|
if (listed.partial) noteEvent(entry, 'partial', 'Gitee ' + (listed.partial === 'pulls' ? 'PR' : 'issue') + ' 列表这一轮没拿到')
|
|
1100
|
+
// 审核 G3:一页满了 = 可能被截断。这一轮**不推进水位**,否则被截掉的那些永远不再出现
|
|
1101
|
+
// (停机恢复/首次轮询时最危险:攒了 30 条只看到 20 条,另外 10 条静默丢掉)。
|
|
1102
|
+
if (listed.truncated) {
|
|
1103
|
+
noteEvent(entry, 'partial', 'Gitee 列表满了一页(可能被截断):这一轮不推进水位,下一轮接着读')
|
|
1104
|
+
entry.lastDeferred = 'Gitee 列表可能被截断,水位先不动'
|
|
1105
|
+
entry.deferReason = 'truncated'
|
|
1106
|
+
return
|
|
1107
|
+
}
|
|
1100
1108
|
const items = listed.items || []
|
|
1101
1109
|
if (items.length === 0) {
|
|
1102
1110
|
entry.lastError = null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-superagent",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.199",
|
|
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",
|