
























@@ -34,6 +34,12 @@ function setMockFetch(
3434return fetchSpy;
3535}
363637+function expectRawFetchSuccessDetails(details: unknown) {
38+const typedDetails = details as { status?: number; extractor?: string };
39+expect(typedDetails.status).toBe(200);
40+expect(typedDetails.extractor).toBe("raw");
41+}
42+3743function createWebFetchToolForTest(params?: {
3844firecrawlApiKey?: string;
3945useTrustedEnvProxy?: boolean;
@@ -153,10 +159,7 @@ describe("web_fetch SSRF protection", () => {
153159const tool = createWebFetchToolForTest();
154160155161const result = await tool?.execute?.("call", { url: "https://example.com" });
156-expect(result?.details).toMatchObject({
157-status: 200,
158-extractor: "raw",
159-});
162+expectRawFetchSuccessDetails(result?.details);
160163});
161164162165it("allows RFC2544 benchmark-range URLs only when web_fetch ssrfPolicy opts in", async () => {
@@ -173,10 +176,7 @@ describe("web_fetch SSRF protection", () => {
173176});
174177175178const allowed = await allowedTool?.execute?.("call", { url });
176-expect(allowed?.details).toMatchObject({
177-status: 200,
178-extractor: "raw",
179-});
179+expectRawFetchSuccessDetails(allowed?.details);
180180expect(fetchSpy).toHaveBeenCalledTimes(1);
181181const stricterTool = createWebFetchToolForTest({ cacheTtlMinutes: 1 });
182182await expectBlockedUrl(stricterTool, url, /private|internal|blocked/i);
@@ -196,10 +196,7 @@ describe("web_fetch SSRF protection", () => {
196196});
197197198198const allowed = await allowedTool?.execute?.("call", { url });
199-expect(allowed?.details).toMatchObject({
200-status: 200,
201-extractor: "raw",
202-});
199+expectRawFetchSuccessDetails(allowed?.details);
203200expect(fetchSpy).toHaveBeenCalledTimes(1);
204201205202const stricterTool = createWebFetchToolForTest({ cacheTtlMinutes: 1 });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。