supabase / edge-runtime

A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services.
MIT License
674 stars 62 forks source link

feat: support setting network permissions via allowNet option #386

Closed 0x5457 closed 3 months ago

0x5457 commented 3 months ago

What kind of change does this PR introduce?

feature

What is the new behavior?

Allow network access. can specify an optional list of IP addresses or hostnames (optionally with ports) to provide an allow-list of allowed network addresses.

EdgeRuntime.userWorkers.create({
...
  allowNet: ["<IP/HOSTNAME>"]
...
})
Code2Life commented 3 months ago

this feature is very useful for fine-grained networking control👍

Codexiaoyi commented 3 months ago

also need this feature to me!

laktek commented 3 months ago

Can you explain the use cases where you need explicit network access? I guess this would be fine to add for self-hosting, but unlikely we'd provide an option to configure it in hosted environment.

0x5457 commented 3 months ago

yes, this is useful for self-hosting cases, especially when EdgeRuntime used standalone rather than with Supabase.

It could extends the EdgeRuntime use case, for example, when the user workers need to be NOT homogeneous, fetching some metadata from localhost is useful, and keep the other network access blocked to avoid security risk.

Another reason is Deno has this option, it would be great if EdgeRuntime could align with Deno https://docs.deno.com/runtime/manual/basics/permissions/#permissions-list

laktek commented 3 months ago

Yeah, LGTM too! Thanks @0x5457 for the contribution and @nyannyacha for adding tests.

(This won't be configurable via Supabase CLI or on hosted platform for now. We'll do a separate Changelog announcement when we enable it)

github-actions[bot] commented 3 months ago

:tada: This PR is included in version 1.56.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

krvajal commented 2 months ago

could be possible to add the a deny list as well?