Skip to content

Commit

Permalink
Add support for sending SMTP TLS results to Log Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
seanthegeek committed Jan 3, 2024
1 parent 17c2035 commit e416c54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion parsedmarc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ def process_reports(reports_):
la_client.publish_results(
reports_,
opts.save_aggregate,
opts.save_forensic)
opts.save_forensic,
opts.save_smtp_tls)
except loganalytics.LogAnalyticsException as e:
logger.error(
"Log Analytics error: {0}".format(e.__str__()))
Expand Down
19 changes: 17 additions & 2 deletions parsedmarc/loganalytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ def publish_results(
self,
results,
save_aggregate: bool,
save_forensic: bool):
save_forensic: bool,
save_smtp_tls: bool
):
"""
Function to publish DMARC reports to Log Analytics
Function to publish DMARC and/or SMTP TLS reports to Log Analytics
via Data Collection Rules (DCR).
Look below for docs:
https://learn.microsoft.com/en-us/azure/azure-monitor/logs/logs-ingestion-api-overview
Expand All @@ -131,6 +133,8 @@ def publish_results(
Whether Aggregate reports can be saved into Log Analytics
save_forensic (bool):
Whether Forensic reports can be saved into Log Analytics
save_smtp_tls (bool):
Whether Forensic reports can be saved into Log Analytics
"""
conf = self.conf
credential = ClientSecretCredential(
Expand Down Expand Up @@ -161,3 +165,14 @@ def publish_results(
logs_client,
conf.dcr_forensic_stream)
logger.info("Successfully pushed forensic reports.")
if (
results['smtp_tls_reports'] and
conf.dcr_smtp_tls_stream and
len(results['smtp_tls_reports']) > 0 and
save_smtp_tls):
logger.info("Publishing SMTP TLS reports.")
self.publish_json(
results['smtp_tls_reports'],
logs_client,
conf.dcr_forensic_stream)
logger.info("Successfully pushed SMTP TLS reports.")

0 comments on commit e416c54

Please sign in to comment.