惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
A
About on SuperTechFans
量子位
Engineering at Meta
Engineering at Meta
B
Blog
The Cloudflare Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
J
Java Code Geeks
D
DataBreaches.Net
aimingoo的专栏
aimingoo的专栏
T
Tailwind CSS Blog
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
酷 壳 – CoolShell
酷 壳 – CoolShell

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
Fix Mattermost open DM validation · openclaw/openclaw@ba9...
amknight · 2026-06-17 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -63,6 +63,7 @@ import { collectRuntimeConfigAssignments, secretTargetRegistryEntries } from "./

6363

import { resolveMattermostOutboundSessionRoute } from "./session-route.js";

6464

import { mattermostSetupAdapter } from "./setup-core.js";

6565

import { mattermostSetupWizard } from "./setup-surface.js";

66+

import { collectMattermostStatusIssues } from "./status-issues.js";

6667

import type { MattermostConfig } from "./types.js";

6768
6869

const loadMattermostChannelRuntime = createLazyRuntimeModule(() => import("./channel.runtime.js"));

@@ -834,6 +835,7 @@ export const mattermostPlugin: ChannelPlugin<ResolvedMattermostAccount> = create

834835

lastConnectedAt: null,

835836

lastDisconnect: null,

836837

}),

838+

collectStatusIssues: collectMattermostStatusIssues,

837839

buildChannelSummary: ({ snapshot }) =>

838840

