def is_url_malicious(subject): # pragma: no cover """ Checks if the given URL is malicious. :param str subject: The subject to work with. :rtype: bool """ if subject: return core.API(subject).reputation("url") == "MALICIOUS" return None
def is_url(subject): # pragma: no cover """ Check if the given subject is a syntactically valid URL. :param subject: The subject to check the syntax from. :type subject: str|list :return: The syntax validity. :rtype: bool|dict """ if subject: # The given subject is not empty nor None. # We return the validity of the given subject. return core.API(subject).url_syntax() # We return None, there is nothing to check. return None
def is_ipv6(subject): # pragma: no cover """ Checks if the given subject is syntactivally valid IPv6. :param subject: The subject to check the syntax from. :type subject: str, list :return: The syntax validity. :rtype: bool|dict """ if subject: # The given subject is not empty not None. # We return the validity of the given subject. return core.API(subject).ipv6_syntax() # We return None, there is nothing to check. return None
def is_ip_range(subject): # pragma: no cover """ Check if the given subject is a syntactically valid IPv4 or IPv6 range. :param subject: The subject to check the syntax from. :type subject: str|list :return: The IPv4 range state. :rtype: bool|dict """ if subject: # The given subject is not empty nor None. # We return the validity of the given subject. return core.API(subject).ip_range_syntax() # We return None, there is nothing to check. return None
def url_test(subject, complete=False, config=None): # pragma: no covere """ Test the availability of the given subject (URL). :param subject: The subject (URL) to test. :type subject: str|list :param bool complete: Activate the return of a dict with some significant data from the test. :param dict config: A dict with the configuration index (from .PyFunceble.yaml) to update. :return: The status or the informations of the URL. :rtype: str|dict .. note:: If :code:`config` is given, the given :code:`dict` overwrite the last value of the given indexes in the configuration. It's actually something like following: :: pyfunceble.configuration.update(config_given_by_user) .. note:: If :code:`complete` is set to :code:`True`, we return the following indexes. :: { "_status_source": None, "_status": None, "dns_lookup": [], "domain_syntax_validation": None, "expiration_date": None, "http_status_code": None, "ipv4_range_syntax_validation": None, "ipv4_syntax_validation": None, "ipv6_range_syntax_validation": None, "ipv6_syntax_validation": None, "status": None, "status_source": None, "subdomain_syntax_validation": None, "tested": None, "url_syntax_validation": None, "whois_record": None, "whois_server": None, } """ if subject: # The given URL is not empty nor None. # We retunr the status of the the url. return core.API(subject, complete=complete, configuration=config).url() # We return None, there is nothing to test. return None