Karta. Reports
(Karta v1.0.0)
The reports Karta receives about the mail sent from the domains it
serves: DMARC aggregate reports, DMARC failure reports and TLS-RPT
reports (kind), and with them the pages that show them.
Who a report belongs to. A report is kept with the server whose
address received it, and attributed to a verified domain of that
server's organisation when the report names one; otherwise it is kept
unattributed (domain_id is nil). Nothing a report says makes it
authoritative: it cannot verify a domain, change a policy, suppress an
address or decide that any mail is genuine. A report about another
organisation's domain is never attributed to it, and the pages of one
organisation never read another's reports.
Twice is once. record/3 stores a report under a report_key that
identifies it (server_id and report_key are unique), so a report
delivered twice is recorded once; the second call says :duplicate.
A report that could not be read is kept too (fail/2), so an operator
sees that it arrived and why it was not used.
Rows are removed after retention_days/0 by Karta.Reports.Pruner.
Summary
Functions
Queues the reading of the received message id as a report
(Karta.Reports.Worker).
Records that a message could not be read as a report, with attrs
(server_id, report_key, message_id, mailbox, error, and
kind when the message was recognised as one), at now
(the :now option). {:ok, :recorded, report} or {:ok, :duplicate}.
A report of the organisation, with its domain, server and records
loaded, or nil.
A page of the organisation's reports, newest first. Options: :after,
:before (a report id) and :limit, as for Karta.Pager.page/2.
Removes the reports received more than :days (default
retention_days/0) before now (the :now option): how many reports
were removed. Their records go with them.
Records a report read from attrs (see attributes/0) with its
records, at now (the :now option). {:ok, :recorded, report}, or
{:ok, :duplicate} when the same report was recorded before.
The records of a report, the largest count first.
A page of a report's records, the largest count first. Options:
:after, :before (a record id) and :limit, as for
Karta.Pager.page/2.
How many days a received report is kept (90).
Types
@type attributes() :: %{ :server_id => Ecto.UUID.t(), :report_key => String.t(), optional(atom()) => term() }
Functions
@spec enqueue(term()) :: {:ok, Oban.Job.t()} | {:error, term()}
Queues the reading of the received message id as a report
(Karta.Reports.Worker).
@spec fail(map(), keyword()) :: {:ok, :recorded, Karta.Reports.DMARC.Report.t()} | {:ok, :duplicate}
Records that a message could not be read as a report, with attrs
(server_id, report_key, message_id, mailbox, error, and
kind when the message was recognised as one), at now
(the :now option). {:ok, :recorded, report} or {:ok, :duplicate}.
@spec get(Karta.Accounts.Organisation.t(), term()) :: Karta.Reports.DMARC.Report.t() | nil
A report of the organisation, with its domain, server and records
loaded, or nil.
@spec page(Karta.Accounts.Organisation.t(), keyword()) :: Karta.Pager.Page.t()
A page of the organisation's reports, newest first. Options: :after,
:before (a report id) and :limit, as for Karta.Pager.page/2.
@spec prune(keyword()) :: non_neg_integer()
Removes the reports received more than :days (default
retention_days/0) before now (the :now option): how many reports
were removed. Their records go with them.
@spec record(attributes(), [map()], keyword()) :: {:ok, :recorded, Karta.Reports.DMARC.Report.t()} | {:ok, :duplicate}
Records a report read from attrs (see attributes/0) with its
records, at now (the :now option). {:ok, :recorded, report}, or
{:ok, :duplicate} when the same report was recorded before.
@spec records(Karta.Reports.DMARC.Report.t()) :: [Karta.Reports.DMARC.Record.t()]
The records of a report, the largest count first.
@spec records_page(Karta.Reports.DMARC.Report.t(), keyword()) :: Karta.Pager.Page.t()
A page of a report's records, the largest count first. Options:
:after, :before (a record id) and :limit, as for
Karta.Pager.page/2.
@spec retention_days() :: pos_integer()
How many days a received report is kept (90).