From 38c6f8697321353fb26c1db357cac4e8b6a0ed28 Mon Sep 17 00:00:00 2001 From: Sean Whalen <44679+seanthegeek@users.noreply.github.com> Date: Fri, 10 Jan 2025 09:09:24 -0500 Subject: [PATCH 1/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d9f47..d18a8b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Changelog 8.17.0 ------ -- Ignore duplicate aggregate DMARC reports with the same `org_name` and `report_id` seen within the same hour (Fixes [#539](https://github.com/domainaware/parsedmarc/issues/539)) +- Ignore duplicate aggregate DMARC reports with the same `org_name` and `report_id` seen within the same hour (Fixes #535) - Fix saving SMTP TLS reports to OpenSearch (PR #585 closed issue #576) - Add 303 entries to `base_reverse_dns_map.csv` From 446c018920705d362ac27d70c0e05692fa37758d Mon Sep 17 00:00:00 2001 From: bendem Date: Mon, 3 Feb 2025 21:20:52 +0100 Subject: [PATCH 2/4] do not stop processing when we encounter an invalid dmarc report (#587) --- parsedmarc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index b3165d8..220fbb3 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -1294,7 +1294,7 @@ def parse_report_email( "is not a valid " "aggregate DMARC report: {1}".format(subject, e) ) - raise ParserError(error) + raise InvalidDMARCReport(error) except Exception as e: error = "Unable to parse message with " 'subject "{0}": {1}'.format( From 669deb97559e95a0e96b750fdf63b325ce72a6cc Mon Sep 17 00:00:00 2001 From: Kevin Goad <104081882+kevingoad-arcfield@users.noreply.github.com> Date: Mon, 3 Feb 2025 15:25:15 -0500 Subject: [PATCH 3/4] Add support for Microsoft national clouds via Graph API base URL (#590) * adding support for Microsoft National Clouds * Update usage.md --- docs/source/usage.md | 2 ++ parsedmarc/cli.py | 5 +++++ parsedmarc/mail/graph.py | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/source/usage.md b/docs/source/usage.md index 81f0fa5..cd20cb8 100644 --- a/docs/source/usage.md +++ b/docs/source/usage.md @@ -208,6 +208,8 @@ The full set of configuration options are: - `mailbox` - str: The mailbox name. This defaults to the current user if using the UsernamePassword auth method, but could be a shared mailbox if the user has access to the mailbox + - `graph_url` - str: Microsoft Graph URL. Allows for use of National Clouds (ex Azure Gov) + (Default: https://graph.microsoft.com) - `token_file` - str: Path to save the token file (Default: `.token`) - `allow_unencrypted_storage` - bool: Allows the Azure Identity diff --git a/parsedmarc/cli.py b/parsedmarc/cli.py index 200c8b5..a98883d 100644 --- a/parsedmarc/cli.py +++ b/parsedmarc/cli.py @@ -528,6 +528,7 @@ def _main(): graph_tenant_id=None, graph_mailbox=None, graph_allow_unencrypted_storage=False, + graph_url="graph.microsoft.com", hec=None, hec_token=None, hec_index=None, @@ -879,6 +880,9 @@ def _main(): ) exit(-1) + if "graph_url" in graph_config: + opts.graph_url = graph_config["graph_url"] + if "allow_unencrypted_storage" in graph_config: opts.graph_allow_unencrypted_storage = graph_config.getboolean( "allow_unencrypted_storage" @@ -1496,6 +1500,7 @@ def _main(): password=opts.graph_password, token_file=opts.graph_token_file, allow_unencrypted_storage=opts.graph_allow_unencrypted_storage, + graph_url=opts.graph_url, ) except Exception: diff --git a/parsedmarc/mail/graph.py b/parsedmarc/mail/graph.py index 918706a..740aeb8 100644 --- a/parsedmarc/mail/graph.py +++ b/parsedmarc/mail/graph.py @@ -89,6 +89,7 @@ class MSGraphConnection(MailboxConnection): self, auth_method: str, mailbox: str, + graph_url: str, client_id: str, client_secret: str, username: str, @@ -108,7 +109,10 @@ class MSGraphConnection(MailboxConnection): token_path=token_path, allow_unencrypted_storage=allow_unencrypted_storage, ) - client_params = {"credential": credential} + client_params = { + "credential": credential, + "cloud": graph_url, + } if not isinstance(credential, ClientSecretCredential): scopes = ["Mail.ReadWrite"] # Detect if mailbox is shared From c7c451b1b1f505369a2ccca9ac658b24fb5f9baf Mon Sep 17 00:00:00 2001 From: Paul Hecker <266615+lluuaapp@users.noreply.github.com> Date: Mon, 3 Feb 2025 21:26:15 +0100 Subject: [PATCH 4/4] Set http.client._MAXHEADERS to 200 (#589) --- parsedmarc/cli.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parsedmarc/cli.py b/parsedmarc/cli.py index a98883d..06ad5af 100644 --- a/parsedmarc/cli.py +++ b/parsedmarc/cli.py @@ -14,6 +14,7 @@ import json from ssl import CERT_NONE, create_default_context from multiprocessing import Pipe, Process import sys +import http.client from tqdm import tqdm from parsedmarc import ( @@ -48,6 +49,8 @@ from parsedmarc.log import logger from parsedmarc.utils import is_mbox, get_reverse_dns from parsedmarc import SEEN_AGGREGATE_REPORT_IDS +http.client._MAXHEADERS = 200 # pylint:disable=protected-access + formatter = logging.Formatter( fmt="%(levelname)8s:%(filename)s:%(lineno)d:%(message)s", datefmt="%Y-%m-%d:%H:%M:%S",