fix: 标明工作流扫描与分析证据完整性

保留不完整扫描中的既有告警指纹,并展示分页和分析证据不足。
This commit is contained in:
gitea committed 2026-10-30 17:37:05 +08:00
1 parent c6d71843b7
commit c813498da2
8 files changed
+84 -22

No files matched your search

+11 -8
View File
@@ -21,6 +21,7 @@ export async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime):
const detail = await getWorkflowDetail(client, pipelineId);
const specIds = extractWorkflowSpecificationIds(detail);
const specifications: Record<string, WorkflowFormSpecLike | undefined> = {};
const evidenceErrors: Array<{ source: string; message: string }> = [];
if (specIds.length > 0) {
const corpId = runtime.selectedCorp!.corpId || runtime.selectedCorp!.id;
await Promise.all(
@@ -28,8 +29,9 @@ export async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime):
try {
const spec = await getFormSpecification(clients.ekbClient, corpId, specId);
if (spec) specifications[specId] = spec;
} catch {
// Ignore specification fetch failure in offline or restricted environments
else evidenceErrors.push({ source: `specification:${specId}`, message: "未返回表单规格" });
} catch (error) {
evidenceErrors.push({ source: `specification:${specId}`, message: error instanceof Error ? error.message : String(error) });
}
})
);
@@ -38,8 +40,8 @@ export async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime):
try {
const available = await getWorkflowAvailableNodes(client);
availableNodeTypes = available.allTypes;
} catch {
// 离线或受限网络环境下忽略探针失败
} catch (error) {
evidenceErrors.push({ source: "availableNodeTypes", message: error instanceof Error ? error.message : String(error) });
}
let openedPowerCodes: Set<string> | undefined;
@@ -60,22 +62,22 @@ export async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime):
}
}
openedPowerCodes = codes;
} catch {
// 离线或无商店应用查询权限时忽略
} catch (error) {
evidenceErrors.push({ source: "openedPowerCodes", message: error instanceof Error ? error.message : String(error) });
}
const result = analyzeWorkflow(detail, { specifications, availableNodeTypes, openedPowerCodes });
const failOnAlert = booleanOption(parsed.options, ["fail", "fail-on-alert", "failOnAlert"]);
const exitCode = failOnAlert && !result.summary.passed ? 2 : 0;
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode };
if (runtime.jsonMode) return { stdout: printJson({ ...result, evidenceComplete: evidenceErrors.length === 0, evidenceErrors }, runtime.outputOptions), stderr: "", exitCode };
const gateDecision =
result.summary.hardBlocks > 0
? `❌ 发现 ${result.summary.hardBlocks} 项硬门禁阻断 (禁止发布上线)`
: result.summary.softAdvices > 0
? `⚠️ 硬门禁全通过,存在 ${result.summary.softAdvices} 项优化建议`
: "✅ 全部门禁通过,可安全发布上线";
: "✅ 已执行的静态检查未发现阻断项";
const diagnosticRows = result.diagnostics.map((item) => [
item.category === "hard_block" ? "⛔ 硬门禁" : "💡 软建议",
@@ -100,6 +102,7 @@ export async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime):
}),
`\n依赖引用:\n${dependencyRows.length ? printTable(["节点路径", "类型", "引用"], dependencyRows) : "暂无代码引用"}`,
`\n诊断列表 (硬门禁 ⛔ / 软建议 💡):\n${diagnosticRows.length ? printTable(["分类", "级别", "代码", "节点路径", "说明"], diagnosticRows) : "未发现明显配置问题"}`,
...(evidenceErrors.length ? [`\n⚠️ 分析证据不完整:${evidenceErrors.map((item) => `${item.source}: ${item.message}`).join(";")}`] : []),
"",
].join("\n"),
stderr: "",