Skip to content

IP validation fails if ip4/ip6 host bits are set #9

@pasiorovuo

Description

@pasiorovuo

IP validation in spf-validator seems to be stricter than RFC 7208 warrants. Example:

from spf_validator import validator

>>> validator.validate_spf_string('v=spf1 ip4:10.10.10.0/24 ip6:fd00::0/8 -all')
[]
>>> validator.validate_spf_string('v=spf1 ip4:10.10.10.1/24 ip6:fd00::1/8 -all')
['The IP 10.10.10.1/24 is not valid.', 'The IP fd00::1/8 is not valid.']

The RFC instructs to compare the high-order bits, but does not seem to require the ip4/ip6 definition to be a canonical network base address.

A potential fix could be to set strict=False in ipaddress.ip_network() call in

ipaddress.ip_network(ip)
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions