shepherdjay / ipfromwebpage

Simple script that scrapes a web page for IP addresses and prints aggregate result.
MIT License
2 stars 6 forks source link

Valid Separators #14

Closed shepherdjay closed 6 years ago

shepherdjay commented 7 years ago

As I was expanding tests to include new ipv6 functionality an error came up in testing. See the ipv6tests branch here:

ipv6tests branch in shepherdjay/ipfromwebpage

Specifically, the regex doesn't validate any data separators. That means that a mib shows up as an IPv4 address, and Letters/Numbers followed by a :: are passed to the ipv6 constructor

shepherdjay commented 7 years ago

For IPv4 some initial expected separators would be single line items, commas, spaces For IPv6 single line, commas

garrett-phoonswadi commented 7 years ago

I would be happy to give this a shot

garrett-phoonswadi commented 7 years ago

well i don't have write access to put up a PR but this is the regex i came up with ([0-9a-fA-f]{4}:)([0-9a-fA-f]{4}::/)([0-9]{2})

shepherdjay commented 7 years ago

Hey @gphoon as referenced in PR #16 that regex doesn't quite work for all ipv6 addresses. I think the existing regex is mostly okay except that we need to enforce some valid separators. For example in the existing regex:

IS31:: the 31:: is pulled out as an IPv6 address.

Similiarly the current IPv4 regex pulls 3 separate ip addresses from the following MIB:1.3.6.1.4.1.9.9.187.1.1.1.1.3

garrett-phoonswadi commented 7 years ago

interesting i tested with all the ips from the website it referenced ipv4 and ipv6 it didn't mark any of the ipv4 as vaild. I'll take a look when i get home from work.