def run(address, config): """Run discovery and return results.""" results = {} ipaddress = dns.resolve_hostname(address) results['domain'] = dns.domain_info(address) results['address'] = ipaddress if config.username is not None: server = find_nova_host(ipaddress, config) if server: host = {'type': 'Nova instance'} host['uri'] = [l['href'] for l in server.links if l['rel'] == 'self'][0] host['name'] = server.name host['id'] = server.id host['addresses'] = server.addresses if all([config.system_info, config.host_key]): module_name = config.system_info if '.' not in module_name: module_name = 'satori.sysinfo.%s' % module_name system_info_module = importlib.import_module(module_name) result = system_info_module.get_systeminfo(host, config) host['system_info'] = result results['host'] = host return results
def run(address, config): """Run discovery and return results.""" results = {} ipaddress = dns.resolve_hostname(address) results['domain'] = dns.domain_info(address) results['address'] = ipaddress if config.username is not None: server = find_nova_host(ipaddress, config) if server: host = {'type': 'Nova instance'} host['uri'] = [ l['href'] for l in server.links if l['rel'] == 'self' ][0] host['name'] = server.name host['id'] = server.id host['addresses'] = server.addresses if all([config.system_info, config.host_key]): module_name = config.system_info if '.' not in module_name: module_name = 'satori.sysinfo.%s' % module_name system_info_module = importlib.import_module(module_name) result = system_info_module.get_systeminfo(host, config) host['system_info'] = result results['host'] = host return results
def test_domain_info_returns_none_for_missing_expiration_date(self): small_whois = [""" Domain : example.io Status : Live NS 1 : dns1.example.com NS 2 : dns2.example.com """] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertIsNone(data['expiration_date'])
def test_domain_info_returns_string_date_for_expiry(self): small_whois = [""" Domain : example.io Status : Live Expiry : 2014-11-06 NS 1 : dns1.example.com NS 2 : dns2.example.com """] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertIsInstance(data['expiration_date'], six.string_types)
def run(target, config=None, interactive=False): """Run discovery and return results.""" if config is None: config = {} found = {} resources = {} errors = {} results = { 'target': target, 'created': utils.get_time_string(), 'found': found, 'resources': resources, } if utils.is_valid_ip_address(target): ip_address = target else: hostname = dns.parse_target_hostname(target) found['hostname'] = hostname ip_address = six.text_type(dns.resolve_hostname(hostname)) # TODO(sam): Use ipaddress.ip_address.is_global # .is_private # .is_unspecified # .is_multicast # To determine address "type" if not ipaddress.ip_address(ip_address).is_loopback: try: domain_info = dns.domain_info(hostname) resource_type = 'OS::DNS::Domain' identifier = '%s:%s' % (resource_type, hostname) resources[identifier] = { 'type': resource_type, 'key': identifier, } found['domain-key'] = identifier resources[identifier]['data'] = domain_info if 'registered' in domain_info: found['registered-domain'] = domain_info['registered'] except shared.WhoisException as exc: results['domain'] = str(exc) found['ip-address'] = ip_address host, host_errors = discover_host(ip_address, config, interactive=interactive) if host_errors: errors.update(host_errors) key = host.get('key') or ip_address resources[key] = host found['host-key'] = key results['updated'] = utils.get_time_string() return results, errors
def test_domain_info_returns_none_for_missing_expiration_date(self): small_whois = [ """ Domain : example.io Status : Live NS 1 : dns1.example.com NS 2 : dns2.example.com """ ] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertIsNone(data['expiration_date'])
def test_domain_info_returns_none_for_days_until_expires(self): small_whois = [ """ Domain : example.io Status : Live NS 1 : dns1.example.com NS 2 : dns2.example.com """ ] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertEqual(data['days_until_expires'], None)
def run(target, config=None, interactive=False): """Run discovery and return results.""" if config is None: config = {} found = {} resources = {} errors = {} results = { 'target': target, 'created': utils.get_time_string(), 'found': found, 'resources': resources, } if utils.is_valid_ip_address(target): ip_address = target else: hostname = dns.parse_target_hostname(target) found['hostname'] = hostname ip_address = six.text_type(dns.resolve_hostname(hostname)) #TODO(sam): Use ipaddress.ip_address.is_global # " .is_private # " .is_unspecified # " .is_multicast # To determine address "type" if not ipaddress.ip_address(ip_address).is_loopback: try: domain_info = dns.domain_info(hostname) resource_type = 'OS::DNS::Domain' identifier = '%s:%s' % (resource_type, hostname) resources[identifier] = { 'type': resource_type, 'key': identifier, } found['domain-key'] = identifier resources[identifier]['data'] = domain_info if 'registered' in domain_info: found['registered-domain'] = domain_info['registered'] except shared.WhoisException as exc: results['domain'] = str(exc) found['ip-address'] = ip_address host, host_errors = discover_host(ip_address, config, interactive=interactive) if host_errors: errors.update(host_errors) key = host.get('key') or ip_address resources[key] = host found['host-key'] = key results['updated'] = utils.get_time_string() return results, errors
def test_domain_info_returns_string_date_for_expiry(self): small_whois = [ """ Domain : example.io Status : Live Expiry : 2014-11-06 NS 1 : dns1.example.com NS 2 : dns2.example.com """ ] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertIsInstance(data['expiration_date'], six.string_types)
def test_domain_info_returns_no_registrar_from_whois(self): small_whois = [ """ Domain : example.io Status : Live Expiry : 2014-11-06 NS 1 : dns1.example.com NS 2 : dns2.example.com """ ] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertEqual([], data['registrar'])
def test_domain_info_returns_none_for_days_until_expires(self): small_whois = [""" Domain : example.io Status : Live NS 1 : dns1.example.com NS 2 : dns2.example.com """] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertEqual( data['days_until_expires'], None )
def test_domain_info_returns_no_registrar_from_whois(self): small_whois = [""" Domain : example.io Status : Live Expiry : 2014-11-06 NS 1 : dns1.example.com NS 2 : dns2.example.com """] self.mock_get_whois_raw.return_value = small_whois data = dns.domain_info(self.domain) self.assertEqual( [], data['registrar'] )
def run(address, config=None, interactive=False): """Run discovery and return results.""" if config is None: config = {} results = {} if utils.is_valid_ip_address(address): ipaddress = address else: ipaddress = dns.resolve_hostname(address) #TODO(sam): Use ipaddress.ip_address.is_global # " .is_private # " .is_unspecified # " .is_multicast # To determine address "type" if not ipaddress_module.ip_address(unicode(ipaddress)).is_loopback: try: results['domain'] = dns.domain_info(address) except shared.WhoisException as exc: results['domain'] = str(exc) results['address'] = ipaddress results['host'] = host = {'type': 'Undetermined'} if config.get('username'): server = find_nova_host(ipaddress, config) if server: host['type'] = 'Nova instance' host['uri'] = [ l['href'] for l in server.links if l['rel'] == 'self' ][0] host['name'] = server.name host['id'] = server.id host['addresses'] = server.addresses if config.get('system_info'): module_name = config['system_info'].replace("-", "_") if '.' not in module_name: module_name = 'satori.sysinfo.%s' % module_name system_info_module = utils.import_object(module_name) result = system_info_module.get_systeminfo(ipaddress, config, interactive=interactive) host['system_info'] = result return results
def run(address, config=None, interactive=False): """Run discovery and return results.""" if config is None: config = {} results = {} if utils.is_valid_ip_address(address): ipaddress = address else: ipaddress = dns.resolve_hostname(address) #TODO(sam): Use ipaddress.ip_address.is_global # " .is_private # " .is_unspecified # " .is_multicast # To determine address "type" if not ipaddress_module.ip_address(unicode(ipaddress)).is_loopback: try: results['domain'] = dns.domain_info(address) except shared.WhoisException as exc: results['domain'] = str(exc) results['address'] = ipaddress results['host'] = host = {'type': 'Undetermined'} if config.get('username'): server = find_nova_host(ipaddress, config) if server: host['type'] = 'Nova instance' host['uri'] = [l['href'] for l in server.links if l['rel'] == 'self'][0] host['name'] = server.name host['id'] = server.id host['addresses'] = server.addresses if config.get('system_info'): module_name = config['system_info'].replace("-", "_") if '.' not in module_name: module_name = 'satori.sysinfo.%s' % module_name system_info_module = utils.import_object(module_name) result = system_info_module.get_systeminfo(ipaddress, config, interactive=interactive) host['system_info'] = result return results
def run(address, config): """Run discovery and return results.""" results = {} ipaddress = dns.resolve_hostname(address) results['domain'] = dns.domain_info(address) results['address'] = ipaddress if config.username is not None: server = find_nova_host(ipaddress, config) if server: host = {'type': 'Nova instance'} host['uri'] = [l['href'] for l in server.links if l['rel'] == 'self'][0] host['name'] = server.name host['id'] = server.id host['addresses'] = server.addresses results['host'] = host return results
def run(address, config): """Run discovery and return results.""" results = {} ipaddress = dns.resolve_hostname(address) results['domain'] = dns.domain_info(address) results['address'] = ipaddress if config.username is not None: server = find_nova_host(ipaddress, config) if server: host = {'type': 'Nova instance'} host['uri'] = [ l['href'] for l in server.links if l['rel'] == 'self' ][0] host['name'] = server.name host['id'] = server.id host['addresses'] = server.addresses results['host'] = host return results
def test_domain_info_returns_nameservers_from_whois(self): data = dns.domain_info(self.domain) self.assertEqual( ['ns1.domain.com', 'ns2.domain.com'], data['nameservers'] )
def test_domain_info_returns_array_of_strings_whois_data(self): data = dns.domain_info(self.domain) self.assertIsInstance(data['whois'][0], str)
def test_domain_info_returns_domain_name_from_parameter(self): data = dns.domain_info(self.domain) self.assertEqual(self.domain, data['name'])
def test_domain_info_returns_365_day_expiration(self): data = dns.domain_info(self.domain) self.assertEqual( 365, data['days_until_expires'] )
def test_domain_info_returns_slimmed_down_domain_name(self): data = dns.domain_info("s1.www." + self.domain) self.assertEqual( self.domain, data['name'] )
def test_domain_info_returns_domain_name_from_parameter(self): data = dns.domain_info(self.domain) self.assertEqual( self.domain, data['name'] )
def test_domain_info_returns_slimmed_down_domain_name(self): data = dns.domain_info("s1.www." + self.domain) self.assertEqual(self.domain, data['name'])
def test_domain_info_returns_registrar_from_whois(self): data = dns.domain_info(self.domain) self.assertEqual( 'Fake Company, Inc', data['registrar'] )
def test_domain_info_returns_nameservers_as_list(self): data = dns.domain_info(self.domain) self.assertIsInstance( data['nameservers'], list )
def test_domain_info_returns_365_day_expiration(self): data = dns.domain_info(self.domain) self.assertEqual(365, data['days_until_expires'])
def test_domain_info_returns_string_for_expiration_date_string(self): data = dns.domain_info(self.domain) self.assertIsInstance(data['expiration_date'], six.string_types)
def test_domain_info_returns_nameservers_as_list(self): data = dns.domain_info(self.domain) self.assertIsInstance(data['nameservers'], list)
def test_domain_info_returns_nameservers_from_whois(self): data = dns.domain_info(self.domain) self.assertEqual(['ns1.domain.com', 'ns2.domain.com'], data['nameservers'])
def test_domain_info_returns_registrar_from_whois(self): data = dns.domain_info(self.domain) self.assertEqual('Fake Company, Inc', data['registrar'])