mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-07-14 20:44:55 +00:00
3.2.0
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
3.2.0
|
||||
-----
|
||||
- Fix existing aggregate report error message
|
||||
|
||||
3.1.0
|
||||
-----
|
||||
- Fix existing aggregate report query
|
||||
|
||||
@@ -41,7 +41,7 @@ import imapclient.exceptions
|
||||
import dateparser
|
||||
import mailparser
|
||||
|
||||
__version__ = "3.1.0"
|
||||
__version__ = "3.2.0"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
@@ -183,7 +183,7 @@ def _timestamp_to_datetime(timestamp):
|
||||
return datetime.fromtimestamp(int(timestamp))
|
||||
|
||||
|
||||
def _timestamp_to_human(timestamp):
|
||||
def timestamp_to_human(timestamp):
|
||||
"""
|
||||
Converts a UNIX/DMARC timestamp to a human-readable string
|
||||
|
||||
@@ -429,8 +429,8 @@ def parse_aggregate_report_xml(xml, nameservers=None, timeout=6.0):
|
||||
"").replace(">", "").split("@")[0]
|
||||
new_report_metadata["report_id"] = report_id
|
||||
date_range = report["report_metadata"]["date_range"]
|
||||
date_range["begin"] = _timestamp_to_human(date_range["begin"])
|
||||
date_range["end"] = _timestamp_to_human(date_range["end"])
|
||||
date_range["begin"] = timestamp_to_human(date_range["begin"])
|
||||
date_range["end"] = timestamp_to_human(date_range["end"])
|
||||
new_report_metadata["begin_date"] = date_range["begin"]
|
||||
new_report_metadata["end_date"] = date_range["end"]
|
||||
errors = []
|
||||
@@ -1361,7 +1361,6 @@ def watch_inbox(host, username, password, callback, reports_folder="INBOX",
|
||||
nameservers=ns,
|
||||
dns_timeout=dt)
|
||||
callback(res)
|
||||
break
|
||||
|
||||
except imapclient.exceptions.IMAPClientError as error:
|
||||
error = error.__str__().lstrip("b'").rstrip("'").rstrip(".")
|
||||
|
||||
@@ -196,6 +196,7 @@ def save_aggregate_report_to_elasticsearch(aggregate_report):
|
||||
domain = aggregate_report["policy_published"]["domain"]
|
||||
begin_date = parsedmarc.human_timestamp_to_datetime(metadata["begin_date"])
|
||||
end_date = parsedmarc.human_timestamp_to_datetime(metadata["end_date"])
|
||||
end_date_human = parsedmarc.timestamp_to_human(end_date)
|
||||
aggregate_report["begin_date"] = begin_date
|
||||
aggregate_report["end_date"] = end_date
|
||||
date_range = (aggregate_report["begin_date"],
|
||||
@@ -209,10 +210,11 @@ def save_aggregate_report_to_elasticsearch(aggregate_report):
|
||||
search.query = org_name_query & domain_query & date_range_query
|
||||
existing = search.execute()
|
||||
if len(existing) > 0:
|
||||
raise AlreadySaved("Aggregate report ID {0} from {1} about {2} "
|
||||
"already exists in Elasticsearch".format(report_id,
|
||||
org_name,
|
||||
domain))
|
||||
raise AlreadySaved("Aggregate from {0} about {1} with end date (2) "
|
||||
"already exists in "
|
||||
"Elasticsearch".format(org_name,
|
||||
domain,
|
||||
end_date_human))
|
||||
published_policy = PublishedPolicy(
|
||||
adkim=aggregate_report["policy_published"]["adkim"],
|
||||
aspf=aggregate_report["policy_published"]["aspf"],
|
||||
|
||||
Reference in New Issue
Block a user