Use a combination of report org and report ID when checking for duplicate aggregate reports

This commit is contained in:
Sean Whalen
2025-01-07 14:25:57 -05:00
parent bcfcd93fc6
commit 26a651cded
2 changed files with 13 additions and 8 deletions
+5 -3
View File
@@ -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"])
+8 -5
View File
@@ -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"])