diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index f6fa514..0588e9b 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -1471,14 +1471,16 @@ def get_dmarc_reports_from_mbox( strip_attachment_payloads=sa, ) if parsed_email["report_type"] == "aggregate": + report_org = parsed_email["report"]["report_metadata"]["report_org"] report_id = parsed_email["report"]["report_metadata"]["report_id"] - if report_id not in SEEN_AGGREGATE_REPORT_IDS: - SEEN_AGGREGATE_REPORT_IDS[report_id] = report_id + report_key = f"{report_org}_{report_id}" + if report_key not in SEEN_AGGREGATE_REPORT_IDS: + SEEN_AGGREGATE_REPORT_IDS[report_key] = report_key aggregate_reports.append(parsed_email["report"]) else: logger.debug( "Skipping duplicate aggregate report " - f"with ID: {report_id}" + f"from {report_org} with ID: {report_id}" ) elif parsed_email["report_type"] == "forensic": forensic_reports.append(parsed_email["report"]) diff --git a/parsedmarc/cli.py b/parsedmarc/cli.py index 13ab304..47205a1 100644 --- a/parsedmarc/cli.py +++ b/parsedmarc/cli.py @@ -1419,13 +1419,16 @@ def _main(): logger.error("Failed to parse {0} - {1}".format(result[1], result[0])) else: if result[0]["report_type"] == "aggregate": - report_id = result[0]["report"]["report_metadata"]["report_id"] - if report_id not in SEEN_AGGREGATE_REPORT_IDS: - SEEN_AGGREGATE_REPORT_IDS[report_id] = report_id - aggregate_reports.append(result[0]["report"]) + report_org = parsed_email["report"]["report_metadata"]["report_org"] + report_id = parsed_email["report"]["report_metadata"]["report_id"] + report_key = f"{report_org}_{report_id}" + if report_key not in SEEN_AGGREGATE_REPORT_IDS: + SEEN_AGGREGATE_REPORT_IDS[report_key] = report_key + aggregate_reports.append(parsed_email["report"]) else: logger.debug( - "Skipping duplicate aggregate report " f"with ID: {report_id}" + "Skipping duplicate aggregate report " + f"from {report_org} with ID: {report_id}" ) elif result[0]["report_type"] == "forensic": forensic_reports.append(result[0]["report"])