add try except block to get_dmarc_reports call

This commit is contained in:
Nathan Thorpe
2022-04-03 21:49:27 -07:00
parent db1d3443fd
commit 445e3cdf9d
2 changed files with 20 additions and 15 deletions

View File

@@ -29,7 +29,7 @@ Features
* Parses draft and 1.0 standard aggregate/rua reports
* Parses forensic/failure/ruf reports
* Can parse reports from an inbox over IMAP
* Can parse reports from an inbox over IMAP or Microsoft Graph
* Transparently handles gzip or zip compressed reports
* Consistent data structures
* Simple JSON and/or CSV output

View File

@@ -787,21 +787,26 @@ def _main():
exit(1)
if mailbox_connection:
reports = get_dmarc_reports_from_mailbox(
connection=mailbox_connection,
delete=opts.mailbox_delete,
batch_size=opts.mailbox_batch_size,
reports_folder=opts.mailbox_reports_folder,
archive_folder=opts.mailbox_archive_folder,
ip_db_path=opts.ip_db_path,
offline=opts.offline,
nameservers=opts.nameservers,
test=opts.mailbox_test,
strip_attachment_payloads=opts.strip_attachment_payloads,
)
try:
reports = get_dmarc_reports_from_mailbox(
connection=mailbox_connection,
delete=opts.mailbox_delete,
batch_size=opts.mailbox_batch_size,
reports_folder=opts.mailbox_reports_folder,
archive_folder=opts.mailbox_archive_folder,
ip_db_path=opts.ip_db_path,
offline=opts.offline,
nameservers=opts.nameservers,
test=opts.mailbox_test,
strip_attachment_payloads=opts.strip_attachment_payloads,
)
aggregate_reports += reports["aggregate_reports"]
forensic_reports += reports["forensic_reports"]
aggregate_reports += reports["aggregate_reports"]
forensic_reports += reports["forensic_reports"]
except Exception as error:
logger.error("Mailbox Error: {0}".format(error.__str__()))
exit(1)
results = OrderedDict([("aggregate_reports", aggregate_reports),
("forensic_reports", forensic_reports)])