diff --git a/bin/packages/Tag.py b/bin/packages/Tag.py index 1e6c9fbc..08265ad8 100755 --- a/bin/packages/Tag.py +++ b/bin/packages/Tag.py @@ -46,6 +46,27 @@ def is_galaxy_tag_enabled(galaxy, tag): else: return False +def enable_taxonomy(taxonomie, enable_tags=True): + ''' + Enable a taxonomy. (UI) + + :param taxonomie: MISP taxonomy + :type taxonomie: str + :param enable_tags: crawled domain + :type enable_tags: boolean + ''' + taxonomies = Taxonomies() + if enable_tags: + taxonomie_info = taxonomies.get(taxonomie) + if taxonomie_info: + # activate taxonomie + r_serv_tags.sadd('active_taxonomies', taxonomie) + # activate taxonomie tags + for tag in taxonomie_info.machinetags(): + r_serv_tags.sadd('active_tag_{}'.format(taxonomie), tag) + else: + print('Error: {}, please update pytaxonomies'.format(taxonomie)) + # Check if tags are enabled in AIL def is_valid_tags_taxonomies_galaxy(list_tags, list_tags_galaxy): if list_tags: diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index aa6d3268..728222ca 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -18,7 +18,13 @@ from flask_login import LoginManager, current_user, login_user, logout_user, log import flask import importlib from os.path import join + +# # TODO: put me in lib/Tag +from pytaxonomies import Taxonomies + sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/')) +import Tag + sys.path.append('./modules/') from User import User @@ -26,9 +32,6 @@ from User import User sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib/')) import ConfigLoader - -from pytaxonomies import Taxonomies - # Import config import Flask_config @@ -217,20 +220,15 @@ def page_not_found(e): return render_template('error/404.html'), 404 # ========== INITIAL taxonomies ============ -# add default ail taxonomies -r_serv_tags.sadd('active_taxonomies', 'infoleak') -r_serv_tags.sadd('active_taxonomies', 'gdpr') -r_serv_tags.sadd('active_taxonomies', 'fpf') -# add default tags -taxonomies = Taxonomies() -for tag in taxonomies.get('infoleak').machinetags(): - r_serv_tags.sadd('active_tag_infoleak', tag) -for tag in taxonomies.get('gdpr').machinetags(): - r_serv_tags.sadd('active_tag_gdpr', tag) -for tag in taxonomies.get('fpf').machinetags(): - r_serv_tags.sadd('active_tag_fpf', tag) +default_taxonomies = ["infoleak", "gdpr", "fpf", "dark-web"] + +# enable default taxonomies +for taxo in default_taxonomies: + Tag.enable_taxonomy(taxo) # ========== INITIAL tags auto export ============ +taxonomies = Taxonomies() + infoleak_tags = taxonomies.get('infoleak').machinetags() infoleak_automatic_tags = [] for tag in taxonomies.get('infoleak').machinetags(): diff --git a/var/www/templates/crawler/crawler_splash/showDomain.html b/var/www/templates/crawler/crawler_splash/showDomain.html index 279cba37..16161fe9 100644 --- a/var/www/templates/crawler/crawler_splash/showDomain.html +++ b/var/www/templates/crawler/crawler_splash/showDomain.html @@ -243,7 +243,7 @@   {{ dict_key }} - {{ key_id }} + {{ key_id }} {% endfor %} {% endif %}