You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What are you trying to achieve or the steps to reproduce ?
When using Joi to validate ipv4 string and ipv6 string, there is a problem with cidr subnet mask : it cannot go over /32, witch is good for ipv4, but for ipv6 it can go up to /128.
Here is a little code to illustrate:
'use strict'constJoi=require('joi')constHapi=require('hapi')constserver=newHapi.Server();server.connection({host: 'localhost',port: 8000});server.route({method: 'GET',path:'/testIP/{ip*}',handler: function(request,reply){returnreply(`For Joi, ${request.params.ip} is a valid ip.`);},config: {validate: {params: {ip: Joi.string().ip({version: ['ipv4','ipV6'],cidr: 'optional'}).required()}}}});server.start((err)=>{if(err){throwerr;}console.log('Server running at:',server.info.uri);})
Context
What are you trying to achieve or the steps to reproduce ?
When using Joi to validate ipv4 string and ipv6 string, there is a problem with cidr subnet mask : it cannot go over /32, witch is good for ipv4, but for ipv6 it can go up to /128.
Here is a little code to illustrate:
Which result you had ?
http://localhost:8000/testIP/foo
-> 400, ok
http://localhost:8000/testIP/192.128.0.0.0
-> 400, ok
http://localhost:8000/testIP/192.128.0.0
-> 200, ok
http://localhost:8000/testIP/192.128.0.0/16
-> 200, ok
http://localhost:8000/testIP/192.128.0.0/32
-> 200, ok
http://localhost:8000/testIP/192.128.0.0/33
-> 400, ok
http://localhost:8000/testIP/ff:
-> 400, ok
http://localhost:8000/testIP/ff::
-> 200, ok
http://localhost:8000/testIP/ff::/22
-> 200, ok
http://localhost:8000/testIP/ff::/32
-> 200, ok
http://localhost:8000/testIP/ff::/33
-> 400, KO: should work !
http://localhost:8000/testIP/ff::/128
-> 400, KO: should work !
http://localhost:8000/testIP/ff::/64
-> 400, KO; should work !
http://localhost:8000/testIP/ff::/129
-> 400, ok
What did you expect ?
ipv6 must be allowed to have a mask up to /128.
The text was updated successfully, but these errors were encountered: