Karta.Reports.TLSRPT (Karta v1.0.0)

Reading a TLS-RPT report (RFC 8460 §4): the JSON a mail server sends about how its connections to a domain's servers went, as plain data.

Hostile input. The document is at most 8 MiB (the caller bounds a compressed one while unpacking it), has at most 200 policies and is read with nothing looked up. Of the failure details at most 1,000 are kept in all, the first ones; failures_truncated says that more were sent, and every policy's summary counts stay as the reporter gave them. A policy string has at most 100 lines and a policy at most 100 MX hosts; every text is made valid UTF-8, free of control characters and at most 255 characters; counts are whole numbers below 10^12. A document with more policies, or missing what RFC 8460 requires (organization-name, report-id, date-range and policies), is refused rather than half-read. Keys the RFC does not name are ignored.

The result is a map: :org_name, :email, :report_id, :date_begin, :date_end, :domain (the policy domain when every policy names the same one, else nil) and :details, whose string keys are what the report page shows and Karta.Reports stores.

Summary

Functions

The most JSON bytes read (8 MiB).

Reads the JSON of a report: {:ok, report} or {:error, reason}: :too_large, :invalid_json, :invalid_report (a required key is missing or has the wrong shape), :invalid_date or :too_many_policies.

Functions

max_bytes()

@spec max_bytes() :: pos_integer()

The most JSON bytes read (8 MiB).

parse(json)

@spec parse(binary()) :: {:ok, map()} | {:error, atom()}

Reads the JSON of a report: {:ok, report} or {:error, reason}: :too_large, :invalid_json, :invalid_report (a required key is missing or has the wrong shape), :invalid_date or :too_many_policies.