buildPassiveProbedChannelStatusSummary(snapshot, {

839841

botTokenSource: snapshot.botTokenSource ?? "none",

@@ -858,6 +860,8 @@ export const mattermostPlugin: ChannelPlugin<ResolvedMattermostAccount> = create

858860

extra: {

859861

botTokenSource: account.botTokenSource,

860862

baseUrl: account.baseUrl,

863+

dmPolicy: account.config.dmPolicy ?? "pairing",

864+

allowFrom: account.config.allowFrom ?? [],

861865

connected: runtime?.connected ?? false,

862866

lastConnectedAt: runtime?.lastConnectedAt ?? null,

863867

lastDisconnect: runtime?.lastDisconnect ?? null,

Original file line numberDiff line numberDiff line change

@@ -30,6 +30,21 @@ describe("MattermostConfigSchema", () => {

3030

expect(result.success).toBe(true);

3131

});

3232
33+

it('rejects dmPolicy="open" without wildcard allowFrom', () => {

34+

const result = MattermostConfigSchema.safeParse({

35+

dmPolicy: "open",

36+

});

37+

expect(result.success).toBe(false);

38+

});

39+
40+

it('accepts dmPolicy="open" with wildcard allowFrom', () => {

41+

const result = MattermostConfigSchema.safeParse({

42+

dmPolicy: "open",

43+

allowFrom: ["*"],

44+

});

45+

expect(result.success).toBe(true);

46+

});

47+
3348

it("accepts documented streaming modes and progress config", () => {

3449

const result = MattermostConfigSchema.safeParse({

3550

streaming: {

Original file line numberDiff line numberDiff line change

@@ -11,13 +11,15 @@ vi.mock("./runtime-api.js", () => ({

1111
1212

describe("mattermost monitor auth", () => {

1313

let authorizeMattermostCommandInvocation: typeof import("./monitor-auth.js").authorizeMattermostCommandInvocation;

14+

let formatMattermostDirectMessageDropLog: typeof import("./monitor-auth.js").formatMattermostDirectMessageDropLog;

1415

let isMattermostSenderAllowed: typeof import("./monitor-auth.js").isMattermostSenderAllowed;

1516

let normalizeMattermostAllowEntry: typeof import("./monitor-auth.js").normalizeMattermostAllowEntry;

1617

let normalizeMattermostAllowList: typeof import("./monitor-auth.js").normalizeMattermostAllowList;

1718
1819

beforeAll(async () => {

1920

({

2021

authorizeMattermostCommandInvocation,

22+

formatMattermostDirectMessageDropLog,

2123

isMattermostSenderAllowed,

2224

normalizeMattermostAllowEntry,

2325

normalizeMattermostAllowList,

@@ -58,6 +60,18 @@ describe("mattermost monitor auth", () => {

5860

});

5961

});

6062
63+

it("formats direct-message drops with the ingress reason and open-policy hint", () => {

64+

expect(

65+

formatMattermostDirectMessageDropLog({

66+

senderId: "alice-id",

67+

dmPolicy: "open",

68+

reasonCode: "dm_policy_not_allowlisted",

69+

}),

70+

).toBe(

71+

"mattermost: drop dm sender=alice-id (dmPolicy=open reason=dm_policy_not_allowlisted hint=add-allowFrom-wildcard)",

72+

);

73+

});

74+
6175

it("resolves direct command authorization from shared ingress", async () => {

6276

isDangerousNameMatchingEnabled.mockReturnValue(false);

6377

resolveAllowlistMatchSimple.mockReturnValue({ allowed: false });

Original file line numberDiff line numberDiff line change

@@ -61,6 +61,19 @@ export function normalizeMattermostAllowList(entries: Array<string | number>): s

6161

return uniqueStrings(normalized);

6262

}

6363
64+

export function formatMattermostDirectMessageDropLog(params: {

65+

senderId: string;

66+

dmPolicy: string;

67+

reasonCode?: string;

68+

}): string {

69+

const reason = params.reasonCode ? ` reason=${params.reasonCode}` : "";

70+

const hint =

71+

params.dmPolicy === "open" && params.reasonCode === "dm_policy_not_allowlisted"

72+

? " hint=add-allowFrom-wildcard"

73+

: "";

74+

return `mattermost: drop dm sender=${params.senderId} (dmPolicy=${params.dmPolicy}${reason}${hint})`;

75+

}

76+
6477

export function isMattermostSenderAllowed(params: {

6578

senderId: string;

6679

senderName?: string;

Original file line numberDiff line numberDiff line change

@@ -57,6 +57,7 @@ import {

5757

} from "./model-picker.js";

5858

import {

5959

authorizeMattermostCommandInvocation,

60+

formatMattermostDirectMessageDropLog,

6061

normalizeMattermostAllowEntry,

6162

resolveMattermostMonitorInboundAccess,

6263

} from "./monitor-auth.js";

@@ -1391,7 +1392,13 @@ export async function monitorMattermostProvider(opts: MonitorMattermostOpts = {}

13911392

}

13921393

return;

13931394

}

1394-

logVerboseMessage(`mattermost: drop dm sender=${senderId} (dmPolicy=${dmPolicy})`);

1395+

logVerboseMessage(

1396+

formatMattermostDirectMessageDropLog({

1397+

senderId,

1398+

dmPolicy,

1399+

reasonCode: accessDecision.senderAccess.reasonCode,

1400+

}),

1401+

);

13951402

return;

13961403

}

13971404

if (accessDecision.ingress.reasonCode === "group_policy_disabled") {

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,32 @@

1+

// Mattermost tests cover status issues plugin behavior.

2+

import { expectOpenDmPolicyConfigIssue } from "openclaw/plugin-sdk/channel-test-helpers";

3+

import { describe, expect, it } from "vitest";

4+

import { collectMattermostStatusIssues } from "./status-issues.js";

5+
6+

describe("collectMattermostStatusIssues", () => {

7+

it("warns when dmPolicy is open without a wildcard allowlist", () => {

8+

expectOpenDmPolicyConfigIssue({

9+

collectIssues: collectMattermostStatusIssues,

10+

account: {

11+

accountId: "default",

12+

enabled: true,

13+

configured: true,

14+

dmPolicy: "open",

15+

},

16+

});

17+

});

18+
19+

it("allows open dmPolicy when allowFrom includes the wildcard", () => {

20+

expect(

21+

collectMattermostStatusIssues([

22+

{

23+

accountId: "default",

24+

enabled: true,

25+

configured: true,

26+

dmPolicy: "open",

27+

allowFrom: ["*"],

28+

},

29+

]),

30+

).toEqual([]);

31+

});

32+

});

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,51 @@

1+

// Mattermost plugin module implements status issue collection.

2+

import type {

3+

ChannelAccountSnapshot,

4+

ChannelStatusIssue,

5+

} from "openclaw/plugin-sdk/channel-contract";

6+

import {

7+

coerceStatusIssueAccountId,

8+

readStatusIssueFields,

9+

} from "openclaw/plugin-sdk/extension-shared";

10+
11+

const MATTERMOST_STATUS_FIELDS = [

12+

"accountId",

13+

"enabled",

14+

"configured",

15+

"dmPolicy",

16+

"allowFrom",

17+

] as const;

18+
19+

function hasWildcardAllowFrom(value: unknown): boolean {

20+

return Array.isArray(value) && value.some((entry) => String(entry).trim() === "*");

21+

}

22+
23+

export function collectMattermostStatusIssues(

24+

accounts: ChannelAccountSnapshot[],

25+

): ChannelStatusIssue[] {

26+

const issues: ChannelStatusIssue[] = [];

27+

for (const entry of accounts) {

28+

const account = readStatusIssueFields(entry, MATTERMOST_STATUS_FIELDS);

29+

if (!account) {

30+

continue;

31+

}

32+

const accountId = coerceStatusIssueAccountId(account.accountId) ?? "default";

33+

const enabled = account.enabled !== false;

34+

const configured = account.configured === true;

35+

if (!enabled || !configured) {

36+

continue;

37+

}

38+
39+

if (account.dmPolicy === "open" && !hasWildcardAllowFrom(account.allowFrom)) {

40+

issues.push({

41+

channel: "mattermost",

42+

accountId,

43+

kind: "config",

44+

message:

45+

'Mattermost dmPolicy is "open" but allowFrom does not include "*"; public DMs will be dropped.',

46+

fix: 'Add "*" to channels.mattermost.allowFrom (or the account-specific allowFrom) or set dmPolicy to "pairing"/"allowlist".',

47+

});

48+

}

49+

}

50+

return issues;

51+

}

Original file line numberDiff line numberDiff line change

@@ -284,6 +284,60 @@ describe("validateConfigObjectWithPlugins channel metadata (applyDefaults: true)

284284

expect(result.config.channels?.discord?.accounts?.work?.agentComponents?.ttlMs).toBe(60_000);

285285

}

286286

});

287+
288+

it('rejects Mattermost dmPolicy="open" without wildcard allowFrom', () => {

289+

const result = validateConfigObjectWithPlugins({

290+

channels: {

291+

mattermost: {

292+

enabled: true,

293+

baseUrl: "https://chat.example.com",

294+

botToken: "test-token",

295+

dmPolicy: "open",

296+

},

297+

},

298+

});

299+
300+

expect(result.ok).toBe(false);

301+

if (!result.ok) {

302+

expect(result.issues).toContainEqual(

303+

expect.objectContaining({

304+

path: "channels.mattermost.allowFrom",

305+

message: expect.stringContaining(

306+

'channels.mattermost.dmPolicy="open" requires channels.mattermost.allowFrom to include "*"',

307+

),

308+

}),

309+

);

310+

}

311+

});

312+
313+

it('rejects account-scoped Mattermost dmPolicy="open" without wildcard allowFrom', () => {

314+

const result = validateConfigObjectWithPlugins({

315+

channels: {

316+

mattermost: {

317+

accounts: {

318+

work: {

319+

enabled: true,

320+

baseUrl: "https://chat.example.com",

321+

botToken: "test-token",

322+

dmPolicy: "open",

323+

},

324+

},

325+

},

326+

},

327+

});

328+
329+

expect(result.ok).toBe(false);

330+

if (!result.ok) {

331+

expect(result.issues).toContainEqual(

332+

expect.objectContaining({

333+

path: "channels.mattermost.accounts.work.allowFrom",

334+

message: expect.stringContaining(

335+

'channels.mattermost.accounts.work.dmPolicy="open" requires channels.mattermost.accounts.work.allowFrom to include "*"',

336+

),

337+

}),

338+

);

339+

}

340+

});

287341

});

288342
289343

describe("validateConfigObjectRawWithPlugins channel metadata", () => {

Original file line numberDiff line numberDiff line change

@@ -311,6 +311,56 @@ function collectAllowedValuesFromBundledChannelSchemaPath(

311311

function formatRawChannelConfigIssueMessage(message: string): string {

312312

return `invalid config: ${message}`;

313313

}

314+
315+

function hasWildcardAllowFrom(value: unknown): boolean {

316+

return Array.isArray(value) && value.some((entry) => String(entry).trim() === "*");

317+

}

318+
319+

function collectMattermostOpenDmAllowFromIssues(

320+

value: unknown,

321+

pathPrefix: string,

322+

): ConfigValidationIssue[] {

323+

if (!isRecord(value)) {

324+

return [];

325+

}

326+

const issues: ConfigValidationIssue[] = [];

327+

if (value.dmPolicy === "open" && !hasWildcardAllowFrom(value.allowFrom)) {

328+

issues.push({

329+

path: `${pathPrefix}.allowFrom`,

330+

message: formatRawChannelConfigIssueMessage(

331+

`${pathPrefix}.dmPolicy="open" requires ${pathPrefix}.allowFrom to include "*"`,

332+

),

333+

});

334+

}

335+

if (isRecord(value.accounts)) {

336+

for (const [accountId, accountConfig] of Object.entries(value.accounts)) {

337+

if (!isRecord(accountConfig)) {

338+

continue;

339+

}

340+

const accountPath = `${pathPrefix}.accounts.${accountId}`;

341+

if (accountConfig.dmPolicy === "open" && !hasWildcardAllowFrom(accountConfig.allowFrom)) {

342+

issues.push({

343+

path: `${accountPath}.allowFrom`,

344+

message: formatRawChannelConfigIssueMessage(

345+

`${accountPath}.dmPolicy="open" requires ${accountPath}.allowFrom to include "*"`,

346+

),

347+

});

348+

}

349+

}

350+

}

351+

return issues;

352+

}

353+
354+

function collectBundledChannelConfigDependencyIssues(

355+

channelId: string,

356+

value: unknown,

357+

): ConfigValidationIssue[] {

358+

if (channelId === "mattermost") {

359+

return collectMattermostOpenDmAllowFromIssues(value, "channels.mattermost");

360+

}

361+

return [];

362+

}

363+
314364

function collectRawBundledChannelConfigIssues(config: OpenClawConfig): ConfigValidationIssue[] {

315365

if (!config.channels || !isRecord(config.channels)) {

316366

return [];

@@ -320,6 +370,9 @@ function collectRawBundledChannelConfigIssues(config: OpenClawConfig): ConfigVal

320370

if (!Object.hasOwn(config.channels, channelId)) {

321371

continue;

322372

}

373+

issues.push(

374+

...collectBundledChannelConfigDependencyIssues(channelId, config.channels[channelId]),

375+

);

323376

const result = validateJsonSchemaValue({

324377

schema: schema as Record<string, unknown>,

325378

cacheKey: `raw-channel:${channelId}`,

@@ -1569,6 +1622,7 @@ function validateConfigObjectWithPluginsBase(

15691622

}

15701623

continue;

15711624

}

1625+

issues.push(...collectBundledChannelConfigDependencyIssues(trimmed, result.value));

15721626

replaceChannelConfig(trimmed, result.value);

15731627

}

15741628

}