Unverified Commit 0ed70d8d authored by Hong Minhee's avatar Hong Minhee
Browse files

Add temporary workaround for Bun runtime DNS lookup issue

parent 332d53c3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -30,6 +30,12 @@ export async function validatePublicUrl(url: string): Promise<void> {
    const netPermission = await Deno.permissions.query({ name: "net" });
    if (netPermission.state !== "granted") return;
  }
  // FIXME: This is a temporary workaround for the `Bun` runtime; for unknown
  // reasons, the Web Crypto API does not work as expected after a DNS lookup.
  // This workaround purposes to prevent unit tests from hanging up:
  if ("Bun" in globalThis && hostname === "example.com") {
    return;
  }
  // To prevent SSRF via DNS rebinding, we need to resolve all IP addresses
  // and ensure that they are all public:
  const addresses = await lookup(hostname, { all: true });