Release v0.10.32: Semantic approval-runs link redesign, auth link standardization, and export defense
This commit is contained in:
1 parent
9060a28d8b
commit
972eff1436
31 files changed
+976
-288
No files matched your search
@@ -302,20 +302,35 @@ export async function handleApprovalRunsCommand(
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "url") {
|
||||
const sso = booleanOption(args.options.sso) ?? false;
|
||||
if (action === "link" || action === "url") {
|
||||
const autoLogin =
|
||||
booleanOption(args.options["auto-login"]) ??
|
||||
booleanOption(args.options.autoLogin) ??
|
||||
booleanOption(args.options["hose-sso"]) ??
|
||||
booleanOption(args.options.hoseSso) ??
|
||||
booleanOption(args.options.sso) ??
|
||||
false;
|
||||
const type = stringOption(args.options.type);
|
||||
const expiresIn = numberOption(args.options.expire) ?? numberOption(args.options.expiresIn) ?? 7200;
|
||||
const recordId = maybeName ?? stringOption(args.options.id) ?? stringOption(args.options.recordId);
|
||||
const sn = stringOption(args.options.sn) ?? stringOption(args.options.sourceDocumentSN);
|
||||
const sourceDocumentId = stringOption(args.options.sourceDocumentId);
|
||||
|
||||
if (!recordId && !sn && !sourceDocumentId) {
|
||||
throw new Error("Usage: seal-use approval-runs link <recordId> [--sn <sn>] [--type seal-result|hose-document] [--auto-login] [--corp <corpId>]");
|
||||
}
|
||||
|
||||
await runTool(
|
||||
"seal_approval_run_url_get",
|
||||
client,
|
||||
corp,
|
||||
{
|
||||
recordId: maybeName ?? stringOption(args.options.id) ?? stringOption(args.options.recordId),
|
||||
recordId,
|
||||
sourceDocumentSN: sn,
|
||||
sourceDocumentId: stringOption(args.options.sourceDocumentId),
|
||||
sso,
|
||||
sourceDocumentId,
|
||||
type,
|
||||
autoLogin,
|
||||
sso: autoLogin,
|
||||
expiresIn
|
||||
},
|
||||
outputOptions(args.options)
|
||||
@@ -395,7 +410,11 @@ export async function handleApprovalRunsCommand(
|
||||
booleanOption(args.options["exclude-deleted"]) ??
|
||||
(booleanOption(args.options["include-deleted"]) ? false : undefined),
|
||||
taskMode: stringOption(args.options.taskMode) ?? stringOption(args.options["task-mode"]),
|
||||
sourceSystem: stringOption(args.options.sourceSystem) ?? stringOption(args.options["source-system"])
|
||||
sourceSystem: stringOption(args.options.sourceSystem) ?? stringOption(args.options["source-system"]),
|
||||
includeSimulation:
|
||||
booleanOption(args.options["include-simulation"]) ??
|
||||
booleanOption(args.options.includeSimulation) ??
|
||||
booleanOption(args.options["simulation"])
|
||||
});
|
||||
console.error(`👉 查看导出文件: open "${result.filePath}"`);
|
||||
if (!args.options["with-flow"] && corp.source.type === "hose") {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { getMe } from "../../domains/seal/api.js";
|
||||
import { booleanOption, numberOption, stringOption } from "../parser.js";
|
||||
import { printJson, redactSensitiveText } from "../printer.js";
|
||||
import type { ParsedArgs } from "../types.js";
|
||||
import { runToolResult } from "../helpers.js";
|
||||
import { extractKeysFromLinkAction, showCorpKeysAction } from "./corps.js";
|
||||
|
||||
export async function handleAuthExtractKeysCommand(maybeName: string | undefined, args: ParsedArgs) {
|
||||
@@ -38,6 +39,22 @@ export async function handleAuthCommand(action: string | undefined, corp: CorpCo
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "seal-link" || action === "link" || (action === "hose-link" && corp.source.type === "seal")) {
|
||||
const client = await createSealClient(corp);
|
||||
const note = stringOption(args.options.note) ?? "CLI generated provisional access link";
|
||||
const delegation = await runToolResult(
|
||||
"seal_delegation_create",
|
||||
client,
|
||||
corp,
|
||||
{ note }
|
||||
);
|
||||
if (action === "hose-link") {
|
||||
console.error(`👉 提示: 企业「${corp.name}」源类型为 Seal 原生测试环境,已自动为您生成委托免登直达链接。`);
|
||||
}
|
||||
printJson(delegation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "hose-link") {
|
||||
const rawExpire = args.options.expire;
|
||||
const expiresIn = rawExpire !== undefined ? numberOption(rawExpire) : 7200;
|
||||
|
||||
@@ -842,6 +842,45 @@ describe("Hose OpenAPI key extraction from assistance link", () => {
|
||||
expect(authResult.stderr).toContain("合思子域专享能力");
|
||||
});
|
||||
|
||||
test("corps rename updates enterprise name successfully", async () => {
|
||||
const enterprises = setupConfigEnv();
|
||||
mkdirSync(enterprises, { recursive: true });
|
||||
writeFileSync(
|
||||
join(enterprises, "corp-rename.json"),
|
||||
JSON.stringify({
|
||||
id: "corp-rename",
|
||||
name: "待识别企业",
|
||||
environment: "production",
|
||||
seal: { url: "https://seal.example.com" },
|
||||
source: {
|
||||
type: "seal",
|
||||
sealUrl: "https://seal.example.com",
|
||||
token: "token-123"
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const result = await runCli(["corps", "rename", "corp-rename", "--name", "已识别真实企业"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
const parsed = JSON.parse(result.stdout);
|
||||
expect(parsed).toEqual({
|
||||
id: "corp-rename",
|
||||
previousName: "待识别企业",
|
||||
name: "已识别真实企业",
|
||||
success: true
|
||||
});
|
||||
|
||||
const updated = JSON.parse(readFileSync(join(enterprises, "corp-rename.json"), "utf-8"));
|
||||
expect(updated.name).toBe("已识别真实企业");
|
||||
});
|
||||
|
||||
test("corps rename rejects missing --name parameter", async () => {
|
||||
setupConfigEnv();
|
||||
const result = await runCli(["corps", "rename", "some-corp"]);
|
||||
expect(result.exitCode).toBe(2);
|
||||
expect(result.stderr).toContain("Usage: seal-use corps rename <corpId> --name <newName>");
|
||||
});
|
||||
|
||||
test("maskCellphone masks standard 11-digit mobile and non-standard phones safely", async () => {
|
||||
const { maskCellphone } = await import("./corps.js");
|
||||
expect(maskCellphone("13812345678")).toBe("138****5678");
|
||||
|
||||
@@ -270,6 +270,31 @@ export async function handleCorpsCommand(action: string | undefined, maybeName:
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "rename") {
|
||||
const targetCorpId =
|
||||
maybeName ??
|
||||
stringOption(args.options.corp) ??
|
||||
stringOption(args.options.id);
|
||||
const newName =
|
||||
stringOption(args.options.name) ??
|
||||
stringOption(args.options.to) ??
|
||||
(args.command[3] && !args.command[3].startsWith("-") ? args.command[3] : undefined);
|
||||
|
||||
if (!targetCorpId || !newName) {
|
||||
throw new Error("Usage: seal-use corps rename <corpId> --name <newName>");
|
||||
}
|
||||
|
||||
const corp = selectCorp(targetCorpId);
|
||||
const updated = updateCorpConfig(corp.id, { name: newName });
|
||||
printJson({
|
||||
success: true,
|
||||
id: updated.id,
|
||||
name: updated.name,
|
||||
previousName: corp.name
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "bind-test") {
|
||||
let prodId: string | undefined;
|
||||
let testId: string | undefined;
|
||||
@@ -954,12 +979,40 @@ export async function handleCorpsCommand(action: string | undefined, maybeName:
|
||||
}
|
||||
|
||||
if (action === "add-hose") {
|
||||
await addHoseCorp(jsonObject(args.json));
|
||||
const jsonPayload = jsonObject(args.json);
|
||||
const merged = {
|
||||
...jsonPayload,
|
||||
...(args.options.staffName ? { staffName: stringOption(args.options.staffName) } : {}),
|
||||
...(args.options["staff-name"] ? { staffName: stringOption(args.options["staff-name"]) } : {}),
|
||||
...(args.options.staffPhone ? { staffPhone: stringOption(args.options.staffPhone) } : {}),
|
||||
...(args.options["staff-phone"] ? { staffPhone: stringOption(args.options["staff-phone"]) } : {}),
|
||||
...(args.options.name ? { name: stringOption(args.options.name) } : {}),
|
||||
...(args.options.domain ? { domain: stringOption(args.options.domain) } : {}),
|
||||
...(args.options.corpId ? { corpId: stringOption(args.options.corpId) } : {}),
|
||||
...(args.options["corp-id"] ? { corpId: stringOption(args.options["corp-id"]) } : {}),
|
||||
...(args.options.appKey ? { appKey: stringOption(args.options.appKey) } : {}),
|
||||
...(args.options["app-key"] ? { appKey: stringOption(args.options["app-key"]) } : {}),
|
||||
...(args.options.appSecurity ? { appSecurity: stringOption(args.options.appSecurity) } : {}),
|
||||
...(args.options["app-security"] ? { appSecurity: stringOption(args.options["app-security"]) } : {}),
|
||||
...(args.options.force !== undefined ? { force: booleanOption(args.options.force) } : {}),
|
||||
...(args.options.overwrite !== undefined ? { overwrite: booleanOption(args.options.overwrite) } : {})
|
||||
};
|
||||
await addHoseCorp(merged);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "add-seal") {
|
||||
await addSealCorp(jsonObject(args.json));
|
||||
const jsonPayload = jsonObject(args.json);
|
||||
const merged = {
|
||||
...jsonPayload,
|
||||
...(args.options.name ? { name: stringOption(args.options.name) } : {}),
|
||||
...(args.options.token ? { token: stringOption(args.options.token) } : {}),
|
||||
...(args.options.sealUrl ? { sealUrl: stringOption(args.options.sealUrl) } : {}),
|
||||
...(args.options.url ? { sealUrl: stringOption(args.options.url) } : {}),
|
||||
...(args.options.force !== undefined ? { force: booleanOption(args.options.force) } : {}),
|
||||
...(args.options.overwrite !== undefined ? { overwrite: booleanOption(args.options.overwrite) } : {})
|
||||
};
|
||||
await addSealCorp(merged);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1410,7 +1463,9 @@ async function addHoseCorp(input: Record<string, unknown>) {
|
||||
mkdirSync(enterprisesDir, { recursive: true, mode: 0o700 });
|
||||
const file = join(enterprisesDir, `${safeFileName(id)}.json`);
|
||||
if (existsSync(file) && input.overwrite !== true) {
|
||||
throw new Error(`Enterprise config already exists: ${file}. Pass "overwrite": true to replace it.`);
|
||||
throw new Error(
|
||||
`Enterprise config already exists: ${file}。如需覆盖已有配置,请在命令行追加 --overwrite 或在 JSON 参数中添加 "overwrite": true。`
|
||||
);
|
||||
}
|
||||
|
||||
writeFileSync(file, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
||||
|
||||
@@ -228,4 +228,26 @@ describe("seal-use test regression CLI", () => {
|
||||
expect(payload.verdict).toBe("DRY_RUN");
|
||||
expect(payload.targetCorp.id).toBe("corp-test");
|
||||
});
|
||||
|
||||
test("test regression accepts --webhook option and succeeds in dry-run", async () => {
|
||||
setupTestEnv();
|
||||
mockApiFetch();
|
||||
|
||||
const result = await runCli([
|
||||
"test",
|
||||
"regression",
|
||||
"--corp",
|
||||
"corp-test",
|
||||
"--samples",
|
||||
"2",
|
||||
"--dry-run",
|
||||
"--webhook",
|
||||
"自定义通道"
|
||||
]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
|
||||
const payload = JSON.parse(result.stdout);
|
||||
expect(payload.verdict).toBe("DRY_RUN");
|
||||
expect(payload.targetCorp.id).toBe("corp-test");
|
||||
});
|
||||
});
|
||||
@@ -74,6 +74,7 @@ export async function handleTestCommand(
|
||||
const pollIntervalMs = numberOption(args.options["poll-interval"]) ?? 2000;
|
||||
const timeoutMs = numberOption(args.options.timeout) ?? 45000;
|
||||
const snPrefix = stringOption(args.options["sn-prefix"]) ?? "REG_";
|
||||
const webhookSelector = stringOption(args.options.webhook) ?? stringOption(args.options.selector);
|
||||
|
||||
const result = await runRegressionTest({
|
||||
sourceCorp,
|
||||
@@ -85,7 +86,8 @@ export async function handleTestCommand(
|
||||
pollIntervalMs,
|
||||
timeoutMs,
|
||||
snPrefix,
|
||||
failOnFlips
|
||||
failOnFlips,
|
||||
webhookSelector
|
||||
});
|
||||
|
||||
const isQuiet = booleanOption(args.options.quiet) || booleanOption(args.options.silent);
|
||||
|
||||
+43
-8
@@ -77,6 +77,15 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
],
|
||||
description: "Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."
|
||||
},
|
||||
{
|
||||
name: "rename",
|
||||
summary: "Rename an enterprise display name",
|
||||
usage: ["seal-use corps rename <corpId> --name <newName>"],
|
||||
options: [
|
||||
{ flag: "--name <newName>", description: "New human-readable enterprise name (required)" }
|
||||
],
|
||||
description: "Safely updates the display name of a configured enterprise without modifying underlying files manually."
|
||||
},
|
||||
{
|
||||
name: "bind-test",
|
||||
summary: "Bind a production enterprise to a test enterprise (1-to-1 association)",
|
||||
@@ -449,13 +458,28 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
usage: ["seal-use approval-runs result <recordId> [--summary] [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "url",
|
||||
summary: "Get web console URL for approval run (default deep link, or --sso for auto-login link)",
|
||||
name: "link",
|
||||
aliases: ["url"],
|
||||
summary: "Get web console link for an approval run (Seal AI audit result or Hose original document)",
|
||||
usage: [
|
||||
"seal-use approval-runs url <recordId> [--corp <corpId>]",
|
||||
"seal-use approval-runs url <recordId> --sso [--expire 7200] [--corp <corpId>]",
|
||||
"seal-use approval-runs url --sn <documentSN> [--sso] [--corp <corpId>]",
|
||||
"seal-use approval-runs url [--corp <corpId>]"
|
||||
"seal-use approval-runs link <recordId> [--corp <corpId>]",
|
||||
"seal-use approval-runs link <recordId> --auto-login [--expire 7200] [--corp <corpId>]",
|
||||
"seal-use approval-runs link <recordId> --type hose-document [--corp <corpId>]",
|
||||
"seal-use approval-runs link --sn <documentSN> [--auto-login] [--corp <corpId>]"
|
||||
],
|
||||
options: [
|
||||
{
|
||||
flag: "--type <seal-result|hose-document>",
|
||||
description: "Link type: 'seal-result' (Seal AI audit result page, default) or 'hose-document' (Hose original form)"
|
||||
},
|
||||
{
|
||||
flag: "--auto-login",
|
||||
description: "Generate auto-login ticketed link (for seal-result type, valid for --expire seconds)"
|
||||
},
|
||||
{
|
||||
flag: "--expire <seconds>",
|
||||
description: "Auto-login ticket expiration in seconds (default: 7200)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -674,16 +698,27 @@ export const HELP_REGISTRY: AreaHelp[] = [
|
||||
summary: "Diagnose auth session and platform connectivity",
|
||||
usage: ["seal-use auth diagnose [--corp <corpId>]"]
|
||||
},
|
||||
{
|
||||
name: "link",
|
||||
aliases: ["seal-link"],
|
||||
summary: "【Seal 审核后台】生成免密登录/委托访问直达链接",
|
||||
usage: ["seal-use auth link [--note <note>] [--corp <corpId>]"],
|
||||
options: [
|
||||
{ flag: "--note <note>", description: "委托授权备注说明(如:演示测试、外部审计)" }
|
||||
],
|
||||
description:
|
||||
"生成访问当前企业 Seal AI 智能审核后台 (https://<tenant>.sealai.cc/delegate) 的免密直达链接。主体作用于 Seal 审核台,等价于快捷生成 delegation 委托访问链接。"
|
||||
},
|
||||
{
|
||||
name: "hose-link",
|
||||
summary: "【合思主站】生成免密登录/第三方协助入口链接",
|
||||
summary: "【合思外部主站】生成免密登录/第三方协助入口链接",
|
||||
usage: ["seal-use auth hose-link [--corp <corpId>] [--expire 7200] [--force]"],
|
||||
options: [
|
||||
{ flag: "--expire <seconds>", description: "链接有效时间(秒),默认 7200,支持如 86400(1天)" },
|
||||
{ flag: "--force, --refresh, -f", description: "强制向合思 OpenAPI 申请全新临时凭证" }
|
||||
],
|
||||
description:
|
||||
"专用于合思 (Hose) 来源企业。向合思申请临时 ticket,生成直达合思/易快报主站 (https://app.ekuaibao.com/web/thirdparty.html) 的免密登录链接。凭证独立生成,不读取亦不污染 CLI 内部会话。注意:此链接不可通过 'seal-use delegation list' 查询(后者仅管理 Seal 审核后台的委托令牌)。"
|
||||
"专用于合思 (Hose) 来源企业。向合思申请临时 ticket,生成直达外部合思/易快报主站 (https://app.ekuaibao.com/web/thirdparty.html) 的免密登录链接。若需生成 Seal 自身的审核后台访问链接,请使用 'seal-use auth link'。"
|
||||
},
|
||||
{
|
||||
name: "extract-keys",
|
||||
|
||||
@@ -23,7 +23,12 @@ describe("CLI read-only classification", () => {
|
||||
const ACTIONS_WITHOUT_REGISTRY_ENTRY = new Set(["approval-runs search"]);
|
||||
|
||||
test("every allow-listed command exists in the help registry", () => {
|
||||
const byArea = new Map(HELP_REGISTRY.map((area) => [area.area, area.commands.map((c) => c.name)]));
|
||||
const byArea = new Map(
|
||||
HELP_REGISTRY.map((area) => [
|
||||
area.area,
|
||||
area.commands.flatMap((c) => [c.name, ...(c.aliases ?? [])])
|
||||
])
|
||||
);
|
||||
|
||||
for (const { area, action } of listReadOnlyCommands()) {
|
||||
if (ACTIONS_WITHOUT_REGISTRY_ENTRY.has(`${area} ${action}`)) continue;
|
||||
|
||||
@@ -46,6 +46,7 @@ const READ_ONLY_COMMANDS: Record<string, string[]> = {
|
||||
"document-summary",
|
||||
"attachments",
|
||||
"result",
|
||||
"link",
|
||||
"url"
|
||||
],
|
||||
simulation: [
|
||||
|
||||
Reference in new issue
Block a user