mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-22 22:27:17 +00:00
chg: [api] add domain lookup
This commit is contained in:
parent
f93d82eff4
commit
483d49fecf
3 changed files with 39 additions and 1 deletions
|
@ -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 #
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
|
@ -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
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
|
Loading…
Reference in a new issue