Karta. TLSReport
(Karta v1.0.0)
The data of TLS reports (RFC 8460): what happened to each TLS session of outbound delivery, by the domain whose policy applied. Reports to the domains themselves are built from it later; here it is collected.
Every session is recorded (record/2) with one result:
"success"- TLS was established and met the policy;- a failure (
result_types/0):"starttls-not-supported","certificate-host-mismatch","certificate-expired","certificate-not-trusted"and"validation-failure"for a session;"tlsa-invalid"(no certificate matched the TLSA records),"dnssec-invalid"(the TLSA lookup failed) and"dane-required"(DANE required by the configuration, no usable TLSA records) for DANE;"sts-policy-fetch-error","sts-policy-invalid"and"sts-webpki-invalid"for a policy that could not be fetched.
policy_type is "tlsa" when an MX host's TLSA records decided (DANE;
the policy text is the RRset, one record a line), "sts" when an
MTA-STS policy applied, and "no-policy-found" otherwise. Policy texts
are kept once per domain and digest, for the report's
policy-string. summary/2 adds the sessions of a domain
and day up the way a report counts them. Rows older than 30 days are
removed by prune/2 (Karta.TLSReport.Pruner, daily).
Recording is best effort: an error is logged and never fails a delivery.
Summary
Functions
The policy domains with sessions on day, the busiest first, at most
limit: the domains a report is made for.
Removes sessions of days before today - keep_days, and policy texts
older than that which no session uses any more. Returns how many of
each were removed.
Records one session (attrs, see attrs/0; policy is the text of
the policy that applied, if any). now gives the day.
The failure result types Karta records.
The sessions of policy_domain on day, added up: one map per policy,
result, MX host and pair of addresses, with count. policy is the
policy's text (nil without one); details the latest of the group's.
Types
@type attrs() :: %{ :policy_domain => String.t(), :policy_type => String.t(), :result => String.t(), optional(:policy) => String.t() | nil, optional(:mx_host) => String.t() | nil, optional(:receiving_ip) => String.t() | nil, optional(:sending_ip) => String.t() | nil, optional(:details) => String.t() | nil }
Functions
@spec domains(Date.t(), pos_integer()) :: [String.t()]
The policy domains with sessions on day, the busiest first, at most
limit: the domains a report is made for.
@spec prune(non_neg_integer(), Date.t()) :: {non_neg_integer(), non_neg_integer()}
Removes sessions of days before today - keep_days, and policy texts
older than that which no session uses any more. Returns how many of
each were removed.
@spec record(attrs(), DateTime.t()) :: :ok
Records one session (attrs, see attrs/0; policy is the text of
the policy that applied, if any). now gives the day.
@spec result_types() :: [String.t()]
The failure result types Karta records.
The sessions of policy_domain on day, added up: one map per policy,
result, MX host and pair of addresses, with count. policy is the
policy's text (nil without one); details the latest of the group's.