mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 02:21:25 +00:00
chore: Fix types in tests 33/N.
This commit is contained in:
@@ -9,6 +9,8 @@ function redirectResponse(location: string): Response {
|
||||
}
|
||||
|
||||
describe("fetchWithSsrFGuard hardening", () => {
|
||||
type LookupFn = NonNullable<Parameters<typeof fetchWithSsrFGuard>[0]["lookupFn"]>;
|
||||
|
||||
it("blocks private IP literal URLs before fetch", async () => {
|
||||
const fetchImpl = vi.fn();
|
||||
await expect(
|
||||
@@ -21,7 +23,9 @@ describe("fetchWithSsrFGuard hardening", () => {
|
||||
});
|
||||
|
||||
it("blocks redirect chains that hop to private hosts", async () => {
|
||||
const lookupFn = vi.fn(async () => [{ address: "93.184.216.34", family: 4 }]);
|
||||
const lookupFn = vi.fn(async () => [
|
||||
{ address: "93.184.216.34", family: 4 },
|
||||
]) as unknown as LookupFn;
|
||||
const fetchImpl = vi.fn().mockResolvedValueOnce(redirectResponse("http://127.0.0.1:6379/"));
|
||||
|
||||
await expect(
|
||||
@@ -47,7 +51,9 @@ describe("fetchWithSsrFGuard hardening", () => {
|
||||
});
|
||||
|
||||
it("allows wildcard allowlisted hosts", async () => {
|
||||
const lookupFn = vi.fn(async () => [{ address: "93.184.216.34", family: 4 }]);
|
||||
const lookupFn = vi.fn(async () => [
|
||||
{ address: "93.184.216.34", family: 4 },
|
||||
]) as unknown as LookupFn;
|
||||
const fetchImpl = vi.fn(async () => new Response("ok", { status: 200 }));
|
||||
const result = await fetchWithSsrFGuard({
|
||||
url: "https://img.assets.example.com/pic.png",
|
||||
|
||||
Reference in New Issue
Block a user