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"] }} - {{ dict_object["metadata"]['date'][0:4] }}/{{ dict_object["metadata"]['date'][4:6] }}/{{ dict_object["metadata"]['date'][6:8] }} + {{ dict_object["metadata"]['date'] }} diff --git a/var/www/templates/correlation/show_correlation.html b/var/www/templates/correlation/show_correlation.html index 8f58b368..93649171 100644 --- a/var/www/templates/correlation/show_correlation.html +++ b/var/www/templates/correlation/show_correlation.html @@ -427,10 +427,10 @@ if (d.popover) { .style("opacity", .9); } else { - //console.log(d); - var pop_header = ""+ sanitize_text(d.text) + "

" + var pop_header = "
"+ sanitize_text(d.text) +"
" + var spinner = "
Loading...
" - div.html(pop_header) + div.html(pop_header + spinner) .style("left", (d3_pageX) + "px") .style("top", (d3_pageY - 28) + "px"); @@ -440,14 +440,33 @@ if (d.popover) { $.getJSON("{{ url_for('correlation.get_description') }}?object_id="+ d.id, function(data){ - var desc = pop_header + var desc = pop_header + "
" Object.keys(data).forEach(function(key) { - desc = desc + key + ": " + sanitize_text(data[key]) + "
" - }) + if (key=="status") { + desc = desc + "
status
UP
" + } else if (key!="tags" && key!="id") { + desc = desc + "
" + sanitize_text(key) + "
" + sanitize_text(data[key]) + "
" + } + }); + desc = desc + "
" + + if (data["tags"]) { + data["tags"].forEach(function(tag) { + desc = desc + ""+ sanitize_text(tag) +""; + }); + } + + desc = desc + "
" div.html(desc) .style("left", (d3_pageX) + "px") .style("top", (d3_pageY - 28) + "px"); d.popover = desc + }) + .fail(function(error) { + desc = pop_header + "
"+ error.statusText +"
" + div.html(desc) + .style("left", (d3_pageX) + "px") + .style("top", (d3_pageY - 28) + "px"); }); } }