From 33219644fda06969f9edabc2f742979de1ecf190 Mon Sep 17 00:00:00 2001 From: ssw Date: Thu, 2 Jul 2026 12:36:49 +0800 Subject: [PATCH] =?UTF-8?q?P2-4=20=E4=BF=AE=E5=A4=8D:=20portal=20setDefaul?= =?UTF-8?q?t=20id=20=E6=95=B0=E5=AD=97=E6=A0=A1=E9=AA=8C=20(2026-07-02)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FINDING-P5: setDefault 缺 id 数字校验 - 用户误传 --portalId=portal.fullName (字符串) - 走 resolveMenuIdFromPortal → loadMenu.getMenuList 拉全部菜单 - 客户端 filter moduleId='portal.fullName' (永真不匹配) - 返 'BS-110 无法解析 menuId' 误导, 浪费 1 次 menu list API 修复: - 入口加 /^\d{10,30}$/ 校验 (JNPF id 是 Long 雪花, 18-19 位) - 不合法直接 exit 1, 提示 '用 dacli portal list 查 id' - --menuId 同样校验 审计: dacli/docs/cmd-review/v0.14-rollout-audit-2026-07-02.md §3.1 P5 --- src/commands/portal/setDefault.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/commands/portal/setDefault.ts b/src/commands/portal/setDefault.ts index 4787341..3cb1bb7 100644 --- a/src/commands/portal/setDefault.ts +++ b/src/commands/portal/setDefault.ts @@ -79,6 +79,19 @@ export function buildPortalSetDefaultCommand(): Command { process.exit(1) } + // v0.15+ (P2-4): id 数字校验, 输错字符串 (如 fullName) → 直接 exit 1, 避免走 resolveMenuIdFromPortal 浪费 API + const idRegex = /^\d{10,30}$/ // JNPF id 是 Long 雪花, 通常 18-19 位数字 + if (opts.portalId && !idRegex.test(opts.portalId)) { + log.error(`--portalId "${opts.portalId}" 不是合法 JNPF id (期望纯数字 10-30 位, 如 842332446711088325)`) + log.error('提示: 用 `dacli portal list` 查 id, 别传 fullName/enCode') + process.exit(1) + } + if (opts.menuId && !idRegex.test(opts.menuId)) { + log.error(`--menuId "${opts.menuId}" 不是合法 JNPF id (期望纯数字 10-30 位)`) + log.error('提示: 用 `dacli menu list` 查 id') + process.exit(1) + } + const c = await JnpfClient.fromToken() await initPortalWebapi(c) await initMenuWebapi(c) // v0.15+: portalId 路径走 menu list 找 moduleId