diff --git a/_modules/index.html b/_modules/index.html
index 3091a02e..413a032e 100644
--- a/_modules/index.html
+++ b/_modules/index.html
@@ -8,7 +8,7 @@
-
Overview: module code — parsedmarc 5.2.1 documentation
+ Overview: module code — parsedmarc 5.3.0 documentation
@@ -56,7 +56,7 @@
- 5.2.1
+ 5.3.0
diff --git a/_modules/parsedmarc.html b/_modules/parsedmarc.html
index 5aa5d8a7..1aa0c4e9 100644
--- a/_modules/parsedmarc.html
+++ b/_modules/parsedmarc.html
@@ -8,7 +8,7 @@
- parsedmarc — parsedmarc 5.2.1 documentation
+ parsedmarc — parsedmarc 5.3.0 documentation
@@ -56,7 +56,7 @@
- 5.2.1
+ 5.3.0
@@ -183,7 +183,7 @@
from parsedmarc.utils import timestamp_to_human, human_timestamp_to_datetime
from parsedmarc.utils import parse_email
-__version__ = "5.2.1"
+__version__ = "5.3.0"
logging.basicConfig(
format='%(levelname)8s:%(filename)s:%(lineno)d:'
@@ -868,7 +868,7 @@
timeout=timeout,
strip_attachment_payloads=strip_attachment_payloads)
except Exception as e:
- raise ParserError(e.__str__())
+ raise InvalidForensicReport(e.__str__())
result = OrderedDict([("report_type", "forensic"),
("report", forensic_report)])
@@ -1057,7 +1057,7 @@
use_uid=True)
server.login(user, password)
- if move_supported is not None:
+ if move_supported is None:
server_capabilities = get_imap_capabilities(server)
move_supported = "MOVE" in server_capabilities
@@ -1120,21 +1120,33 @@
logger.debug("Found {0} messages in IMAP folder {1}".format(
len(messages), reports_folder))
for i in range(len(messages)):
- message_uid = messages[i]
+ msg_uid = messages[i]
logger.debug("Processing message {0} of {1}: UID {2}".format(
i+1,
total_messages,
- message_uid
+ msg_uid
))
try:
try:
- raw_msg = server.fetch(message_uid,
- ["RFC822"])[message_uid][b"RFC822"]
+ raw_msg = server.fetch(msg_uid,
+ ["RFC822"])[msg_uid]
+ msg_keys = [b'RFC822', b'BODY[NULL]']
+ msg_key = ''
+ for key in msg_keys:
+ if key in raw_msg.keys():
+ msg_key = key
+ break
+ raw_msg = raw_msg[msg_key]
except (ConnectionResetError, socket.error,
TimeoutError) as error:
logger.debug("IMAP error: {0}".format(error.__str__()))
logger.debug("Reconnecting to IMAP")
+ try:
+ server.shutdown()
+ except Exception as e:
+ logger.debug(
+ "Failed to log out: {0}".format(e.__str__()))
if not ssl:
logger.debug("Connecting to IMAP over plain text")
server = imapclient.IMAPClient(host,
@@ -1144,8 +1156,8 @@
use_uid=True)
server.login(user, password)
server.select_folder(reports_folder)
- raw_msg = server.fetch(message_uid,
- ["RFC822"])[message_uid][b"RFC822"]
+ raw_msg = server.fetch(msg_uid,
+ ["RFC822"])[msg_uid][b"RFC822"]
msg_content = raw_msg.decode("utf-8", errors="replace")
sa = strip_attachment_payloads
@@ -1155,28 +1167,28 @@
strip_attachment_payloads=sa)
if parsed_email["report_type"] == "aggregate":
aggregate_reports.append(parsed_email["report"])
- aggregate_report_msg_uids.append(message_uid)
+ aggregate_report_msg_uids.append(msg_uid)
elif parsed_email["report_type"] == "forensic":
forensic_reports.append(parsed_email["report"])
- forensic_report_msg_uids.append(message_uid)
+ forensic_report_msg_uids.append(msg_uid)
except imapclient.exceptions.IMAPClientError as error:
error = error.__str__().lstrip("b'").rstrip("'").rstrip(".")
error = "IMAP error: Skipping message UID {0}: {1}".format(
- message_uid, error)
+ msg_uid, error)
logger.error("IMAP error: {0}".format(error))
except InvalidDMARCReport as error:
logger.warning(error.__str__())
if not test:
if delete:
logger.debug(
- "Deleting message UID {0}".format(message_uid))
- delete_messages([message_uid])
+ "Deleting message UID {0}".format(msg_uid))
+ delete_messages([msg_uid])
else:
logger.debug(
"Moving message UID {0} to {1}".format(
- message_uid, invalid_reports_folder))
- move_messages([message_uid], invalid_reports_folder)
+ msg_uid, invalid_reports_folder))
+ move_messages([msg_uid], invalid_reports_folder)
if not test:
if delete:
@@ -1202,6 +1214,11 @@
TimeoutError) as e:
logger.debug("IMAP error: {0}".format(e.__str__()))
logger.debug("Reconnecting to IMAP")
+ try:
+ server.shutdown()
+ except Exception as e:
+ logger.debug(
+ "Failed to log out: {0}".format(e.__str__()))
if not ssl:
logger.debug("Connecting to IMAP over plain text")
server = imapclient.IMAPClient(host,
@@ -1239,6 +1256,11 @@
logger.debug("IMAP error: {0}".format(
error.__str__()))
logger.debug("Reconnecting to IMAP")
+ try:
+ server.shutdown()
+ except Exception as e:
+ logger.debug("Failed to log out: {0}".format(
+ e.__str__()))
if not ssl:
logger.debug(
"Connecting to IMAP over plain text")
@@ -1280,6 +1302,12 @@
logger.debug("IMAP error: {0}".format(
error.__str__()))
logger.debug("Reconnecting to IMAP")
+ try:
+ server.shutdown()
+ except Exception as e:
+ logger.debug("Failed to "
+ "disconnect: {0}".format(
+ e.__str__()))
if not ssl:
logger.debug(
"Connecting to IMAP over plain text")
@@ -1645,6 +1673,10 @@
error,
sleep_minutes))
logger.debug("Reconnecting watcher")
+ try:
+ server.logout()
+ except Exception as e:
+ logger.debug("Failed to log out: {0}".format(e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1671,6 +1703,10 @@
except ConnectionResetError:
logger.debug("IMAP error: Connection reset")
logger.debug("Reconnecting watcher")
+ try:
+ server.shutdown()
+ except Exception as e:
+ logger.debug("Failed to disconnect: {0}".format(e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1689,6 +1725,10 @@
except KeyError:
logger.debug("IMAP error: Server returned unexpected result")
logger.debug("Reconnecting watcher")
+ try:
+ server.logout()
+ except Exception as e:
+ logger.debug("Failed to log out: {0}".format(e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1715,6 +1755,10 @@
except BrokenPipeError:
logger.debug("IMAP error: Broken pipe")
logger.debug("Reconnecting watcher")
+ try:
+ server.shutdown()
+ except Exception as e:
+ logger.debug("Failed to disconnect: {0}".format(e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1781,6 +1825,11 @@
error,
sleep_minutes))
logger.debug("Reconnecting watcher")
+ try:
+ server.logout()
+ except Exception as e:
+ logger.debug("Failed to disconnect: {0}".format(
+ e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1805,6 +1854,10 @@
except (KeyError, socket.error, BrokenPipeError, ConnectionResetError):
logger.debug("IMAP error: Connection reset")
logger.debug("Reconnecting watcher")
+ try:
+ server.logout()
+ except Exception as e:
+ logger.debug("Failed to disconnect: {0}".format(e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1823,6 +1876,10 @@
except KeyError:
logger.debug("IMAP error: Server returned unexpected result")
logger.debug("Reconnecting watcher")
+ try:
+ server.logout()
+ except Exception as e:
+ logger.debug("Failed to log out: {0}".format(e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1849,6 +1906,10 @@
except BrokenPipeError:
logger.debug("IMAP error: Broken pipe")
logger.debug("Reconnecting watcher")
+ try:
+ server.shutdown()
+ except Exception as e:
+ logger.debug("Failed to disconnect: {0}".format(e.__str__()))
server = imapclient.IMAPClient(host)
server.login(username, password)
server.select_folder(rf)
@@ -1868,7 +1929,6 @@
try:
server.idle_done()
- server.logout()
except BrokenPipeError:
pass
diff --git a/_modules/parsedmarc/elastic.html b/_modules/parsedmarc/elastic.html
index 0b32ae6f..9322574d 100644
--- a/_modules/parsedmarc/elastic.html
+++ b/_modules/parsedmarc/elastic.html
@@ -8,7 +8,7 @@
- parsedmarc.elastic — parsedmarc 5.2.1 documentation
+ parsedmarc.elastic — parsedmarc 5.3.0 documentation
@@ -56,7 +56,7 @@
- 5.2.1
+ 5.3.0
diff --git a/_modules/parsedmarc/splunk.html b/_modules/parsedmarc/splunk.html
index ed7c0b8a..df0c4562 100644
--- a/_modules/parsedmarc/splunk.html
+++ b/_modules/parsedmarc/splunk.html
@@ -8,7 +8,7 @@
- parsedmarc.splunk — parsedmarc 5.2.1 documentation
+ parsedmarc.splunk — parsedmarc 5.3.0 documentation
@@ -56,7 +56,7 @@
- 5.2.1
+ 5.3.0
diff --git a/_modules/parsedmarc/utils.html b/_modules/parsedmarc/utils.html
index 0bd5e15b..6d9ea02a 100644
--- a/_modules/parsedmarc/utils.html
+++ b/_modules/parsedmarc/utils.html
@@ -8,7 +8,7 @@
- parsedmarc.utils — parsedmarc 5.2.1 documentation
+ parsedmarc.utils — parsedmarc 5.3.0 documentation
@@ -56,7 +56,7 @@
- 5.2.1
+ 5.3.0
diff --git a/_static/documentation_options.js b/_static/documentation_options.js
index e9345c86..10b961cb 100644
--- a/_static/documentation_options.js
+++ b/_static/documentation_options.js
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
- VERSION: '5.2.1',
+ VERSION: '5.3.0',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
diff --git a/genindex.html b/genindex.html
index a5cb30e8..5c16de5d 100644
--- a/genindex.html
+++ b/genindex.html
@@ -9,7 +9,7 @@
- Index — parsedmarc 5.2.1 documentation
+ Index — parsedmarc 5.3.0 documentation
@@ -57,7 +57,7 @@
- 5.2.1
+ 5.3.0
diff --git a/index.html b/index.html
index 082650a2..7c03926b 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,7 @@
- parsedmarc documentation - Open source DMARC report analyzer and visualizer — parsedmarc 5.2.1 documentation
+ parsedmarc documentation - Open source DMARC report analyzer and visualizer — parsedmarc 5.3.0 documentation
@@ -56,7 +56,7 @@
- 5.2.1
+ 5.3.0
diff --git a/objects.inv b/objects.inv
index 35c9c55a..136df0e3 100644
Binary files a/objects.inv and b/objects.inv differ
diff --git a/py-modindex.html b/py-modindex.html
index b7718791..eb8f8e05 100644
--- a/py-modindex.html
+++ b/py-modindex.html
@@ -8,7 +8,7 @@
- Python Module Index — parsedmarc 5.2.1 documentation
+ Python Module Index — parsedmarc 5.3.0 documentation
@@ -59,7 +59,7 @@
- 5.2.1
+ 5.3.0
diff --git a/search.html b/search.html
index d237d1d7..eed69de1 100644
--- a/search.html
+++ b/search.html
@@ -8,7 +8,7 @@
- Search — parsedmarc 5.2.1 documentation
+ Search — parsedmarc 5.3.0 documentation
@@ -56,7 +56,7 @@
- 5.2.1
+ 5.3.0