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:

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.

Summary

Functions

Reads the message id as a report. Options: :now (a DateTime), :max_message_bytes and :max_xml_bytes (tests make them small).

Functions

ingest(id, opts \\ [])

@spec ingest(term(), keyword()) ::
  {:ok, :recorded | :duplicate | :failed | :ignored, term()} | {:error, term()}

Reads the message id as a report. Options: :now (a DateTime), :max_message_bytes and :max_xml_bytes (tests make them small).