VirusTotal / vt-py

The official Python 3 client library for VirusTotal
https://virustotal.github.io/vt-py/
Apache License 2.0
531 stars 121 forks source link

Use ipaddress module to validate IP address #149

Closed za closed 1 year ago

za commented 1 year ago

Hi there!

What do you think if we use ipaddress module to validate IP address instead of using regex? Example of regex usage: the example code.

$ python3

>>> import ipaddress
>>> ipaddress.ip_address("127.0.0.1")
IPv4Address('127.0.0.1')
>>> ipaddress.ip_address("127.0.0.10000")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/ipaddress.py", line 54, in ip_address
    raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 address')
ValueError: '127.0.0.10000' does not appear to be an IPv4 or IPv6 address
za commented 1 year ago

Hi @plusvic any comment? Maybe I could start by initiating a PR if the idea is accepted.

mgmacias95 commented 1 year ago

Hello @za,

Feel free to make a PR :). Reach out if you need any guidance.

za commented 1 year ago

Hi @mgmacias95 I have initiated the PR.

za commented 1 year ago

PR has been merged.