Source code for PyFunceble.status.reputation.domain_and_ip

"""
The tool to check the availability or syntax of domains, IPv4, IPv6 or URL.

::


    ██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
    ██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
    ██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
    ██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
    ██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
    ╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the status interface for domains and IP reputation check.

Author:
    Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom

Special thanks:
    https://pyfunceble.github.io/special-thanks.html

Contributors:
    https://pyfunceble.github.io/contributors.html

Project link:
    https://github.com/funilrys/PyFunceble

Project documentation:
    https://pyfunceble.readthedocs.io/en/master/

Project homepage:
    https://pyfunceble.github.io/

License:
::


    MIT License

    Copyright (c) 2017, 2018, 2019, 2020 Nissar Chababy

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
"""

import PyFunceble

from ..gatherer_base import GathererBase


[docs]class DomainAndIp(GathererBase): """ Gather the reputation of the given domain or IP. """ # pylint: disable=no-member def __init__(self, subject, filename=None, whois_db=None, inactive_db=None): super().__init__( subject, filename=filename, whois_db=whois_db, inactive_db=inactive_db ) self.subject_type += "domain" self.__gather() def __gather(self): """ Process the gathering. """ self.status["_status_source"] = self.status.status_source = "REPUTATION" if self.status.domain_syntax_validation or self.status.ipv4_syntax_validation: if self.subject in PyFunceble.lookup.IPv4Reputation(): self.status[ "_status" ] = self.status.status = PyFunceble.STATUS.official.malicious else: self.status[ "_status" ] = self.status.status = PyFunceble.STATUS.official.sane else: self.status[ "_status" ] = self.status.status = PyFunceble.STATUS.official.sane PyFunceble.output.Generate( self.subject, self.subject_type, self.status.status, source=self.status.status_source, whois_server=self.status.whois_server, filename=self.filename, ip_validation=self.status.ipv4_syntax_validation or self.status.ipv6_syntax_validation, ).status_file() PyFunceble.LOGGER.debug(f"[{self.subject}] State:\n{self.status.get()}")