From e0899e6e0d78ad3d121f671afb87efa28ae74d4b Mon Sep 17 00:00:00 2001 From: Terrtia Date: Fri, 21 Apr 2023 15:38:48 +0200 Subject: [PATCH] chg: [corellation graph] hide unsafe screenshots --- bin/lib/objects/Screenshots.py | 4 ++-- var/www/blueprints/correlation.py | 3 ++- var/www/templates/correlation/show_correlation.html | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/lib/objects/Screenshots.py b/bin/lib/objects/Screenshots.py index 8dbca0ac..bf1a92d0 100755 --- a/bin/lib/objects/Screenshots.py +++ b/bin/lib/objects/Screenshots.py @@ -86,8 +86,8 @@ class Screenshot(AbstractObject): meta = {'id': self.id} meta['img'] = get_screenshot_rel_path(self.id) ######### # TODO: Rename ME ?????? meta['tags'] = self.get_tags(r_list=True) - # TODO: ADD IN ABSTRACT CLASS - #meta['is_tags_safe'] = Tag.is_tags_safe(metadata_dict['tags']) ################## # TODO: ADD IN ABSTRACT CLASS + if 'tags_safe' in options: + meta['tags_safe'] = self.is_tags_safe(meta['tags']) return meta def get_screenshot_dir(): diff --git a/var/www/blueprints/correlation.py b/var/www/blueprints/correlation.py index 48388995..35263974 100644 --- a/var/www/blueprints/correlation.py +++ b/var/www/blueprints/correlation.py @@ -157,7 +157,8 @@ def get_description(): return Response(json.dumps({"status": "error", "reason": "404 Not Found"}, indent=2, sort_keys=True), mimetype='application/json'), 404 # object exist else: - res = ail_objects.get_object_meta(object_type, type_id, correlation_id, options={'tags'}, flask_context=True) + res = ail_objects.get_object_meta(object_type, type_id, correlation_id, options={'tags', 'tags_safe'}, + flask_context=True) if 'tags' in res: res['tags'] = list(res['tags']) return jsonify(res) diff --git a/var/www/templates/correlation/show_correlation.html b/var/www/templates/correlation/show_correlation.html index 07536556..746ffdf7 100644 --- a/var/www/templates/correlation/show_correlation.html +++ b/var/www/templates/correlation/show_correlation.html @@ -542,10 +542,14 @@ if (d.popover) { } if (data["img"]) { - desc = desc + ""; + if (data["tags_safe"]) { + desc = desc + ""; + } else { + desc = desc + ""; + } } - desc = desc + "" + desc = desc + "" div.html(desc) .style("left", (d3_pageX) + "px") .style("top", (d3_pageY - 28) + "px");