domainaware / parsedmarc

A Python package and CLI for parsing aggregate and forensic DMARC reports
https://domainaware.github.io/parsedmarc/
Apache License 2.0
994 stars 213 forks source link

fix: handle none value #468

Closed yktakaha4 closed 7 months ago

yktakaha4 commented 8 months ago

Thank you to all the maintainers.

In my use case, I encountered the below error.

Traceback (most recent call last):
  File "tests.py", line [39](https://github.com/yktakaha4/parsedmarc/actions/runs/7691856259/job/20957819252?pr=1#step:8:40), in testAggregateSamples
    parsedmarc.parsed_aggregate_reports_to_csv(parsed_report)
  File "/home/runner/work/parsedmarc/parsedmarc/parsedmarc/__init__.py", line 583, in parsed_aggregate_reports_to_csv
    rows = parsed_aggregate_reports_to_csv_rows(reports)
  File "/home/runner/work/parsedmarc/parsedmarc/parsedmarc/__init__.py", line 517, in parsed_aggregate_reports_to_csv_rows
    row["policy_override_reasons"] = ",".join(
TypeError: sequence item 0: expected str instance, NoneType found

It turned out that the None check was missing in the following places, so I fixed it. I've also added test data to verify the fix. https://github.com/domainaware/parsedmarc/blob/7d2b431e5f20bdcdb330c4fbb23ce7df5fb0642f/parsedmarc/__init__.py#L510

I believe that the CI failure will be resolved by merging the PR below. https://github.com/domainaware/parsedmarc/pull/466