Skip to main content

Module trace

Module trace 

Source
Available on crate feature trace only.
Expand description

Recording dialogs as masked, anonymised traces (feature trace).

  • Recorder decorates a Transport (Recorder::wrap) and keeps every exchange that goes through the wrapped transport, masked as it is recorded, so credentials never sit in memory unmasked: PIN, TAN, challenges, subaccounts and binary data other than statements, pain messages and IDs become *; names, product names, amounts and the statements in HIKAZ, HICAZ, HIWPD and HIWDU keep only their shape, values as # in fixed lengths, and every date is moved by the same few days. Identity values get a stand-in. Account identifiers (IBANs, account numbers, user and customer ID, creditor IDs) get aliases numbered in the order they first appear in this trace, from a random start, with no link to the value; the same value gets the same alias everywhere in the trace, IBANs keep country and bank code and valid check digits, and an IBAN’s account part matches the alias of the same account number. The table lives in the recorder’s memory only. References and IDs (booking references, end-to-end, message and payment information IDs, mandate references, system ID, order, VOP and polling IDs) get keyed pseudonyms. Their key is a Salt: Recorder::new draws one and forgets it, so the trace links to no other; traces recorded with the same salt (Recorder::with_salt) give a reference the same pseudonym, while their account aliases stay unrelated. The library writes no salt. It records exactly the dialogs that use the wrapped transport, whatever thread they run on; two recorders never see each other’s traffic. A failed send is recorded with a short, content-free error. It also names the account each request is about (Exchange::account, an alias such as #2 described by a TraceAccount): aliases are numbered in the order the accounts first appear in a HIUPD, and the recorder keeps only keyed hashes of their identifiers (a per-recorder random key that is never written), never the identifiers themselves.
  • Trace is the fixture: one JSON document (TRACE_FORMAT, see Trace::to_json). Trace::from_exchanges anonymises the rest. Trace::summary reads it for a human, one ExchangeSummary per exchange.

Independent of the TRACE event the transport boundary emits for log consumers (mask::EXCHANGE_TARGET).

Clean room: written from the FinTS 3.0 specification and our own masking rules (mask).

Structs§

Client
The client that recorded a trace.
Code
A return code with its text (one element of HIRMG or HIRMS).
Exchange
One request and its response, as wire bytes (ISO 8859-1, with the PIN/TAN envelope), redacted; or the request and the error that ended it.
ExchangeSummary
One exchange of a trace, read for a human: what was asked, what the bank answered. Built by Trace::summary; never fails.
Recorder
Records the exchanges of the transports it wraps. Cheap to clone; clones share the log. Wrap a transport (Recorder::wrap), hand it to the dialogs (with_transport), run the client, then take Recorder::trace.
Salt
The secret key of the pseudonyms: 32 bytes. Never written into a trace. Account identifiers do not depend on it (they get aliases).
Trace
A recorded dialog: the exchanges in order, and the accounts they name.
TraceAccount
An account of a trace, by alias only: what the UPD says about it, never an identifier, a name or the product name.
UnknownSegment
A segment the recorder has no field list for, as the person recording may look at it before deciding whether a trace shows it (Recorder::unknown_segments).

Constants§

SUMMARY_LEGEND
The first line of Trace::summary_table: how to read the lines below.
TRACE_FORMAT
The format of a trace file written by Trace::to_json.

Functions§

outcome_label
Short, content-free summary of a failed send (an HTTP body is never included: it may echo request data); a single line. The kind of an error without its text: the variant, with the HTTP status, the transport kind, the bank’s code or the unreadable segment.
unshape_statement
The binary data of a recorded answer segment made valid again, if the segment holds a shape-masked statement (HIKAZ: MT940, HICAZ: camt.052, HIWPD/HIWDU: MT535/536): each # becomes 1 in an amount and X in text, read with the same field rules as the mask, so the result has the bank’s layout. None for other segments.
unshape_text
A shape-masked text element made valid again: ####,## becomes 1111,11, any other # becomes X.