fix(workflow): intercept production debug on enabled workflows without force and document platform vulnerability

This commit is contained in:
gitea committed 2026-10-15 14:13:50 +08:00
1 parent 36a3c3b28d
commit 0b4519652b
3 files changed
+193 -1

No files matched your search

+133
View File
@@ -622,6 +622,18 @@ describe("CLI - workflow job 执行详情与异常精准透视", () => {
}),
};
}
if (url.includes("api/easo/pipelines/")) {
return {
json: async () => ({
code: 200,
data: {
id: "wf_test_1",
label: "测试工作流",
state: 0,
},
}),
};
}
return {
json: async () => ({
code: 200,
@@ -665,4 +677,125 @@ describe("CLI - workflow job 执行详情与异常精准透视", () => {
expect(res.stdout).toContain("ZJ-20261015-001387");
expect(res.stdout).toContain("control_1");
});
it("blocks workflow test when pipeline is enabled in production without --force", async () => {
const mockClient = {
get: (url: string) => {
if (url.includes("api/easo/pipelines/")) {
return {
json: async () => ({
code: 200,
data: {
id: "wf_prod_1",
label: "生产自动审批工作流",
state: 1, // 生产启用中
},
}),
};
}
return { json: async () => ({ code: 200, data: null }) };
},
post: () => ({ json: async () => ({ code: 200, data: null }) }),
};
spies.push(
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
ekbClient: mockClient as any,
easoClient: mockClient as any,
corp: mockCorp,
} as any)
);
spies.push(
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
);
const res = await handleWorkflowCommand(
{
area: "workflow",
action: "test",
args: ["wf_prod_1"],
options: { flow: "ZJ-20261015-001387", platformId: "p1" },
raw: ["workflow", "test", "wf_prod_1", "--flow=ZJ-20261015-001387", "--platform-id=p1"],
},
mockRuntime
);
expect(res.exitCode).toBe(1);
expect(res.stderr).toContain("安全防御拦截");
expect(res.stderr).toContain("生产启用中");
expect(res.stderr).toContain("--force");
});
it("allows workflow test when pipeline is enabled in production with --force", async () => {
const mockClient = {
get: (url: string) => {
if (url.includes("api/easo/pipelines/")) {
return {
json: async () => ({
code: 200,
data: {
id: "wf_prod_1",
label: "生产自动审批工作流",
state: 1,
},
}),
};
}
if (url.includes("execution")) {
return {
json: async () => ({
code: 200,
data: [
{
id: "e1",
name: "trigger_1",
label: "触发器",
type: "ekuaibao-flowform-trigger",
status: "COMPLETED",
},
],
}),
};
}
return {
json: async () => ({
code: 200,
data: {
id: "job_force_999",
pipelineId: "wf_prod_1",
status: "COMPLETED",
runType: "DEBUG",
},
}),
};
},
post: () => ({ json: async () => ({ code: 200, data: "job_force_999" }) }),
};
spies.push(
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
ekbClient: mockClient as any,
easoClient: mockClient as any,
corp: mockCorp,
} as any)
);
spies.push(
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
);
const res = await handleWorkflowCommand(
{
area: "workflow",
action: "test",
args: ["wf_prod_1"],
options: { flow: "ZJ-20261015-001387", force: true, platformId: "p1" },
raw: ["workflow", "test", "wf_prod_1", "--flow=ZJ-20261015-001387", "--force", "--platform-id=p1"],
},
mockRuntime
);
expect(res.exitCode).toBe(0);
expect(res.stdout).toContain("生产调试警示");
expect(res.stdout).toContain("job_force_999");
});
});