Skip to content

Commit

Permalink
Add S3 output support for SMTP TLS reports
Browse files Browse the repository at this point in the history
  • Loading branch information
seanthegeek committed Jan 3, 2024
1 parent 8b494f1 commit 6a8b2ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions parsedmarc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ def process_reports(reports_):
error_.__str__()))
try:
if opts.s3_bucket:
pass
# TODO: save SMTP TLS reports to S3
s3_client.save_smtp_tls_report_to_s3(report)
except Exception as error_:
logger.error("S3 Error: {0}".format(error_.__str__()))
try:
Expand Down
15 changes: 11 additions & 4 deletions parsedmarc/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,18 @@ def save_aggregate_report_to_s3(self, report):
def save_forensic_report_to_s3(self, report):
self.save_report_to_s3(report, 'forensic')

def save_smtp_tls_report_to_s3(self, report):
self.save_report_to_s3(report, "smtp_tls")

def save_report_to_s3(self, report, report_type):
report_date = human_timestamp_to_datetime(
report["report_metadata"]["begin_date"]
)
report_id = report["report_metadata"]["report_id"]
if report_type == "smtp_tls":
report_date = report["begin_date"]
report_id = report["report_id"]
else:
report_date = human_timestamp_to_datetime(
report["report_metadata"]["begin_date"]
)
report_id = report["report_metadata"]["report_id"]
path_template = "{0}/{1}/year={2}/month={3:02d}/day={4:02d}/{5}.json"
object_path = path_template.format(
self.bucket_path,
Expand Down
2 changes: 1 addition & 1 deletion parsedmarc/syslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def save_forensic_report_to_syslog(self, forensic_reports):
rows = parsed_forensic_reports_to_csv_rows(forensic_reports)
for row in rows:
self.logger.info(json.dumps(row))

def save_smtp_tls_report_to_syslog(self, smtp_tls_reports):
rows = parsed_smtp_tls_reports_to_csv_rows(smtp_tls_reports)
for row in rows:
Expand Down

0 comments on commit 6a8b2ff

Please sign in to comment.