Karta. Reports. Ingest
(Karta v1.0.0)
Reading a stored message as a report.
ingest/2 takes a received message, finds the report in it and records
it (Karta.Reports). Three kinds are read, told apart by content:
- a DMARC failure report (RFC 7489 §7.3), a feedback report
(
Karta.Reports.DMARC.Forensic); - a TLS-RPT report (RFC 8460), JSON as
application/tlsrpt+jsonor+gzip, or any of the shapes below holding JSON (Karta.Reports.TLSRPT); - a DMARC aggregate report: the XML itself, a gzip stream or a zip
archive, as Google, Microsoft, Yahoo and others send them
(
Karta.Reports.DMARC.Aggregate).
Hostile input. Reports arrive over SMTP from anyone who can reach
the address. The message is at most 10 MiB, the archive it carries is
unpacked to at most 32 MiB (Karta.Compression), and the XML is read
within Karta.Reports.DMARC.Aggregate's bounds: no document type
declaration, no entity, nothing outside the document; a TLS-RPT report
within its own (Karta.Reports.TLSRPT) and a failure report within
Karta.Complaints.ARF's. Nothing is looked up while a report is read.
Attribution. The report is attributed to a verified domain of the
receiving server's organisation when the domain it names
(policy_published/domain, Reported-Domain, or the policy domain of
a TLS report) is one (Karta.Domains.verified_domain/2); otherwise it
is kept unattributed. Nothing in a report is trusted: it cannot verify a
domain, change a policy or suppress an address.
Outcomes. {:ok, :recorded, report}, {:ok, :duplicate},
{:ok, :failed, reason} (the message was not a report, was too large
or could not be read; a row says so and stays for the operator),
{:ok, :ignored} (the message is gone, or is not a received message),
or {:error, reason}: reading the stored message failed, and the job
should be tried again.