from parsedmarc.utils import parse_email
from parsedmarc.utils import timestamp_to_human, human_timestamp_to_datetime
-__version__ = "8.13.0"
+__version__ = "8.14.0"
logger.debug("parsedmarc v{0}".format(__version__))
@@ -185,6 +185,8 @@ Source code for parsedmarc
"""
record = record.copy()
new_record = OrderedDict()
+ if record["row"]["source_ip"] is None:
+ raise ValueError("Source IP address is empty")
new_record_source = get_ip_address_info(
record["row"]["source_ip"],
cache=IP_ADDRESS_CACHE,
@@ -192,6 +194,7 @@ Source code for parsedmarc
always_use_local_files=always_use_local_files,
reverse_dns_map_path=reverse_dns_map_path,
reverse_dns_map_url=reverse_dns_map_url,
+ reverse_dns_map=REVERSE_DNS_MAP,
offline=offline,
nameservers=nameservers,
timeout=dns_timeout)
@@ -624,16 +627,19 @@ Source code for parsedmarc
keep_alive()
logger.debug("Processed {0}/{1}".format(
i, len(report["record"])))
- report_record = _parse_report_record(
- report["record"][i],
- ip_db_path=ip_db_path,
- offline=offline,
- always_use_local_files=always_use_local_files,
- reverse_dns_map_path=reverse_dns_map_path,
- reverse_dns_map_url=reverse_dns_map_url,
- nameservers=nameservers,
- dns_timeout=timeout)
- records.append(report_record)
+ try:
+ report_record = _parse_report_record(
+ report["record"][i],
+ ip_db_path=ip_db_path,
+ offline=offline,
+ always_use_local_files=always_use_local_files,
+ reverse_dns_map_path=reverse_dns_map_path,
+ reverse_dns_map_url=reverse_dns_map_url,
+ nameservers=nameservers,
+ dns_timeout=timeout)
+ records.append(report_record)
+ except Exception as e:
+ logger.warning("Could not parse record: {0}".format(e))
else:
report_record = _parse_report_record(
@@ -678,18 +684,13 @@ Source code for parsedmarc
str: The extracted text
"""
- def is_base64(s):
- base64_regex = re.compile(r'^[A-Za-z0-9+/=]+\Z')
- return bool(base64_regex.match(s))
-
try:
file_object = None
if isinstance(input_, str):
- if is_base64(input_):
- try:
- file_object = BytesIO(b64decode(input_))
- except binascii.Error:
- pass
+ try:
+ file_object = BytesIO(b64decode(input_))
+ except binascii.Error:
+ pass
else:
file_object = open(input_, "rb")
elif type(input_) is bytes:
@@ -991,6 +992,7 @@ Source code for parsedmarc
always_use_local_files=always_use_local_files,
reverse_dns_map_path=reverse_dns_map_path,
reverse_dns_map_url=reverse_dns_map_url,
+ reverse_dns_map=REVERSE_DNS_MAP,
offline=offline,
nameservers=nameservers,
timeout=dns_timeout)
@@ -1503,10 +1505,15 @@ Source code for parsedmarc
aggregate_report_msg_uids = []
forensic_report_msg_uids = []
smtp_tls_msg_uids = []
- aggregate_reports_folder = "{0}/Aggregate".format(archive_folder)
- forensic_reports_folder = "{0}/Forensic".format(archive_folder)
- smtp_tls_reports_folder = "{0}/SMTP-TLS".format(archive_folder)
- invalid_reports_folder = "{0}/Invalid".format(archive_folder)
+ folder_separator = connection.get_folder_separator()
+ aggregate_reports_folder = "{0}{1}Aggregate".format(archive_folder,
+ folder_separator)
+ forensic_reports_folder = "{0}{1}Forensic".format(archive_folder,
+ folder_separator)
+ smtp_tls_reports_folder = "{0}{1}SMTP-TLS".format(archive_folder,
+ folder_separator)
+ invalid_reports_folder = "{0}{1}Invalid".format(archive_folder,
+ folder_separator)
if results:
aggregate_reports = results["aggregate_reports"].copy()
@@ -1800,6 +1807,7 @@ Source code for parsedmarc
aggregate_reports = results["aggregate_reports"]
forensic_reports = results["forensic_reports"]
smtp_tls_reports = results["smtp_tls_reports"]
+ output_directory = os.path.expanduser(output_directory)
if os.path.exists(output_directory):
if not os.path.isdir(output_directory):
diff --git a/_modules/parsedmarc/elastic.html b/_modules/parsedmarc/elastic.html
index 780d2ba8..2f4a30ab 100644
--- a/_modules/parsedmarc/elastic.html
+++ b/_modules/parsedmarc/elastic.html
@@ -3,7 +3,7 @@
- parsedmarc.elastic — parsedmarc 8.13.0 documentation
+ parsedmarc.elastic — parsedmarc 8.14.0 documentation
@@ -35,7 +35,7 @@
parsedmarc
- 8.13.0
+ 8.14.0