@@ -1417,6 +1417,8 @@ static void Query(const FunctionCallbackInfo<Value>& args) {
14171417 node::Utf8Value utf8name (env->isolate (), string);
14181418 auto plain_name = utf8name.ToStringView ();
14191419 std::string name = ada::idna::to_ascii (plain_name);
1420+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1421+ env, permission::PermissionScope::kNetDNS , name);
14201422 channel->ModifyActivityQueryCount (1 );
14211423 int err = wrap->Send (name.c_str ());
14221424 if (err) {
@@ -1429,7 +1431,6 @@ static void Query(const FunctionCallbackInfo<Value>& args) {
14291431 args.GetReturnValue ().Set (err);
14301432}
14311433
1432-
14331434void AfterGetAddrInfo (uv_getaddrinfo_t * req, int status, struct addrinfo * res) {
14341435 auto cleanup = OnScopeLeave ([&]() { uv_freeaddrinfo (res); });
14351436 BaseObjectPtr<GetAddrInfoReqWrap> req_wrap{
@@ -1568,15 +1569,15 @@ void CanonicalizeIP(const FunctionCallbackInfo<Value>& args) {
15681569
15691570void GetAddrInfo (const FunctionCallbackInfo<Value>& args) {
15701571 Environment* env = Environment::GetCurrent (args);
1571-
15721572 CHECK (args[0 ]->IsObject ());
15731573 CHECK (args[1 ]->IsString ());
15741574 CHECK (args[2 ]->IsInt32 ());
15751575 CHECK (args[4 ]->IsUint32 ());
15761576 Local<Object> req_wrap_obj = args[0 ].As <Object>();
15771577 node::Utf8Value hostname (env->isolate (), args[1 ]);
15781578 std::string ascii_hostname = ada::idna::to_ascii (hostname.ToStringView ());
1579-
1579+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1580+ env, permission::PermissionScope::kNetDNS , ascii_hostname);
15801581 int32_t flags = 0 ;
15811582 if (args[3 ]->IsInt32 ()) {
15821583 flags = args[3 ].As <Int32>()->Value ();
@@ -1639,7 +1640,9 @@ void GetNameInfo(const FunctionCallbackInfo<Value>& args) {
16391640 node::Utf8Value ip (env->isolate (), args[1 ]);
16401641 const unsigned port = args[2 ]->Uint32Value (env->context ()).FromJust ();
16411642 struct sockaddr_storage addr;
1642-
1643+ THROW_IF_INSUFFICIENT_PERMISSIONS (
1644+ env, permission::PermissionScope::kNetDNS ,
1645+ (*ip + std::string (" :" ) + std::to_string (port)));
16431646 CHECK (uv_ip4_addr (*ip, port, reinterpret_cast <sockaddr_in*>(&addr)) == 0 ||
16441647 uv_ip6_addr (*ip, port, reinterpret_cast <sockaddr_in6*>(&addr)) == 0 );
16451648
0 commit comments