mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-06-01 08:29:44 +00:00
More refactoring
This commit is contained in:
@@ -777,7 +777,7 @@ def parse_forensic_report(feedback_report, sample, sample_headers_only,
|
||||
parsed_sample["delivered_to"] = list(
|
||||
map(lambda x: convert_address(x),
|
||||
parsed_sample["delivered_to"])
|
||||
)
|
||||
)
|
||||
|
||||
if "attachments" not in parsed_sample:
|
||||
parsed_sample["attachments"] = []
|
||||
|
||||
+2
-18
@@ -17,32 +17,16 @@ def _main():
|
||||
"""Called when the module in executed"""
|
||||
def process_reports(reports_):
|
||||
try:
|
||||
print(json.dumps(reports_, ensure_ascii=False, indent=2), "\n")
|
||||
if args.save_aggregate:
|
||||
for report in reports_["aggregate_reports"]:
|
||||
elastic.save_aggregate_report_to_elasticsearch(report)
|
||||
if args.save_forensic:
|
||||
for report in reports_["forensic_reports"]:
|
||||
elastic.save_forensic_report_to_elasticsearch(report)
|
||||
print(json.dumps(reports_, ensure_ascii=False, indent=2), "\n")
|
||||
except elastic.AlreadySaved as exception:
|
||||
logger.warning(exception.__str__())
|
||||
|
||||
def idle_callback():
|
||||
try:
|
||||
reports_ = get_dmarc_reports_from_inbox(args.host,
|
||||
args.user,
|
||||
args.password,
|
||||
reports_folder=rf,
|
||||
archive_folder=af,
|
||||
delete=args.delete,
|
||||
test=args.test)
|
||||
|
||||
process_reports(reports_)
|
||||
|
||||
except IMAPError as exception:
|
||||
print("IMAP Error: {0}".format(exception.__str__()))
|
||||
exit(-1)
|
||||
|
||||
arg_parser = ArgumentParser(description="Parses DMARC reports")
|
||||
arg_parser.add_argument("file_path", nargs="*",
|
||||
help="one or more paths to aggregate or forensic "
|
||||
@@ -192,7 +176,7 @@ def _main():
|
||||
logger.warning("The IMAP Connection is now in IDLE mode. "
|
||||
"Quit with ^c")
|
||||
try:
|
||||
watch_inbox(args.host, args.user, args.password, idle_callback,
|
||||
watch_inbox(args.host, args.user, args.password, process_reports,
|
||||
reports_folder=args.reports_folder,
|
||||
archive_folder=args.archive_folder, delete=args.delete,
|
||||
test=args.test, nameservers=args.nameservers,
|
||||
|
||||
Reference in New Issue
Block a user