msticpy/sectools/tiproviders/ti_provider_base.py
def _preprocess_ip(ipaddress: str, version=4):
    """Ensure Ip address is a valid public IPv4 address."""
    try:
        addr = ip_address(ipaddress)
    except ValueError:
        return SanitizedObservable(None, "IP address is invalid format")

    if version == 4 and not isinstance(addr, IPv4Address):
        return SanitizedObservable(None, "Not an IPv4 address")
    if version == 6 and not isinstance(addr, IPv6Address):
        return SanitizedObservable(None, "Not an IPv6 address")
    if addr.is_global:
        return SanitizedObservable(ipaddress, "ok")

    return SanitizedObservable(None, "IP address is not global")
Ensure Ip address is a valid public IPv4 address.
Ensure Ip address is a valid public IPv4 address.
Ensure Ip address is a valid public IPv4 address .
def _preprocess_ip(ipaddress: str, version=4):
    try:
        addr = ip_address(ipaddress)
    except ValueError:
        return SanitizedObservable(None, "IP address is invalid format")
    if version == 4 and not isinstance(addr, IPv4Address):
        return SanitizedObservable(None, "Not an IPv4 address")
    if version == 6 and not isinstance(addr, IPv6Address):
        return SanitizedObservable(None, "Not an IPv6 address")
    if addr.is_global:
        return SanitizedObservable(ipaddress, "ok")
    return SanitizedObservable(None, "IP address is not global")
def _preprocess_ip ( ipaddress : str , version = 4 ) : try : addr = ip_address ( ipaddress ) except ValueError : return SanitizedObservable ( None , "IP address is invalid format" ) if version == 4 and not isinstance ( addr , IPv4Address ) : return SanitizedObservable ( None , "Not an IPv4 address" ) if version == 6 and not isinstance ( addr , IPv6Address ) : return SanitizedObservable ( None , "Not an IPv6 address" ) if addr . is_global : return SanitizedObservable ( ipaddress , "ok" ) return SanitizedObservable ( None , "IP address is not global" )
Ensure Ip address is a valid public IPv4 address.
Ensure Ip address is a valid public IPv4 address .
"""Ensure Ip address is a valid public IPv4 address."""
ipaddress
str
version