Fix error message formatting

This commit is contained in:
Sean Whalen
2018-10-14 05:11:36 -04:00
parent 7fdee0ab76
commit a57d6836aa
2 changed files with 15 additions and 9 deletions
+13 -7
View File
@@ -322,15 +322,21 @@ def save_forensic_report_to_elasticsearch(forensic_report,
search = Index(index).search()
arrival_query = {"match": {"arrival_date": arrival_date}}
q = Q(arrival_query)
from_ = None
to_ = None
subject = None
if "from" in headers:
from_query = {"match": {"sample.headers.from": headers["from"]}}
from_ = headers["from"]
from_query = {"match": {"sample.headers.from": from_}}
q = q & from_query
if "to" in headers:
to_query = {"match": {"sample.headers.to": headers["to"]}}
to_ = headers["to"]
to_query = {"match": {"sample.headers.to": to_}}
q = q & Q(to_query)
if "subject" in headers:
subject_query = {"match": {"sample.headers.subject": headers[
"subject"]}}
subject = headers["subject"]
subject_query = {"match": {"sample.headers.subject": subject}}
q = q & subject_query
search.query = q
@@ -340,9 +346,9 @@ def save_forensic_report_to_elasticsearch(forensic_report,
raise AlreadySaved("A forensic sample to {0} from {1} "
"with a subject of {2} and arrival date of {3} "
"already exists in "
"Elasticsearch".format(headers["to"],
headers["from"],
headers["subject"],
"Elasticsearch".format(to_,
from_,
subject,
arrival_date_human
))
+2 -2
View File
@@ -405,8 +405,8 @@ def parse_email(data):
" ")
if "from" not in parsed_email:
if "From" in parsed_email["headers"]:
parsed_email["from"] = parsed_email["Headers"]["From"]
if "from" in parsed_email["headers"]:
parsed_email["from"] = parsed_email["Headers"]["from"]
else:
parsed_email["from"] = None