Skip to content

Commit 5550d0e

Browse files
authored
Merge branch 'main' into alix/telegram-diagnostic-response-read-timeouts
2 parents 08e6651 + eb91c59 commit 5550d0e

123 files changed

Lines changed: 1905 additions & 753 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
81.1 KB
Loading
228 KB
Loading
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
5cc5b1f35c16b3b65871942b262467b1eee065652f4f90a24ddd65eb1096aa3c plugin-sdk-api-baseline.json
2-
aaeb88388cf472b788ba2332890811d5bee64208a99596c975b2f11f7d40c04e plugin-sdk-api-baseline.jsonl
1+
38de898c2b05a0895c4863373aa7128f073128cc6ace8bd5004203c3ee9735fd plugin-sdk-api-baseline.json
2+
93ca4d93917be8be643293c2a11c58d2a7c138390c15f646991a223815ddec1e plugin-sdk-api-baseline.jsonl

‎extensions/clickclack/src/activity.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Tests for the durable ClickClack agent-activity publisher (coalescing rules).
22
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3-
import { createClickClackActivityPublisher, type ClickClackActivityClient } from "./activity.js";
3+
import { createClickClackActivityPublisher } from "./activity.js";
44
import type { ClickClackMessage } from "./types.js";
55

6+
type ActivityClient = Parameters<typeof createClickClackActivityPublisher>[0]["client"];
7+
68
function createClientMock(): {
7-
client: ClickClackActivityClient;
9+
client: ActivityClient;
810
createActivityMessage: ReturnType<typeof vi.fn>;
911
updateMessageBody: ReturnType<typeof vi.fn>;
1012
} {
@@ -15,7 +17,7 @@ function createClientMock(): {
1517
});
1618
const updateMessageBody = vi.fn(async () => ({}) as ClickClackMessage);
1719
return {
18-
client: { createActivityMessage, updateMessageBody } as ClickClackActivityClient,
20+
client: { createActivityMessage, updateMessageBody } as ActivityClient,
1921
createActivityMessage,
2022
updateMessageBody,
2123
};
@@ -253,7 +255,7 @@ describe("createClickClackActivityPublisher", () => {
253255
});
254256
const updateMessageBody = vi.fn(async () => ({}) as ClickClackMessage);
255257
const publisher = createClickClackActivityPublisher({
256-
client: { createActivityMessage, updateMessageBody } as ClickClackActivityClient,
258+
client: { createActivityMessage, updateMessageBody } as ActivityClient,
257259
target: { channelId: "chn_1" },
258260
turnId: "msg_turn",
259261
onError,

‎extensions/clickclack/src/activity.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type ClickClackActivityTarget = {
4242
};
4343

4444
/** Client subset needed by the publisher (satisfied by `createClickClackClient`). */
45-
export type ClickClackActivityClient = {
45+
type ClickClackActivityClient = {
4646
createActivityMessage(params: {
4747
channelId?: string;
4848
conversationId?: string;

‎extensions/googlechat/src/auth.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,3 @@ export const testing = {
208208
googleAuthRuntimeTesting.resetGoogleAuthRuntimeForTests();
209209
},
210210
};
211-
export { testing as __testing };

‎extensions/msteams/src/attachments/bot-framework.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { expectDefined } from "@openclaw/normalization-core";
33
import { beforeEach, describe, expect, it, vi } from "vitest";
44
import { setMSTeamsRuntime } from "../runtime.js";
55
import {
6-
downloadMSTeamsBotFrameworkAttachment,
76
downloadMSTeamsBotFrameworkAttachments,
87
isBotFrameworkPersonalChatId,
98
} from "./bot-framework.js";
@@ -23,6 +22,20 @@ type MockRuntime = {
2322
savedContentType: string;
2423
};
2524

25+
type DownloadSingleAttachmentParams = Omit<
26+
Parameters<typeof downloadMSTeamsBotFrameworkAttachments>[0],
27+
"attachmentIds"
28+
> & { attachmentId: string };
29+
30+
async function downloadMSTeamsBotFrameworkAttachment(params: DownloadSingleAttachmentParams) {
31+
const { attachmentId, ...rest } = params;
32+
const result = await downloadMSTeamsBotFrameworkAttachments({
33+
...rest,
34+
attachmentIds: [attachmentId],
35+
});
36+
return result.media[0];
37+
}
38+
2639
function installRuntime(): MockRuntime {
2740
const state: MockRuntime = {
2841
saveCalls: [],

‎extensions/msteams/src/attachments/bot-framework.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ async function saveBotFrameworkAttachmentView(params: {
218218
* path is not usable because the Bot Framework conversation ID (`a:...`) is
219219
* not a valid Graph chat identifier.
220220
*/
221-
export async function downloadMSTeamsBotFrameworkAttachment(params: {
221+
async function downloadMSTeamsBotFrameworkAttachment(params: {
222222
serviceUrl: string;
223223
attachmentId: string;
224224
tokenProvider?: MSTeamsAccessTokenProvider;

‎extensions/msteams/src/attachments/shared.test.ts‎

Lines changed: 23 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@ import {
55
encodeGraphShareId,
66
extractInlineImageCandidates,
77
isDownloadableAttachment,
8-
isGraphSharedLinkUrl,
98
isLikelyImageAttachment,
10-
isPrivateOrReservedIP,
119
isUrlAllowed,
1210
normalizeContentType,
13-
resolveAndValidateIP,
1411
resolveAttachmentFetchPolicy,
15-
resolveAllowedHosts,
16-
resolveAuthAllowedHosts,
1712
resolveMediaSsrfPolicy,
18-
safeFetch,
1913
safeFetchWithPolicy,
2014
tryBuildGraphSharesUrlForSharedLink,
2115
} from "./shared.js";
@@ -26,6 +20,29 @@ const failingResolve = async () => {
2620
throw new Error("DNS failure");
2721
};
2822

23+
const resolveAllowedHosts = (input?: string[]) =>
24+
resolveAttachmentFetchPolicy({ allowHosts: input }).allowHosts;
25+
const resolveAuthAllowedHosts = (input?: string[]) =>
26+
resolveAttachmentFetchPolicy({ authAllowHosts: input }).authAllowHosts;
27+
const isGraphSharedLinkUrl = (url: string) =>
28+
tryBuildGraphSharesUrlForSharedLink(url) !== undefined;
29+
30+
type SafeFetchParams = Omit<Parameters<typeof safeFetchWithPolicy>[0], "policy"> & {
31+
allowHosts: string[];
32+
authorizationAllowHosts?: string[];
33+
};
34+
35+
async function safeFetch(params: SafeFetchParams) {
36+
const { allowHosts, authorizationAllowHosts, ...request } = params;
37+
return await safeFetchWithPolicy({
38+
...request,
39+
policy: {
40+
allowHosts,
41+
authAllowHosts: authorizationAllowHosts ?? [],
42+
},
43+
});
44+
}
45+
2946
function mockFetchWithRedirect(redirectMap: Record<string, string>, finalBody = "ok") {
3047
return vi.fn(async (url: string, init?: RequestInit) => {
3148
const target = redirectMap[url];
@@ -112,56 +129,6 @@ describe("msteams attachment allowlists", () => {
112129
});
113130
expect(resolveMediaSsrfPolicy(["*"])).toBeUndefined();
114131
});
115-
116-
it.each([
117-
["999.999.999.999", true],
118-
["256.0.0.1", true],
119-
["10.0.0.256", true],
120-
["-1.0.0.1", false],
121-
["1.2.3.4.5", false],
122-
["0:0:0:0:0:0:0:1", true],
123-
] as const)("malformed/expanded %s → %s (SDK fails closed)", (ip, expected) => {
124-
expect(isPrivateOrReservedIP(ip)).toBe(expected);
125-
});
126-
});
127-
128-
// ─── resolveAndValidateIP ────────────────────────────────────────────────────
129-
130-
describe("resolveAndValidateIP", () => {
131-
it("accepts a hostname resolving to a public IP", async () => {
132-
const ip = await resolveAndValidateIP("teams.sharepoint.com", publicResolve);
133-
expect(ip).toBe("13.107.136.10");
134-
});
135-
136-
it("rejects a hostname resolving to 10.x.x.x", async () => {
137-
await expect(resolveAndValidateIP("evil.test", privateResolve("10.0.0.1"))).rejects.toThrow(
138-
"private/reserved IP",
139-
);
140-
});
141-
142-
it("rejects a hostname resolving to 169.254.169.254", async () => {
143-
await expect(
144-
resolveAndValidateIP("evil.test", privateResolve("169.254.169.254")),
145-
).rejects.toThrow("private/reserved IP");
146-
});
147-
148-
it("rejects a hostname resolving to loopback", async () => {
149-
await expect(resolveAndValidateIP("evil.test", privateResolve("127.0.0.1"))).rejects.toThrow(
150-
"private/reserved IP",
151-
);
152-
});
153-
154-
it("rejects a hostname resolving to IPv6 loopback", async () => {
155-
await expect(resolveAndValidateIP("evil.test", privateResolve("::1"))).rejects.toThrow(
156-
"private/reserved IP",
157-
);
158-
});
159-
160-
it("throws on DNS resolution failure", async () => {
161-
await expect(resolveAndValidateIP("nonexistent.test", failingResolve)).rejects.toThrow(
162-
"DNS resolution failed",
163-
);
164-
});
165132
});
166133

167134
// ─── safeFetch ───────────────────────────────────────────────────────────────

‎extensions/msteams/src/attachments/shared.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const GRAPH_SHARED_LINK_HOST_SUFFIXES = [
148148
* shared-link content must be fetched through the Graph shares API rather
149149
* than directly.
150150
*/
151-
export function isGraphSharedLinkUrl(url: string): boolean {
151+
function isGraphSharedLinkUrl(url: string): boolean {
152152
let host: string;
153153
try {
154154
host = normalizeLowercaseStringOrEmpty(new URL(url).hostname);
@@ -442,11 +442,11 @@ export function safeHostForUrl(url: string): string {
442442
}
443443
}
444444

445-
export function resolveAllowedHosts(input?: string[]): string[] {
445+
function resolveAllowedHosts(input?: string[]): string[] {
446446
return normalizeHostnameSuffixAllowlist(input, DEFAULT_MEDIA_HOST_ALLOWLIST);
447447
}
448448

449-
export function resolveAuthAllowedHosts(input?: string[]): string[] {
449+
function resolveAuthAllowedHosts(input?: string[]): string[] {
450450
return normalizeHostnameSuffixAllowlist(input, DEFAULT_MEDIA_AUTH_HOST_ALLOWLIST);
451451
}
452452

@@ -549,13 +549,13 @@ export function resolveMediaSsrfPolicy(allowHosts: string[]): SsrFPolicy | undef
549549
* expanded notation, NAT64, 6to4, Teredo, octal IPv4, and fails closed on
550550
* parse errors.
551551
*/
552-
export const isPrivateOrReservedIP: (ip: string) => boolean = isPrivateIpAddress;
552+
const isPrivateOrReservedIP: (ip: string) => boolean = isPrivateIpAddress;
553553

554554
/**
555555
* Resolve a hostname via DNS and reject private/reserved IPs.
556556
* Throws if the resolved IP is private or resolution fails.
557557
*/
558-
export async function resolveAndValidateIP(
558+
async function resolveAndValidateIP(
559559
hostname: string,
560560
resolveFn?: MSTeamsAttachmentResolveFn,
561561
): Promise<string> {
@@ -582,7 +582,7 @@ const MAX_SAFE_REDIRECTS = 5;
582582
* - Auto-following redirects to non-allowlisted hosts
583583
* - DNS rebinding attacks when a lookup function is provided
584584
*/
585-
export async function safeFetch(params: {
585+
async function safeFetch(params: {
586586
url: string;
587587
allowHosts: string[];
588588
/**

0 commit comments

Comments
 (0)