From d6128eae9fc3e889e04624ecd6a82c0449a5179a Mon Sep 17 00:00:00 2001 From: Sean Whalen <44679+seanthegeek@users.noreply.github.com> Date: Mon, 1 Apr 2024 09:14:45 -0400 Subject: [PATCH] Actually save source_tye and source_name to Elasticsearch and Opensearch --- parsedmarc/__init__.py | 2 +- parsedmarc/elastic.py | 4 +++- parsedmarc/opensearch.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index bf4b2c5..fc994f6 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -413,7 +413,7 @@ def parse_aggregate_report_xml( Args: xml (str): A string of DMARC aggregate report XML ip_db_path (str): Path to a MMDB file from MaxMind or DBIP - always_use_local_files (bool): Do not download files + always_use_local_files (bool): Do not download files reverse_dns_map_path (str): Path to a reverse DNS map file reverse_dns_map_url (str): URL to a reverse DNS map file offline (bool): Do not query online for geolocation or DNS diff --git a/parsedmarc/elastic.py b/parsedmarc/elastic.py index f4eb2a9..8a63ded 100644 --- a/parsedmarc/elastic.py +++ b/parsedmarc/elastic.py @@ -60,7 +60,7 @@ class _AggregateReportDoc(Document): source_ip_address = Ip() source_country = Text() source_reverse_dns = Text() - source_Base_domain = Text() + source_base_domain = Text() source_type = Text() source_name = Text() message_count = Integer @@ -442,6 +442,8 @@ def save_aggregate_report_to_elasticsearch(aggregate_report, source_country=record["source"]["country"], source_reverse_dns=record["source"]["reverse_dns"], source_base_domain=record["source"]["base_domain"], + source_type=record["source"]["type"], + source_name=record["source"]["name"], message_count=record["count"], disposition=record["policy_evaluated"]["disposition"], dkim_aligned=record["policy_evaluated"]["dkim"] is not None and diff --git a/parsedmarc/opensearch.py b/parsedmarc/opensearch.py index 54488e0..5e777ed 100644 --- a/parsedmarc/opensearch.py +++ b/parsedmarc/opensearch.py @@ -59,7 +59,7 @@ class _AggregateReportDoc(Document): source_ip_address = Ip() source_country = Text() source_reverse_dns = Text() - source_Base_domain = Text() + source_base_domain = Text() source_type = Text() source_name = Text() message_count = Integer @@ -438,6 +438,8 @@ def save_aggregate_report_to_opensearch(aggregate_report, source_country=record["source"]["country"], source_reverse_dns=record["source"]["reverse_dns"], source_base_domain=record["source"]["base_domain"], + source_type=record["source"]["type"], + source_name=record["source"]["name"], message_count=record["count"], disposition=record["policy_evaluated"]["disposition"], dkim_aligned=record["policy_evaluated"]["dkim"] is not None and