Skip to content

Commit

Permalink
Add temporary workaround for Bun runtime DNS lookup issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Jul 13, 2024
1 parent 332d53c commit 0ed70d8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runtime/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit 0ed70d8

Please sign in to comment.