mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-06-01 16:39:45 +00:00
* general cleanup to meet linter rules
This commit is contained in:
+18
-9
@@ -1234,11 +1234,12 @@ def watch_inbox(host, username, password, callback, port=None, ssl=True,
|
||||
except (timeout, IMAPClientError):
|
||||
logger.warning("IMAP connection timeout. Reconnecting...")
|
||||
|
||||
def save_output(results, output_directory="output", \
|
||||
output_json_aggregate_file="aggregate.json", \
|
||||
output_json_forensic_file="forensic.json", \
|
||||
output_csv_aggregate_file="aggregate.csv", \
|
||||
output_csv_forensic_file="forensic.csv"):
|
||||
|
||||
def save_output(results, output_directory="output",
|
||||
output_json_aggregate="aggregate.json",
|
||||
output_json_forensic="forensic.json",
|
||||
output_csv_aggregate="aggregate.csv",
|
||||
output_csv_forensic="forensic.csv"):
|
||||
"""
|
||||
Save report data in the given directory
|
||||
|
||||
@@ -1256,22 +1257,30 @@ def save_output(results, output_directory="output", \
|
||||
else:
|
||||
os.makedirs(output_directory)
|
||||
|
||||
with open("{0}".format(os.path.join(output_directory, output_json_aggregate_file)),
|
||||
with open("{0}"
|
||||
.format(os.path.join(output_directory,
|
||||
output_json_aggregate)),
|
||||
"w", newline="\n", encoding="utf-8") as agg_json:
|
||||
agg_json.write(json.dumps(aggregate_reports, ensure_ascii=False,
|
||||
indent=2))
|
||||
|
||||
with open("{0}".format(os.path.join(output_directory, output_csv_aggregate_file)),
|
||||
with open("{0}"
|
||||
.format(os.path.join(output_directory,
|
||||
output_csv_aggregate)),
|
||||
"w", newline="\n", encoding="utf-8") as agg_csv:
|
||||
csv = parsed_aggregate_reports_to_csv(aggregate_reports)
|
||||
agg_csv.write(csv)
|
||||
|
||||
with open("{0}".format(os.path.join(output_directory, output_json_forensic_file)),
|
||||
with open("{0}"
|
||||
.format(os.path.join(output_directory,
|
||||
output_json_forensic)),
|
||||
"w", newline="\n", encoding="utf-8") as for_json:
|
||||
for_json.write(json.dumps(forensic_reports, ensure_ascii=False,
|
||||
indent=2))
|
||||
|
||||
with open("{0}".format(os.path.join(output_directory, output_csv_forensic_file)),
|
||||
with open("{0}"
|
||||
.format(os.path.join(output_directory,
|
||||
output_csv_forensic)),
|
||||
"w", newline="\n", encoding="utf-8") as for_csv:
|
||||
csv = parsed_forensic_reports_to_csv(forensic_reports)
|
||||
for_csv.write(csv)
|
||||
|
||||
+21
-17
@@ -160,14 +160,18 @@ def _main():
|
||||
help=strip_attachment_help, action="store_true")
|
||||
arg_parser.add_argument("-o", "--output",
|
||||
help="write output files to the given directory")
|
||||
arg_parser.add_argument("--output-json-aggregate-file",
|
||||
help="output aggregate JSON file", default="aggregate.json")
|
||||
arg_parser.add_argument("--output-json-forensic-file",
|
||||
help="output forensic JSON file", default="forensic.json")
|
||||
arg_parser.add_argument("--output-csv-aggregate-file",
|
||||
help="output aggregate CSV file", default="aggregate.csv")
|
||||
arg_parser.add_argument("--output-csv-forensic-file",
|
||||
help="output forensic CSV file", default="forensic.csv")
|
||||
arg_parser.add_argument("--output-json-aggregate",
|
||||
help="output aggregate JSON file",
|
||||
default="aggregate.json")
|
||||
arg_parser.add_argument("--output-json-forensic",
|
||||
help="output forensic JSON file",
|
||||
default="forensic.json")
|
||||
arg_parser.add_argument("--output-csv-aggregate",
|
||||
help="output aggregate CSV file",
|
||||
default="aggregate.csv")
|
||||
arg_parser.add_argument("--output-csv-forensic",
|
||||
help="output forensic CSV file",
|
||||
default="forensic.csv")
|
||||
arg_parser.add_argument("-n", "--nameservers", nargs="+",
|
||||
help="nameservers to query")
|
||||
arg_parser.add_argument("-t", "--dns_timeout",
|
||||
@@ -197,10 +201,10 @@ def _main():
|
||||
offline=args.offline,
|
||||
strip_attachment_payloads=args.strip_attachment_payloads,
|
||||
output=args.output,
|
||||
output_json_aggregate_file=args.output_json_aggregate_file,
|
||||
output_json_forensic_file=args.output_json_forensic_file,
|
||||
output_csv_aggregate_file=args.output_csv_aggregate_file,
|
||||
output_csv_forensic_file=args.output_csv_forensic_file,
|
||||
output_json_aggregate=args.output_json_aggregate,
|
||||
output_json_forensic=args.output_json_forensic,
|
||||
output_csv_aggregate=args.output_csv_aggregate,
|
||||
output_csv_forensic=args.output_csv_forensic,
|
||||
nameservers=args.nameservers,
|
||||
silent=args.silent,
|
||||
dns_timeout=args.dns_timeout,
|
||||
@@ -632,11 +636,11 @@ def _main():
|
||||
("forensic_reports", forensic_reports)])
|
||||
|
||||
if opts.output:
|
||||
save_output(results, output_directory=opts.output, \
|
||||
output_json_aggregate_file=opts.output_json_aggregate_file, \
|
||||
output_json_forensic_file=opts.output_json_forensic_file, \
|
||||
output_csv_aggregate_file=opts.output_csv_aggregate_file, \
|
||||
output_csv_forensic_file=opts.output_csv_forensic_file)
|
||||
save_output(results, output_directory=opts.output,
|
||||
output_json_aggregate=opts.output_json_aggregate,
|
||||
output_json_forensic=opts.output_json_forensic,
|
||||
output_csv_aggregate=opts.output_csv_aggregate,
|
||||
output_csv_forensic=opts.output_csv_forensic)
|
||||
|
||||
process_reports(results)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user