Ejemplo n.º 1
0
    def test_processDomain_should_return_None(self):
        """
        Test processDomain(self, domainName, parentEvent, affil=False, host=None)

        Todo:
            review: why should this return None?
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = 'example.local'
        target_type = 'INTERNET_NAME'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = 'example module'
        source_event = ''
        parent_event = SpiderFootEvent(event_type, event_data, event_module,
                                       source_event)

        result = module.processDomain('www.example.local', parent_event, None,
                                      None)

        self.assertIsNone(result)
Ejemplo n.º 2
0
    def test_handleEvent(self):
        """
        Test handleEvent(self, event)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = 'spiderfoot.net'
        target_type = 'INTERNET_NAME'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = ''
        source_event = ''
        evt = SpiderFootEvent(event_type, event_data, event_module,
                              source_event)

        event_type = 'RAW_RIR_DATA'
        event_data = 'example data spiderfoot.net example data'
        event_module = 'example module'
        source_event = evt
        evt = SpiderFootEvent(event_type, event_data, event_module,
                              source_event)

        result = module.handleEvent(evt)

        self.assertIsNone(result)
        self.assertEqual('TODO', 'TODO')
Ejemplo n.º 3
0
    def test_processHost_should_return_SpiderFootEvent(self):
        """
        Test processHost(self, host, parentEvent, affiliate=None)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = '127.0.0.1'
        target_type = 'IP_ADDRESS'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = 'example module'
        source_event = ''
        parent_event = SpiderFootEvent(event_type, event_data, event_module,
                                       source_event)

        result = module.processHost("127.0.0.1", parent_event, None)

        self.assertIsInstance(result, SpiderFootEvent)

        self.assertIsNone(result)
Ejemplo n.º 4
0
    def test_processHost_affiliate_ip_address_should_return_affiliate_ip_address_event(
            self):
        """
        Test processHost(self, host, parentEvent, affiliate=None)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = '127.0.0.1'
        target_type = 'IP_ADDRESS'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = 'example module'
        source_event = ''
        parent_event = SpiderFootEvent(event_type, event_data, event_module,
                                       source_event)

        host = '127.0.0.1'
        result = module.processHost(host, parent_event, True)

        self.assertIsInstance(result, SpiderFootEvent)
        self.assertEqual(result.data, host)
        self.assertEqual(result.eventType, 'AFFILIATE_IPADDR')
Ejemplo n.º 5
0
    def test_setup(self):
        """
        Test setup(self, sfc, userOpts=dict())
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())
Ejemplo n.º 6
0
    def test_processDomain(self):
        """
        Test processDomain(self, domainName, parentEvent, affil=False, host=None)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.processDomain(None, None, None, None)

        self.assertEqual('TBD', 'TBD')
Ejemplo n.º 7
0
    def test_processHost(self):
        """
        Test processHost(self, host, parentEvent, affiliate=None)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.processHost(None, None, None)

        self.assertEqual('TBD', 'TBD')
Ejemplo n.º 8
0
    def test_enrichTarget_should_return_SpiderFootTarget(self):
        """
        Test enrichTarget(self, target)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = '127.0.0.1'
        target_type = 'IP_ADDRESS'
        target = SpiderFootTarget(target_value, target_type)

        result = module.enrichTarget(target)
        self.assertIsInstance(result, SpiderFootTarget)
