Expand description
Masking of FinTS messages for logs and tooling.
Every message that crosses the transport boundary (request and response)
is logged through mask_for_log. The function is segment-aware: it
tokenizes with codec::wire (so ? escapes and @len@ binary
data are respected), looks up per segment code and version which data
elements hold credentials or identifiers, and writes the message again
with those elements replaced.
§The rule
- A masked text element becomes one
*per character: the length class stays visible, the value does not. (No prefix or suffix of an IBAN is kept.) PIN and TAN are always eight stars: their length says something. - Names and amounts are shown as a fixed shape (
shape): a name is eight#whatever its length, an amount is#,##whatever its size and its decimals. Holder and user names (HIUPA 4, HIUPD 6 6 and 7), product names (HIUPD 6 8, HISAL 2), the extensions (HIUPA 5, HIUPD 6 12) and every amount in HISAL and HIUPD 6. - A binary element (MT940, camt, MT535/536, keys, certificates) becomes
@<original length>@<masked>in the log and@n@+nstars inredact_credentials. Binary data is never shown. Only the trace recorder (mask_for_recorder) shows statements as their shape, field by field, with the length of the shaped data in@len@: a trace is a reviewed artefact, the log goes to any sink, so the log stays the more masked of the two. - HNVSD carries the signed segments as binary data; its contents are masked recursively and written in place, so the log shows the whole dialog.
- Masked with stars in the log, with a stand-in in a trace
(
pseudonym: equal values give equal stand-ins; a counterparty’s IBAN, a creditor ID and a reference have one fixed form each). In a trace every date is moved by the same number of days (dates). A per-trace alias for the account identifiers: user ID / customer ID (HKIDN, HNSHK, HNVSK, HIUPA, HIUPD); account number and IBAN in every account group of HKSAL/HISAL, HKKAZ/HIKAZ, HKCAZ/HICAZ, HKWPD, HKWDU, HKSPA/HISPA, HKTAN and HIUPD. A keyed pseudonym for the system ID (HKIDN, HNSHK, HNVSK, HISYN). Always starred: PIN and TAN (HNSHA), subaccounts, the TAN challenge (HITAN). BIC and bank code are kept. - Payment orders (HKCCS, HKIPZ, HKIPS, HKVPP, HKVPA and their answers
HIIPZ, HIIPS, HIVPP): the debtor account (KTI), the instant order ID,
the payee IBAN in HIVPP and the binary VOP-ID and polling ID are
starred in the log; in a trace the accounts get aliases, the IDs
pseudonyms; the VoP touchdown
point and the payee’s additional information, registered name, other
ID and RVNA reason are starred; the explanation text of HIVPP is shown
as its shape. The pain.001/pain.002 messages are binary and so starred
in the log; the trace recorder shows them as their shape (
shape: markup, status and service level codes and currency stay; names, BICs, dates, remittance text and amounts do not) with aliases for IBANs, account numbers and creditor IDs and pseudonyms for references. Descriptors, flags, outcome codes and waits are kept. - Segments known to carry only protocol data (envelope, feedback,
parameter segments
HI…S, HKEND, HKSYN, and HKVVB except its product registration, which is starred) are kept; feedback texts have IBAN-like words masked (an alias in a trace). Every other segment is unknown and masked completely except its header (better too much than too little); the recorder can keep the ones a person has looked at (hide_unknown). - Input that does not tokenize is never shown: the log gets only a length.
The function never panics. It is a logging aid, not a security boundary: a bank that sends an identifier in a place the table does not list, inside a known segment, is not caught.
Constants§
- EXCHANGE_
TARGET - Target of the one
TRACEevent the library emits per exchange (success or failure), for callers that record a dialog (e.g. as a replay fixture). It is emitted around theTransportcall, so no transport can skip it.
Functions§
- mask_
for_ log - Masks a message (or the clear text of an HNVSD) for logging. The result
is not wire syntax (binary data are shown as
@n@<masked>). - redact_
credentials - Masks a message like
mask_for_log, but keeps it parseable: binary data are replaced by as many*as they were long, and input that does not tokenize keeps only its separators. Used bydebugbefore it parses a message for display. - redacted_
text redact_credentialsas ISO 8859-1 text: onecharper byte, sotext.chars().map(|c| c as u8)gives the bytes back.