diff --git a/bin/lib/crawlers.py b/bin/lib/crawlers.py index c5931211..1b852570 100755 --- a/bin/lib/crawlers.py +++ b/bin/lib/crawlers.py @@ -40,6 +40,7 @@ from lib import ail_orgs from lib.ConfigLoader import ConfigLoader from lib.objects.Domains import Domain +from lib.objects.Titles import Title from lib.objects import HHHashs from lib.objects.Items import Item @@ -55,6 +56,34 @@ faup = Faup() +# # # # # # # # +# # +# DOMAINS # +# # +# # # # # # # # + +# is safe ??? +# TODO FILTER URL ??? + +def api_get_domain_lookup_meta(domain): + dom = Domain(domain) + if not dom.exists(): + return {'error': 'domain not found', 'domain': domain}, 404 + meta = dom.get_meta(options={'languages'}) + meta['first_seen'] = meta['first_seen'].replace('/', '-') + meta['last_seen'] = meta['last_check'].replace('/', '-') + meta['languages'] = list(meta['languages']) + del meta['domain'] + del meta['last_check'] + del meta['type'] + del meta['status'] + meta['titles'] = [] + for h in dom.get_correlation('title').get('title', []): + t = Title(h[1:]) + meta['titles'].append(t.get_content()) + return meta + + # # # # # # # # # # # COMMON # diff --git a/bin/lib/objects/Domains.py b/bin/lib/objects/Domains.py index 9756d7cc..88e94dd9 100755 --- a/bin/lib/objects/Domains.py +++ b/bin/lib/objects/Domains.py @@ -221,7 +221,7 @@ def get_meta_keys(self): # options: set of optional meta fields def get_meta(self, options=set()): - meta = {'type': self.domain_type, + meta = {'type': self.domain_type, # TODO RENAME ME -> Fix template 'id': self.id, 'domain': self.id, # TODO Remove me -> Fix templates 'first_seen': self.get_first_seen(), diff --git a/var/www/blueprints/api_rest.py b/var/www/blueprints/api_rest.py index 3b6f000f..84cb994c 100644 --- a/var/www/blueprints/api_rest.py +++ b/var/www/blueprints/api_rest.py @@ -214,6 +214,15 @@ def objects_chat_thread_messages(): r = chats_viewer.api_thread_messages(obj_subtype, obj_id) return create_json_response(r[0], r[1]) +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # DOMAINS # # # # # # # # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +@api_rest.route("api/v1/domain/lookup/", methods=['GET']) +@token_required('user') +def api_domain_lookup(domain): + return create_json_response(crawlers.api_get_domain_lookup_meta(domain), 200) + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # TITLES # # # # # # # # # # # # # # # # # # # TODO TO REVIEW # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #