chg: [Domain] move Domain to lib/

pull/418/head
Terrtia 2019-10-29 09:13:44 +01:00
parent f1def65c89
commit 4b389559ab
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
3 changed files with 30 additions and 8 deletions

View File

@ -12,12 +12,17 @@ import sys
import time
import redis
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/'))
import Correlation
import Cryptocurrency
import Item
sys.path.append(os.path.join(os.environ['AIL_FLASK'], 'modules/'))
import Flask_config
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib/'))
import ConfigLoader
r_serv_onion = Flask_config.r_serv_onion
config_loader = ConfigLoader.ConfigLoader()
r_serv_onion = config_loader.get_redis_conn("ARDB_Onion")
config_loader = None
def get_domain_type(domain):
if str(domain).endswith('.onion'):
@ -52,7 +57,7 @@ def get_link_tree():
###
### correlation
###
"""
def _get_domain_correlation(domain, correlation_name=None, correlation_type=None):
res = r_serv_metadata.smembers('item_{}_{}:{}'.format(correlation_name, correlation_type, item_id))
if res:
@ -74,7 +79,10 @@ def get_item_pgp_mail(item_id):
def get_item_pgp_correlation(item_id):
pass
"""
def _get_domain_correlation(domain, correlation_list):
return Cryptocurrency.get_cryptocurrency_domain(domain)
class Domain(object):
"""docstring for Domain."""

View File

@ -49,6 +49,7 @@ class Correlation(object):
if not request_dict:
return ({'status': 'error', 'reason': 'Malformed JSON'}, 400)
print(correlation_type)
field_name = request_dict.get(correlation_type, None)
if not field_name:
return ( {'status': 'error', 'reason': 'Mandatory parameter(s) not provided'}, 400 )

View File

@ -14,7 +14,7 @@ import Item
r_serv_metadata = Flask_config.r_serv_metadata
all_cryptocurrency = ['bitcoin', 'etherum']
all_cryptocurrency = ['bitcoin', 'ethereum', 'bitcoin-cash', 'litecoin', 'monero', 'zcash', 'dash']
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
@ -41,6 +41,18 @@ def verify_cryptocurrency_address(cryptocurrency_type, cryptocurrency_address):
else:
return True
def get_all_all_cryptocurrency():
return all_cryptocurrency
# check if all crypto type in the list are valid
# if a type is invalid, return the full list of currency types
def sanythise_cryptocurrency_types(cryptocurrency_types):
if cryptocurrency_types is None:
return get_all_all_cryptocurrency()
for currency in cryptocurrency_types: # # TODO: # OPTIMIZE:
if currency not in all_cryptocurrency:
return get_all_all_cryptocurrency()
return cryptocurrency_types
def get_cryptocurrency(request_dict, cryptocurrency_type):
# basic verification
@ -54,9 +66,10 @@ def get_cryptocurrency(request_dict, cryptocurrency_type):
return cryptocurrency.get_correlation(request_dict, cryptocurrency_type, field_name)
# # TODO: add get all cryptocurrency option
def get_cryptocurrency_domain(request_dict, cryptocurrency_type):
res = cryptocurrency.verify_correlation_field_request(request_dict, cryptocurrency_type, item_type='domain')
def get_cryptocurrency_domain(request_dict, cryptocurrency_type=None):
currency_types = sanythise_cryptocurrency_types(cryptocurrency_type)
res = cryptocurrency.verify_correlation_field_request(request_dict, currency_types, item_type='domain')
if res:
return res
field_name = request_dict.get(cryptocurrency_type)