msticpy/sectools/tiproviders/ti_provider_base.py
def preprocess_observable(
    observable, ioc_type, require_url_encoding: bool = False
) -> SanitizedObservable:
    """
    Preprocesses and checks validity of observable against declared IoC type.

        :param observable: the value of the IoC
        :param ioc_type: the IoC type
    """
    observable = observable.strip()
    try:
        validated = _IOC_EXTRACT.validate(observable, ioc_type)
    except KeyError:
        validated = False
    if not validated:
        return SanitizedObservable(
            None, "Observable does not match expected pattern for " + ioc_type
        )
    if ioc_type == "url":
        return _preprocess_url(observable, require_url_encoding)
    if ioc_type == "ipv4":
        return _preprocess_ip(observable, version=4)
    if ioc_type == "ipv6":
        return _preprocess_ip(observable, version=6)
    if ioc_type in ["dns", "hostname"]:
        return _preprocess_dns(observable)
    if ioc_type in ["md5_hash", "sha1_hash", "sha256_hash", "file_hash"]:
        return _preprocess_hash(observable)
    return SanitizedObservable(observable, "ok")

    Preprocesses and checks validity of observable against declared IoC type.

        :param observable: the value of the IoC
        :param ioc_type: the IoC type
    
Preprocesses and checks validity of observable against declared IoC type.
:param observable: the value of the IoC
:param ioc_type: the IoC type
Preprocesses and checks validity of observable against declared IoC type . : param observable : the value of the IoC : param ioc_type : the IoC type
def preprocess_observable(
    observable, ioc_type, require_url_encoding: bool = False
) -> SanitizedObservable:
    observable = observable.strip()
    try:
        validated = _IOC_EXTRACT.validate(observable, ioc_type)
    except KeyError:
        validated = False
    if not validated:
        return SanitizedObservable(
            None, "Observable does not match expected pattern for " + ioc_type
        )
    if ioc_type == "url":
        return _preprocess_url(observable, require_url_encoding)
    if ioc_type == "ipv4":
        return _preprocess_ip(observable, version=4)
    if ioc_type == "ipv6":
        return _preprocess_ip(observable, version=6)
    if ioc_type in ["dns", "hostname"]:
        return _preprocess_dns(observable)
    if ioc_type in ["md5_hash", "sha1_hash", "sha256_hash", "file_hash"]:
        return _preprocess_hash(observable)
    return SanitizedObservable(observable, "ok")
def preprocess_observable ( observable , ioc_type , require_url_encoding : bool = False ) -> SanitizedObservable : observable = observable . strip ( ) try : validated = _IOC_EXTRACT . validate ( observable , ioc_type ) except KeyError : validated = False if not validated : return SanitizedObservable ( None , "Observable does not match expected pattern for " + ioc_type ) if ioc_type == "url" : return _preprocess_url ( observable , require_url_encoding ) if ioc_type == "ipv4" : return _preprocess_ip ( observable , version = 4 ) if ioc_type == "ipv6" : return _preprocess_ip ( observable , version = 6 ) if ioc_type in [ "dns" , "hostname" ] : return _preprocess_dns ( observable ) if ioc_type in [ "md5_hash" , "sha1_hash" , "sha256_hash" , "file_hash" ] : return _preprocess_hash ( observable ) return SanitizedObservable ( observable , "ok" )
Preprocesses and checks validity of observable against declared IoC type.
Preprocesses and checks validity of observable against declared IoC type .
"""
    Preprocesses and checks validity of observable against declared IoC type.

        :param observable: the value of the IoC
        :param ioc_type: the IoC type
    """
observable
ioc_type
require_url_encoding
bool