How to use the passivetotal.common.exceptions.MISSING_FIELD function in passivetotal

To help you get started, we’ve selected a few passivetotal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github passivetotal / python_api / tests / test_actions.py View on Github external
def test_dynamic_dns(self):
        """Test various actions for dynamic DNS."""
        payload = {'query': 'passivetotal.org'}
        response = self.client.get_dynamic_dns_status(**payload)
        assert not (response['dynamicDns'])

        payload = {'query': 'passivetotal.org', 'status': 'false'}
        response = self.client.set_dynamic_dns_status(**payload)
        assert not (response['dynamicDns'])

        with pytest.raises(MISSING_FIELD) as excinfo:
            def missing_field():
                payload = {'query': 'passivetotal.org', 'no-status': 'false'}
                self.client.set_dynamic_dns_status(**payload)
            missing_field()
        assert 'field is required' in str(excinfo.value)
github passivetotal / python_api / tests / test_whois.py View on Github external
def test_whois_search_missing_field(self):
        """Test missing a field in a search."""
        with pytest.raises(MISSING_FIELD) as excinfo:
            def missing_field():
                payload = {'query': '18772064254', 'no-field': '_'}
                self.client.search_whois_by_field(**payload)
            missing_field()
        assert 'value is required' in str(excinfo.value)
github passivetotal / python_api / tests / test_actions.py View on Github external
def test_classification(self):
        """Test various actions for classifications."""
        payload = {'query': 'passivetotal.org'}
        response = self.client.get_classification_status(**payload)
        assert (response['classification']) == 'non-malicious'

        payload = {'query': 'passivetotal.org',
                   'classification': 'non-malicious'}
        response = self.client.set_classification_status(**payload)
        assert (response['classification']) == 'non-malicious'

        with pytest.raises(MISSING_FIELD) as excinfo:
            def missing_field():
                payload = {'query': 'passivetotal.org',
                           'no-classification': 'unknown'}
                self.client.set_classification_status(**payload)
            missing_field()
        assert 'field is required' in str(excinfo.value)

        with pytest.raises(INVALID_VALUE_TYPE) as excinfo:
            def invalid_field():
                payload = {'query': 'passivetotal.org', 'classification': '_'}
                self.client.set_classification_status(**payload)
            invalid_field()
        assert 'must be one of the following' in str(excinfo.value)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def set_classification_status(self, **kwargs):
        if 'classification' not in kwargs:
            raise MISSING_FIELD("Classification field is required.")
        if kwargs['classification'] not in CLASSIFICATION_VALID_VALUES:
            raise INVALID_VALUE_TYPE("Value must be one of the following: %s"
                                     % ', '.join(CLASSIFICATION_VALID_VALUES))
        data = {'classification': kwargs['classification'],
                'query': kwargs['query']}
        return self._send_data('POST', ACTIONS, ACTIONS_CLASSIFICATION, data)
github passivetotal / python_api / passivetotal / libs / whois.py View on Github external
def search_whois_by_field(self, **kwargs):
        """Search WHOIS details based on query value and field.

        Reference: https://api.passivetotal.org/api/docs/#api-WHOIS-GetV2WhoisSearchQueryField

        :param str query: Query value to use when making the request for data
        :param str compact_record: Return the record in a compact format
        :param str field: Field to run the query against
        :return: WHOIS records matching the query
        """
        if 'field' not in kwargs:
            raise MISSING_FIELD("Field value is required.")
        if kwargs['field'] not in WHOIS_VALID_FIELDS:
            raise INVALID_FIELD_TYPE("Field must be one of the following: %s"
                                     % ', '.join(WHOIS_VALID_FIELDS))
        return self._get('whois', 'search', **kwargs)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def set_sinkhole_status(self, **kwargs):
        if 'status' not in kwargs:
            raise MISSING_FIELD("Status field is required.")
        # if type(kwargs['status']) != bool:
        #     raise INVALID_VALUE_TYPE("Status must be type bool.")
        data = {'status': kwargs['status'], 'query': kwargs['query']}
        return self._send_data('POST', ACTIONS, ACTIONS_SINKHOLE, data)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def set_dynamic_dns_status(self, **kwargs):
        if 'status' not in kwargs:
            raise MISSING_FIELD("Status field is required.")
        # if type(kwargs['status']) != bool:
        #     raise INVALID_VALUE_TYPE("Status must be type bool.")
        data = {'status': kwargs['status'], 'query': kwargs['query']}
        return self._send_data('POST', ACTIONS, ACTIONS_DYNAMIC_DNS, data)
github passivetotal / python_api / passivetotal / libs / ssl.py View on Github external
def search_ssl_certificate_by_field(self, **kwargs):
        """Search SSL certificate details based on query value and field.

        Reference: https://api.passivetotal.org/api/docs/#api-SSL_Certificates-GetSslCertificateSearchQueryField

        :param str query: Query value to use when making the request for data
        :param str compact_record: Return the record in a compact format
        :param str field: Field to run the query against
        :param str type: Type of search to conduct
        :return: SSL certificates matching the query
        """
        if 'field' not in kwargs:
            raise MISSING_FIELD("Field value is required.")
        if kwargs['field'] not in SSL_VALID_FIELDS:
            raise INVALID_FIELD_TYPE("Field must be one of the following: %s"
                                     % ', '.join(SSL_VALID_FIELDS))
        return self._get('ssl-certificate', 'search', **kwargs)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def set_monitor_status(self, **kwargs):
        if 'status' not in kwargs:
            raise MISSING_FIELD("Status field is required.")
        # if type(kwargs['status']) != bool:
        #     raise INVALID_VALUE_TYPE("Status must be type bool.")
        data = {'status': kwargs['status'], 'query': kwargs['query']}
        return self._send_data('POST', ACTIONS, ACTIONS_MONITOR, data)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def set_ever_compromised_status(self, **kwargs):
        if 'status' not in kwargs:
            raise MISSING_FIELD("Status field is required.")
        # if type(kwargs['status']) != bool:
        #     raise INVALID_VALUE_TYPE("Status must be type bool.")
        data = {'status': kwargs['status'], 'query': kwargs['query']}
        return self._send_data('POST', ACTIONS, ACTIONS_EVER_COMPROMISED, data)