chg: [api] add domain lookup

pull/607/merge
terrtia 2024-10-03 14:59:12 +02:00
parent f93d82eff4
commit 483d49fecf
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
3 changed files with 39 additions and 1 deletions

View File

@ -40,6 +40,7 @@ from packages import Date
from lib import ail_orgs from lib import ail_orgs
from lib.ConfigLoader import ConfigLoader from lib.ConfigLoader import ConfigLoader
from lib.objects.Domains import Domain from lib.objects.Domains import Domain
from lib.objects.Titles import Title
from lib.objects import HHHashs from lib.objects import HHHashs
from lib.objects.Items import Item from lib.objects.Items import Item
@ -55,6 +56,34 @@ config_loader = None
faup = Faup() 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 # # COMMON #

View File

@ -221,7 +221,7 @@ class Domain(AbstractObject):
# options: set of optional meta fields # options: set of optional meta fields
def get_meta(self, options=set()): def get_meta(self, options=set()):
meta = {'type': self.domain_type, meta = {'type': self.domain_type, # TODO RENAME ME -> Fix template
'id': self.id, 'id': self.id,
'domain': self.id, # TODO Remove me -> Fix templates 'domain': self.id, # TODO Remove me -> Fix templates
'first_seen': self.get_first_seen(), 'first_seen': self.get_first_seen(),

View File

@ -214,6 +214,15 @@ def objects_chat_thread_messages():
r = chats_viewer.api_thread_messages(obj_subtype, obj_id) r = chats_viewer.api_thread_messages(obj_subtype, obj_id)
return create_json_response(r[0], r[1]) return create_json_response(r[0], r[1])
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # DOMAINS # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@api_rest.route("api/v1/domain/lookup/<domain>", 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 # # # # # # # # # # # # # # # TITLES # # # # # # # # # # # # # # # # # # # TODO TO REVIEW
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #