diff --git a/bin/lib/Correlate_object.py b/bin/lib/Correlate_object.py index e3f21bd1..647650ee 100755 --- a/bin/lib/Correlate_object.py +++ b/bin/lib/Correlate_object.py @@ -52,7 +52,7 @@ def get_object_metadata(object_type, correlation_id, type_id=None): if object_type == 'domain': return Domain.Domain(correlation_id).get_domain_metadata() elif object_type == 'paste': - return Item.get_item({"id": correlation_id, "date": True, "tags": True})[0] + return Item.get_item({"id": correlation_id, "date": True, "date_separator": True, "tags": True})[0] elif object_type == 'decoded': return Decoded.get_decoded_metadata(correlation_id, nb_seen=True, size=True, file_type=True) elif object_type == 'pgp': diff --git a/bin/packages/Item.py b/bin/packages/Item.py index 162734fb..e4723a7c 100755 --- a/bin/packages/Item.py +++ b/bin/packages/Item.py @@ -34,9 +34,12 @@ def exist_item(item_id): def get_item_id(full_path): return full_path.replace(PASTES_FOLDER, '', 1) -def get_item_date(item_id): +def get_item_date(item_id, add_separator=False): l_directory = item_id.split('/') - return '{}{}{}'.format(l_directory[-4], l_directory[-3], l_directory[-2]) + if add_separator: + return '{}/{}/{}'.format(l_directory[-4], l_directory[-3], l_directory[-2]) + else: + return '{}{}{}'.format(l_directory[-4], l_directory[-3], l_directory[-2]) def get_source(item_id): return item_id.split('/')[-5] @@ -94,7 +97,10 @@ def get_item(request_dict): dict_item['id'] = item_id date = request_dict.get('date', True) if date: - dict_item['date'] = get_item_date(item_id) + add_separator = False + if request_dict.get('date_separator', False): + add_separator = True + dict_item['date'] = get_item_date(item_id, add_separator=add_separator) tags = request_dict.get('tags', True) if tags: dict_item['tags'] = Tag.get_item_tags(item_id) diff --git a/var/www/blueprints/correlation.py b/var/www/blueprints/correlation.py index 124abe71..ee9a51b0 100644 --- a/var/www/blueprints/correlation.py +++ b/var/www/blueprints/correlation.py @@ -216,7 +216,7 @@ def get_description(): # check if correlation_id exist # # TODO: return error json if not Correlate_object.exist_object(object_type, correlation_id, type_id=type_id): - abort(404) # return 404 + return Response(json.dumps({"status": "error", "reason": "404 Not Found"}, indent=2, sort_keys=True), mimetype='application/json'), 404 # oject exist else: res = Correlate_object.get_object_metadata(object_type, correlation_id, type_id=type_id) diff --git a/var/www/templates/correlation/metadata_card_paste.html b/var/www/templates/correlation/metadata_card_paste.html index 994351f5..5541cd00 100644 --- a/var/www/templates/correlation/metadata_card_paste.html +++ b/var/www/templates/correlation/metadata_card_paste.html @@ -23,7 +23,7 @@ {{ dict_object["metadata"]["type_id"] }} -