How to use the passivetotal.response.Response 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_whois.py View on Github external
def test_process_whois_details(self):
        """Test processing WHOIS details."""
        payload = {'query': 'passivetotal.org'}
        response = self.client.get_whois_details(**payload)
        wrapped = Response(response)
        for item in self.formats:
            assert (getattr(wrapped, item))
github passivetotal / python_api / tests / test_whois.py View on Github external
def test_process_whois_search(self):
        """Test processing search results."""
        payload = {'query': '18772064254', 'field': 'phone'}
        response = self.client.search_whois_by_field(**payload)
        results = Response(response)
        assert (Response(results.results[0]).domain) == 'passivetotal.org'
github passivetotal / python_api / tests / test_enrichment.py View on Github external
def test_subdomains(self):
        """Test processing subdomains."""
        payload = {'query': '*.passivetotal.org'}
        response = self.client.get_subdomains(**payload)
        wrapped = Response(response)
        assert (wrapped.queryValue) == '*.passivetotal.org'
        assert ('www' in wrapped.subdomains)
github passivetotal / python_api / tests / test_dns.py View on Github external
def test_process_dns_passive(self):
        """Test processing passive DNS records."""
        payload = {'query': 'passivetotal.org'}
        response = self.client.get_passive_dns(**payload)
        wrapped = Response(response)
        assert (wrapped.queryValue) == 'passivetotal.org'
        assert (Response(wrapped.results.pop(0)).recordHash) == '6d24bc7754af023afeaaa05ac689ac36e96656aa6519ba435b301b14916b27d3'
github passivetotal / python_api / tests / test_ssl.py View on Github external
def test_property_load(self):
        """Test loading properties on a result."""
        payload = {'query': 'e9a6647d6aba52dc47b3838c920c9ee59bad7034'}
        response = self.client.get_ssl_certificate_details(**payload)
        wrapped = Response(response)

        for key, value in iteritems(response):
            assert (getattr(wrapped, key)) == value
github passivetotal / python_api / tests / test_enrichment.py View on Github external
def test_osint(self):
        """Test getting unique passive DNS records."""
        payload = {'query': 'xxxvideotube.org'}
        response = self.client.get_osint(**payload)
        wrapped = Response(response)
        assert (response['results'])
        record = wrapped.results.pop(0)
        record = Response(record)
        assert (record.source) == 'RiskIQ'
        assert (record.sourceUrl) == "https://www.riskiq.com/blog/riskiq-labs/post/a-brief-encounter-with-slempo"
github passivetotal / python_api / tests / test_ssl.py View on Github external
def test_process_ssl_certificate_search(self):
        """Test processing search results."""
        payload = {'query': 'www.passivetotal.org', 'field': 'subjectCommonName'}
        response = self.client.search_ssl_certificate_by_field(**payload)
        results = Response(response)
        assert (Response(results.results[0]).serialNumber) == '2317683628587350290823564500811277499'
github passivetotal / python_api / tests / test_whois.py View on Github external
def test_process_whois_search(self):
        """Test processing search results."""
        payload = {'query': '18772064254', 'field': 'phone'}
        response = self.client.search_whois_by_field(**payload)
        results = Response(response)
        assert (Response(results.results[0]).domain) == 'passivetotal.org'
github passivetotal / python_api / passivetotal / libs / attributes.py View on Github external
:return: Dict of results with component information
        """
        return self._get('host-attributes', 'pairs', **kwargs)

    def search_trackers(self, **kwargs):
        """Search tracking IDs for associated hosts.

        Reference: https://api.passivetotal.org/api/docs/#api-Host_Attributes-SearchTrackers

        :return: Dict of matching hosts using a tracking ID
        """
        return self._get('trackers', 'search', **kwargs)


class AttributeResponse(Response):
    @property
    def csv(self):
        data = []
        for record in self._results['results']:
            data.append([record.get(i) for i in approved_fields])
        return utilities.to_csv(approved_fields, data)
github passivetotal / python_api / passivetotal / libs / ssl.py View on Github external
raise INVALID_FIELD_TYPE("Field must be one of the following: %s"
                                     % ', '.join(SSL_VALID_FIELDS))
        return self._get('ssl-certificate', 'search', **kwargs)

    def search_keyword(self, **kwargs):
        """Search for a keyword across SSL certificate data.

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

        :param str query: Keyword value to search for in the dataset
        :return: List of matching hits based on the keyword
        """
        return self._get('ssl-certificate', 'search', 'keyword', **kwargs)


class SSLHistoryResponse(Response):
    pass


class SSLResponse(Response):
    @property
    def csv(self):
        """Output data as CSV.

        :return: String of formatted data
        """
        for result in self._results.get('results', []):
            data = [result.get(detail, '') for detail in SSL_VALID_FIELDS]
        return utilities.to_csv(SSL_VALID_FIELDS, [data])