dsh-rank-scan 0.6.3 → 0.6.4
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/README.md +3 -3
- package/lib/index.js +40 -11
- package/lib/index.js.map +1 -1
- package/lib/scan/guard.js +5 -0
- package/lib/scan/guard.js.map +1 -1
- package/lib/scan/store.js +19 -2
- package/lib/scan/store.js.map +1 -1
- package/lib/sites/qidiantu.js +4 -1
- package/lib/sites/qidiantu.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ DeepSeek Harness 扫榜插件:定时 + 按需采集多站小说榜单,算变
|
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
dsh plugin --profile desktop add github:kilo-s/dsh-rank-scan
|
|
21
|
-
# 钉版本:github:kilo-s/dsh-rank-scan#v0.6.
|
|
21
|
+
# 钉版本:github:kilo-s/dsh-rank-scan#v0.6.4
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
仓库不含编译产物,这条命令会在安装时现场构建 `lib/`。首次可能被 pnpm 拦下构建脚本(它会打印要放行的键,加进 `allowBuilds` 后重跑即可),细节见 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)。
|
|
@@ -37,14 +37,14 @@ dsh plugin --profile desktop add "<tgz 的完整路径>"
|
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
39
|
dsh plugin --profile desktop add dsh-rank-scan
|
|
40
|
-
# 钉版本:dsh-rank-scan@0.6.
|
|
40
|
+
# 钉版本:dsh-rank-scan@0.6.4
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
npm 上那份是 CI 从源码构建的(包内自带 `lib/`,发布带 `--provenance` 签名)——装的时候不用再编译,也不会被 pnpm 的 `allowBuilds` 拦下。面板的「检查更新」读的就是 npm 上的版本号。
|
|
44
44
|
|
|
45
45
|
**验证**:重开 DSH 后左侧栏会话列表下方应出现「扫榜」入口;或访问 `http://127.0.0.1:19387/api/rank-scan/health`,返回 `{ok:true,...}` 即通。
|
|
46
46
|
|
|
47
|
-
**更新**:重跑安装命令即可(链接直装取最新 `main`,registry 装取最新发布版;本版本为 **0.6.
|
|
47
|
+
**更新**:重跑安装命令即可(链接直装取最新 `main`,registry 装取最新发布版;本版本为 **0.6.4**);面板「设置」页底部会读 npm 上的版本号提示有没有新版,装了 [dsh-market](https://github.com/dsh-market/dsh-market) 的话还能就地更新。
|
|
48
48
|
|
|
49
49
|
**卸载**:`dsh plugin --profile desktop remove dsh-rank-scan`。数据目录 `~/.dsh/data/rank-scan` 会保留,要彻底清理自行删除;脚本化卸载与 patch 安全口径见 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)。
|
|
50
50
|
|
package/lib/index.js
CHANGED
|
@@ -69,6 +69,15 @@ const pad2 = (n) => String(n).padStart(2, '0');
|
|
|
69
69
|
* 使用者若刻意把菠萝包调回 09:30,会被再改掉一次 —— 与「调过的不动」自相矛盾。
|
|
70
70
|
*/
|
|
71
71
|
const TIMER_SCHEMA_V = 7;
|
|
72
|
+
/**
|
|
73
|
+
* ★ 2026-11-02(审查 M1):boardId 会直入快照路径拼接
|
|
74
|
+
* (store.readSnapshot/writeSnapshot 的 join(root, dataDate, boardId + '.json')),
|
|
75
|
+
* 而它来自 HTTP query/body 与持久化配置 —— 未校验时 '../../x' 可读出数据根之外的任意 .json,
|
|
76
|
+
* /select 还会把恶意 boardId 持久化(之后每次 /overview 自动触发一次穿越读)。
|
|
77
|
+
* 只放行「字母数字开头 + 字母数字/./_/-」⇒ 无路径分隔符、无 '..' 段。store 层另有兜底。
|
|
78
|
+
*/
|
|
79
|
+
const BOARD_ID_SAFE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
80
|
+
const isValidBoardId = (b) => BOARD_ID_SAFE.test(b);
|
|
72
81
|
function defaultState() {
|
|
73
82
|
return {
|
|
74
83
|
scanTime: '01:30',
|
|
@@ -3663,8 +3672,8 @@ export function apply(ctx, config) {
|
|
|
3663
3672
|
return send(200, await panelOverview());
|
|
3664
3673
|
if (p === '/api/rank-scan/board') {
|
|
3665
3674
|
const b = q.get('boardId');
|
|
3666
|
-
if (!b)
|
|
3667
|
-
return send(400, { error: 'boardId
|
|
3675
|
+
if (!b || !isValidBoardId(b))
|
|
3676
|
+
return send(400, { error: 'boardId 必填且只能是字母、数字、点、下划线、连字符' });
|
|
3668
3677
|
return send(200, await panelBoard(b, q.get('date') || undefined, q.get('sort') || undefined, Number(q.get('limit') || 0)));
|
|
3669
3678
|
}
|
|
3670
3679
|
if (p === '/api/rank-scan/changes')
|
|
@@ -3676,6 +3685,9 @@ export function apply(ctx, config) {
|
|
|
3676
3685
|
const st3 = readState();
|
|
3677
3686
|
if (Array.isArray(body.captures)) {
|
|
3678
3687
|
const posted = body.captures.map(String);
|
|
3688
|
+
// ★ 审查 M1:boardId 直入快照路径 ⇒ 非法字符(路径分隔符/..)直接拒,不持久化
|
|
3689
|
+
if (posted.some((b) => !isValidBoardId(b)))
|
|
3690
|
+
return send(400, { error: 'boardId 含非法字符(只允许字母、数字、点、下划线、连字符)' });
|
|
3679
3691
|
// 面板只能管清单内的榜;清单外的既有抓取项原样保留(防止「保存丢榜」)
|
|
3680
3692
|
const known = new Set(catalog().boards.map((b) => b.boardId));
|
|
3681
3693
|
const keep = st3.boards.filter((b) => !known.has(b));
|
|
@@ -3683,8 +3695,12 @@ export function apply(ctx, config) {
|
|
|
3683
3695
|
// 口径:抓了就要显示 ⇒ 显示集跟随抓取集(派生榜随番茄开关自动进出)
|
|
3684
3696
|
st3.display = st3.boards.filter((b) => !b.startsWith('fanqie.derived.'));
|
|
3685
3697
|
}
|
|
3686
|
-
if (Array.isArray(body.displays))
|
|
3687
|
-
|
|
3698
|
+
if (Array.isArray(body.displays)) {
|
|
3699
|
+
const disp = body.displays.map(String);
|
|
3700
|
+
if (disp.some((b) => !isValidBoardId(b)))
|
|
3701
|
+
return send(400, { error: 'boardId 含非法字符(只允许字母、数字、点、下划线、连字符)' });
|
|
3702
|
+
st3.display = disp;
|
|
3703
|
+
}
|
|
3688
3704
|
if (typeof body.autoEnrich === 'boolean')
|
|
3689
3705
|
st3.autoEnrich = body.autoEnrich;
|
|
3690
3706
|
if (typeof body.qidianEnrich === 'boolean')
|
|
@@ -3760,8 +3776,8 @@ export function apply(ctx, config) {
|
|
|
3760
3776
|
const body = await readBody(req);
|
|
3761
3777
|
const boardId = String(body.boardId || '');
|
|
3762
3778
|
const n = Math.max(1, Math.min(100, Number(body.depth) || 10));
|
|
3763
|
-
if (!boardId)
|
|
3764
|
-
return send(400, { error: 'boardId
|
|
3779
|
+
if (!boardId || !isValidBoardId(boardId))
|
|
3780
|
+
return send(400, { error: 'boardId 必填且只能是字母、数字、点、下划线、连字符' });
|
|
3765
3781
|
const st2 = readState();
|
|
3766
3782
|
st2.depths = { ...(st2.depths || {}), [boardId]: n };
|
|
3767
3783
|
writeState(st2);
|
|
@@ -3818,8 +3834,8 @@ export function apply(ctx, config) {
|
|
|
3818
3834
|
catch (e) {
|
|
3819
3835
|
return send(400, { error: e instanceof Error ? e.message : String(e) });
|
|
3820
3836
|
}
|
|
3821
|
-
if (!boardId)
|
|
3822
|
-
return send(400, { error: 'boardId
|
|
3837
|
+
if (!boardId || !isValidBoardId(boardId))
|
|
3838
|
+
return send(400, { error: 'boardId 必填且只能是字母、数字、点、下划线、连字符' });
|
|
3823
3839
|
const stDay = readState();
|
|
3824
3840
|
const site = serveSiteFor([boardId], stDay.depths || {})[0];
|
|
3825
3841
|
if (!site)
|
|
@@ -3872,6 +3888,8 @@ export function apply(ctx, config) {
|
|
|
3872
3888
|
return send(200, { ok: true, dropped: date, gone: !existsSync(dir) });
|
|
3873
3889
|
}
|
|
3874
3890
|
const b = String(body.boardId || 'qidiantu.shouding');
|
|
3891
|
+
if (!isValidBoardId(b))
|
|
3892
|
+
return send(400, { error: 'boardId 含非法字符(只允许字母、数字、点、下划线、连字符)' });
|
|
3875
3893
|
const st4 = readState();
|
|
3876
3894
|
const site = serveSiteFor([b], st4.depths || {})[0];
|
|
3877
3895
|
if (!site)
|
|
@@ -3931,8 +3949,8 @@ export function apply(ctx, config) {
|
|
|
3931
3949
|
if (String(req.method || 'GET').toUpperCase() !== 'POST')
|
|
3932
3950
|
return send(405, { error: 'POST only' });
|
|
3933
3951
|
const b = q.get('boardId');
|
|
3934
|
-
if (!b)
|
|
3935
|
-
return send(400, { error: 'boardId
|
|
3952
|
+
if (!b || !isValidBoardId(b))
|
|
3953
|
+
return send(400, { error: 'boardId 必填且只能是字母、数字、点、下划线、连字符' });
|
|
3936
3954
|
const resE = await enrichBoard(b, forceQ);
|
|
3937
3955
|
/**
|
|
3938
3956
|
* ★ 2026-10-17:手动「补全本榜」补齐后要**把待办销掉** —— 以前只有后台工人那一圈会清,
|
|
@@ -3968,6 +3986,8 @@ export function apply(ctx, config) {
|
|
|
3968
3986
|
return send(405, { error: 'POST only' });
|
|
3969
3987
|
const forceQ = q.get('force') === '1' || q.get('force') === 'true';
|
|
3970
3988
|
const bid = q.get('boardId');
|
|
3989
|
+
if (bid && !isValidBoardId(bid))
|
|
3990
|
+
return send(400, { error: 'boardId 含非法字符(只允许字母、数字、点、下划线、连字符)' });
|
|
3971
3991
|
if (bid)
|
|
3972
3992
|
return send(200, await qidianEnrichBoard(bid, forceQ));
|
|
3973
3993
|
// 不带 boardId = 把抓取集里的起点榜逐个补(仍受每榜请求上限保护)
|
|
@@ -4106,6 +4126,9 @@ export function apply(ctx, config) {
|
|
|
4106
4126
|
if (action === 'add') {
|
|
4107
4127
|
let row = body.row || null;
|
|
4108
4128
|
let boardId = String(body.boardId || '');
|
|
4129
|
+
// ★ 审查 M1:boardId 会用于 readSnapshot 路径拼接 ⇒ 先卡格式
|
|
4130
|
+
if (boardId && !isValidBoardId(boardId))
|
|
4131
|
+
return send(400, { error: 'boardId 含非法字符(只允许字母、数字、点、下划线、连字符)' });
|
|
4109
4132
|
let dataDate = String(body.dataDate || '');
|
|
4110
4133
|
/**
|
|
4111
4134
|
* ★ 只给了 bookKey 的情况(「变化集」就是这么调用的):去本地快照里把这本书找出来,
|
|
@@ -4291,7 +4314,13 @@ export function apply(ctx, config) {
|
|
|
4291
4314
|
if (String(req.method || 'GET').toUpperCase() !== 'POST')
|
|
4292
4315
|
return send(405, { error: 'POST only' });
|
|
4293
4316
|
const body3 = await readBody(req);
|
|
4294
|
-
|
|
4317
|
+
// ★ 2026-11-02(审查 M2):与 export-file 同一道白名单 —— 只允许用户目录内的路径,
|
|
4318
|
+
// 且**先校验再 existsSync**:UNC 路径(\\host\share)光 existsSync 就会发起 SMB 认证,
|
|
4319
|
+
// 把本地 NTLM 哈希发给攻击者主机。
|
|
4320
|
+
const dir = resolve(String(body3.path || '').trim() || join(homedir(), 'Documents', 'rank-scan-export'));
|
|
4321
|
+
const relF = relative(resolve(homedir()), dir);
|
|
4322
|
+
if (!relF || relF === '..' || relF.startsWith('..' + (process.platform === 'win32' ? '\\' : '/')) || isAbsolute(relF))
|
|
4323
|
+
return send(400, { error: '只允许打开用户目录内的文件夹' });
|
|
4295
4324
|
if (!existsSync(dir))
|
|
4296
4325
|
return send(400, { error: '目录还不存在:' + dir + '(先导出一次就会创建)' });
|
|
4297
4326
|
const cmd = process.platform === 'win32' ? 'explorer.exe' : process.platform === 'darwin' ? 'open' : 'xdg-open';
|