Ejemplo n.º 9
0
    def test_handleEvent_event_data_raw_rir_data_containing_subdomain_should_return_internet_name_event(
            self):
        """
        Test handleEvent(self, event)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = 'spiderfoot.net'
        target_type = 'INTERNET_NAME'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        def new_notifyListeners(self, event):
            expected = 'INTERNET_NAME'
            if str(event.eventType) != expected:
                raise Exception(f"{event.eventType} != {expected}")

            expected = "www.spiderfoot.net"
            if str(event.data) != expected:
                raise Exception(f"{event.data} != {expected}")

            raise Exception("OK")

        module.notifyListeners = new_notifyListeners.__get__(
            module, sfp_dnsresolve)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = ''
        source_event = ''
        evt = SpiderFootEvent(event_type, event_data, event_module,
                              source_event)

        event_type = 'RAW_RIR_DATA'
        event_data = 'example data www.spiderfoot.net example data'
        event_module = 'example module'
        source_event = evt
        evt = SpiderFootEvent(event_type, event_data, event_module,
                              source_event)

        with self.assertRaises(Exception) as cm:
            module.handleEvent(evt)

        self.assertEqual("OK", str(cm.exception))
Ejemplo n.º 10
0
    def test_handleEvent_event_data_affiliate_ip_address_should_return_affiliate_internet_name_event(
            self):
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = 'spiderfoot.net'
        target_type = 'INTERNET_NAME'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        def new_notifyListeners(self, event):
            expected = 'AFFILIATE_INTERNET_NAME'
            if str(event.eventType) != expected:
                raise Exception(f"{event.eventType} != {expected}")

            expected = "one.one.one.one"
            if str(event.data) != expected:
                raise Exception(f"{event.data} != {expected}")

            raise Exception("OK")

        module.notifyListeners = new_notifyListeners.__get__(
            module, sfp_dnsresolve)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = ''
        source_event = ''
        evt = SpiderFootEvent(event_type, event_data, event_module,
                              source_event)

        event_type = 'IP_ADDRESS'
        event_data = '1.1.1.1'
        event_module = 'example module'
        source_event = evt
        evt = SpiderFootEvent(event_type, event_data, event_module,
                              source_event)

        with self.assertRaises(Exception) as cm:
            module.handleEvent(evt)

        self.assertEqual("OK", str(cm.exception))
Ejemplo n.º 11
0
    def test_handleEvent(self):
        """
        Test handleEvent(self, event)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = 'example target value'
        target_type = 'IP_ADDRESS'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        event_type = 'ROOT'
        event_data = 'example data'
        event_module = ''
        source_event = ''
        evt = SpiderFootEvent(event_type, event_data, event_module, source_event)

        result = module.handleEvent(evt)
Ejemplo n.º 12
0
    def test_resolveTargets_should_return_list(self):
        """
        Test resolveTargets(self, target, validateReverse)
        """
        sf = SpiderFoot(self.default_options)

        module = sfp_dnsresolve()
        module.setup(sf, dict())

        target_value = 'spiderfoot.net'
        target_type = 'INTERNET_NAME'
        target = SpiderFootTarget(target_value, target_type)
        module.setTarget(target)

        invalid_types = [None, "", list(), dict()]
        for invalid_type in invalid_types:
            with self.subTest(invalid_type=invalid_type):
                resolve_targets = module.resolveTargets(invalid_type, False)
                self.assertIsInstance(resolve_targets, list)

        target = SpiderFootTarget("spiderfoot.net", "INTERNET_NAME")
        resolve_targets = module.resolveTargets(target, False)
        self.assertIsInstance(resolve_targets, list)
        self.assertIn('spiderfoot.net', resolve_targets)

        target = SpiderFootTarget("127.0.0.1", "IP_ADDRESS")
        resolve_targets = module.resolveTargets(target, False)
        self.assertIsInstance(resolve_targets, list)
        self.assertIn('127.0.0.1', resolve_targets)

        target = SpiderFootTarget("::1", "IPV6_ADDRESS")
        resolve_targets = module.resolveTargets(target, False)
        self.assertIsInstance(resolve_targets, list)
        self.assertIn('::1', resolve_targets)

        target = SpiderFootTarget("127.0.0.1/32", "NETBLOCK_OWNER")
        resolve_targets = module.resolveTargets(target, False)
        self.assertIsInstance(resolve_targets, list)
        self.assertIn('127.0.0.1', resolve_targets)
Ejemplo n.º 13
0
 def test_opts(self):
     module = sfp_dnsresolve()
     self.assertEqual(len(module.opts), len(module.optdescs))
Ejemplo n.º 14
0
 def test_producedEvents_should_return_list(self):
     module = sfp_dnsresolve()
     self.assertIsInstance(module.producedEvents(), list)
Ejemplo n.º 15
0
 def test_setup(self):
     sf = SpiderFoot(self.default_options)
     module = sfp_dnsresolve()
     module.setup(sf, dict())