6.3.5 - Normalize Delivery-Result value in forensic/failure reports (issue #76)

This commit is contained in:
Sean Whalen
2019-04-29 17:02:05 -04:00
parent 3b366a24e4
commit cf62534c5b
4 changed files with 23 additions and 2 deletions
+5
View File
@@ -1,3 +1,8 @@
6.3.5
-----
- Normalize `Delivery-Result` value in forensic/failure reports (issue #76)
6.3.4
-----
+11 -1
View File
@@ -38,7 +38,7 @@ from parsedmarc.utils import is_outlook_msg, convert_outlook_msg
from parsedmarc.utils import timestamp_to_human, human_timestamp_to_datetime
from parsedmarc.utils import parse_email
__version__ = "6.3.4"
__version__ = "6.3.5"
logging.basicConfig(
format='%(levelname)8s:%(filename)s:%(lineno)d:'
@@ -537,6 +537,8 @@ def parse_forensic_report(feedback_report, sample, msg_date,
Returns:
OrderedDict: A parsed report and sample
"""
delivery_results = ["delivered", "spam", "policy", "reject", "other"]
try:
parsed_report = OrderedDict()
report_values = feedback_report_regex.findall(feedback_report)
@@ -558,6 +560,13 @@ def parse_forensic_report(feedback_report, sample, msg_date,
if "delivery_result" not in parsed_report:
parsed_report["delivery_result"] = None
else:
for delivery_result in delivery_results:
if delivery_result in parsed_report["delivery_result"].lower():
parsed_report["delivery_result"] = delivery_result
break
if parsed_report["delivery_result"] not in delivery_results:
parsed_report["delivery_result"] = "other"
arrival_utc = human_timestamp_to_datetime(
parsed_report["arrival_date"], to_utc=True)
@@ -603,6 +612,7 @@ def parse_forensic_report(feedback_report, sample, msg_date,
sample_headers_only = False
number_of_attachments = len(parsed_sample["attachments"])
if number_of_attachments < 1 and parsed_sample["body"] is None:
if number_of_attachments < 1 and parsed_sample["body"] is None:
sample_headers_only = True
if sample_headers_only and parsed_sample["has_defects"]:
+6
View File
@@ -1,5 +1,11 @@
nose
flake8
doc8
jinja2
packaging
imagesize
alabaster
babel
sphinx
sphinx_rtd_theme
wheel
+1 -1
View File
@@ -14,7 +14,7 @@ from setuptools import setup
from codecs import open
from os import path
__version__ = "6.3.4"
__version__ = "6.3.5"
description = "A Python package and CLI for parsing aggregate and " \
"forensic DMARC reports"