Expand description
Hides what looks like a payment card, an ID number or a one-time code in text an agent is about to read from a web page (the Browser tool’s snapshot, find, wait, log and every other answer).
The Browser tool already refuses to read a password, card or taxpayer-number field (the DOM facts: type, autocomplete, name, label). This is the second line: it works on the text, by shape, so a number a page echoes in plain copy, or one in a field the markup doesn’t name, doesn’t reach the agent, its transcript or the pane’s Log either. It is a mistake guard, not a sandbox: a page can always write a number in a way no pattern knows (digits spelled out, split across elements). It errs toward hiding.
What it hides:
- a payment card number: 13–19 digits (single spaces or dashes between groups allowed) that pass the Luhn check and start like a real card network;
- a U.S. Social Security or taxpayer number written
123-45-6789or123 45 6789; - an IBAN that passes its mod-97 check;
- the digits after a label that says what they are: a card security code (
CVV: 123), a one-time or verification code, a bank account or routing number, an SSN or taxpayer ID; - with
mask_short_text, credential-prefixed tokens and private keys (ghp_…,sk-…,-----BEGIN … PRIVATE KEY-----), throughcrate::redact.
Manual scanning, like redact.rs: nothing in this workspace depends on regex. mask_text is
linear in the length of the text, so a page of digits can’t make it slow.
Constants§
Functions§
- mask_
bounded - The first
max_charscharacters oftextwith everything above hidden, for a caller that shows only the start of a long string. The whole text is masked first and cut after, so no number or token that straddles the cut can show its first characters. - mask_
short_ text mask_text, and credential-prefixed tokens and private keys too. Linear in the length of the text.- mask_
text textwith the numbers above hidden. Text with none of them comes back unchanged. Linear in the length of the text, so it is safe on a whole page.