Skip to content

ipv6 check on number of octets missing #152

Closed

Description

@devikasondhi

Hello,

The ipv6 validator returns false positive for incorrect number of octets in the ipv6 address. The following are invalid ipv6 while the function returns True:
00:00:00:00:00
1111:2222:3333:4444:5555:6666:7777
1111:2222:3333:4444:1.2.3.4 (this should have contained compressed octet to return a True)

Activity

  1. devikasondhi commented on Apr 11, 2020

    @devikasondhi
    Author

    Hello,

    This is a secondary check that you could add for cases having spaces (or other invalid characters):
    For instance, 2001:0000:1234: 0000:0000:C1C0:ABCD:0876 should be flagged as invalid due to a space character after the third octet.

  2. devikasondhi commented on Apr 11, 2020

    @devikasondhi
    Author
  3. GregIthaca commented on Aug 13, 2020

    @GregIthaca

    Also, at present MAC addresses are accepted as valid IPv6 addresses, which they are not.

    >>> validators.ip_address.ipv6('01:23:45:67:89:ab')
    True
    >>> validators.mac_address('01:23:45:67:89:ab')
    True

  4. kvesteri commented on Aug 17, 2020

    @kvesteri
    Collaborator

    PRs welcome

  5. hpfousac commented on Feb 22, 2022

    @hpfousac

    The issue is still there:

    root@node-api-f87467dcd-xbjc8:/# pip freeze | grep validators
    validators==0.18.2
    root@node-api-f87467dcd-xbjc8:/# python3
    Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
    [GCC 10.2.1 20210110] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import validators
    >>> 
    >>> validators.ip_address.ipv6 ("2001:1:40F")
    True
    >>> validators.ip_address.ipv6 ("2001:1:40Z")
    ValidationFailure(func=ipv6, args={'value': '2001:1:40Z'})
    >>> 
    

    Actually I'm using following construction to detect if IP address has correct format:

    import ipaddress # https://docs.python.org/3/library/ipaddress.html#module-ipaddress
    
    def IsIpv4 (str):
           try:
                   if 32 == ipaddress.ip_address (str).max_prefixlen:
                           return True
                   else:
                           return False
           except:
                   return False
     
    def IsIpv6 (str):
           try:
                   if 128 == ipaddress.ip_address(str).max_prefixlen:
                           return True
                   else:
                           return False
           except:
                   return False
     
     def IsIpAddr (str):
            return IsIpv4 (str) or IsIpv6 (str)
    
  6. added
    bugIssue: Works not as designed
    outdatedIssue/PR: Open for more than 3 months
    maintenancePR: Alters existing source code
    on Mar 10, 2023
  7. added 5 commits that reference this issue on Mar 10, 2023
    39771fc
    84e5f39
    83bf2c2
    267c507
    e4f3adf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue: Works not as designedmaintenancePR: Alters existing source codeoutdatedIssue/PR: Open for more than 3 months

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions