-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
The usage of ip_regex.v6().test(ip) on every invocation as well as this massive conditional (with the same regex re-used over and over, as opposed to defining as constants in-memory at top root level of file, cause major performance issues.
Lines 45 to 57 in 9d984ed
| return /^::$/.test(ip_addr) || | |
| /^::1$/.test(ip_addr) || | |
| /^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(ip_addr) || | |
| /^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(ip_addr) || | |
| /^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(ip_addr) || | |
| /^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) || | |
| /^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) || | |
| /^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) || | |
| /^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) || | |
| /^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(ip_addr) || | |
| /^f[c-d]([0-9a-fA-F]{2,2}):/i.test(ip_addr) || | |
| /^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(ip_addr) || | |
| /^ff([0-9a-fA-F]{2,2}):/i.test(ip_addr) |
Also see the PR we made at #27
In the interim, we've dropped private-ip usage completely because of this and instead we use localhost-url-regex
synack-cmoscoso
Metadata
Metadata
Assignees
Labels
No labels