























@@ -3,6 +3,19 @@ import type { ChannelPlugin } from "../channels/plugins/types.js";
33import type { OpenClawConfig } from "../config/config.js";
44import { collectChannelSecurityFindings } from "./audit-channel.js";
556+type ChannelSecurityFinding = Awaited<ReturnType<typeof collectChannelSecurityFindings>>[number];
7+8+function requireFinding(
9+findings: ChannelSecurityFinding[],
10+checkId: string,
11+): ChannelSecurityFinding {
12+const finding = findings.find((entry) => entry.checkId === checkId);
13+if (!finding) {
14+throw new Error(`Expected finding ${checkId}`);
15+}
16+return finding;
17+}
18+619describe("security audit channel dm policy", () => {
720it("warns when multiple DM senders share the main session", async () => {
821const cfg: OpenClawConfig = {
@@ -44,14 +57,13 @@ describe("security audit channel dm policy", () => {
4457 plugins,
4558});
465947-expect(findings).toEqual(
48-expect.arrayContaining([
49-expect.objectContaining({
50-checkId: "channels.whatsapp.dm.scope_main_multiuser",
51-severity: "warn",
52-remediation: expect.stringContaining('config set session.dmScope "per-channel-peer"'),
53-}),
54-]),
60+const sharedScopeFinding = requireFinding(
61+findings,
62+"channels.whatsapp.dm.scope_main_multiuser",
63+);
64+expect(sharedScopeFinding.severity).toBe("warn");
65+expect(sharedScopeFinding.remediation).toContain(
66+'config set session.dmScope "per-channel-peer"',
5567);
5668});
5769@@ -95,17 +107,13 @@ describe("security audit channel dm policy", () => {
95107 plugins,
96108});
9710998-expect(findings).toEqual(
99-expect.arrayContaining([
100-expect.objectContaining({
101-checkId: "channels.telegram.dm.open",
102-severity: "critical",
103-}),
104-expect.objectContaining({
105-checkId: "channels.telegram.dm.scope_main_multiuser",
106-severity: "warn",
107-}),
108-]),
110+const openDmFinding = requireFinding(findings, "channels.telegram.dm.open");
111+expect(openDmFinding.severity).toBe("critical");
112+113+const sharedScopeFinding = requireFinding(
114+findings,
115+"channels.telegram.dm.scope_main_multiuser",
109116);
117+expect(sharedScopeFinding.severity).toBe("warn");
110118});
111119});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。