Masking
The eleven masking rules, why they are deterministic, how they respect column constraints, and the honest limit of free text.
Masking happens in transit — values are replaced between reading them from the source and writing them to the target, so nothing unmasked is ever written to disk.
The rules
| Rule | Produces | Example output |
|---|---|---|
email | An address at example.invalid | user_0b1343bf051a1e1c@example.invalid |
phone | A 555 number, reserved for fiction | +15550563127 |
first_name | A name from a fixed list | Riley |
last_name | A name from a fixed list | Kowalski |
name | First and last together | Kai Park |
address | A street address | 545 Placeholder St |
govid | Uppercase hex — for SSNs, cards, tax IDs | 00D1AF1CBD6 |
ip | An address in the TEST-NET-3 range | 203.0.113.68 |
secret | The literal REDACTED | REDACTED |
redact | Nothing — the value is dropped | NULL, or '' when NOT NULL |
keep | The original value, unchanged | — |
Those outputs are real, at seed safeslice.
Determinism
The same input and the same seed always produce the same replacement. That is what keeps a slice usable: a customer’s email appearing in users, invoices and audit_log masks identically in all three, so every join still works.
Change the seed and every value changes. Share the seed across a team and everyone’s snapshots agree on what a given customer was renamed to.
Constraint awareness
Masking has to produce a value the column will actually accept:
- Key columns are never masked. Rewriting a primary or foreign key would destroy the referential integrity the slice exists to preserve.
NOT NULLis respected.redacton a NOT NULL column writes an empty string rather than NULL.varchar(n)is not overflowed. Output is clamped to the declared length.- Types are matched. An
integercolumn receives an integer, anumerica decimal, auuida well-formed UUID, aninetan address. UNIQUEis retried. A collision is re-generated with a salt until the value is free. A rule that cannot produce distinct values —redacton a NOT NULL unique column — is refused before a table is read, rather than failing halfway through a load.- Unmaskable types are refused. A geometry, array or enum column cannot take a fake string, so Safeslice stops and asks you to set
keeporredactinstead of corrupting the row.
Free text is the limit
No regular expression reliably scrubs a support ticket that happens to quote a customer’s address, and Safeslice does not pretend otherwise. Columns it cannot judge are surfaced for a decision, and strict mode — on by default — refuses to run while any remain unreviewed.
That refusal is the feature. Silently passing an unreviewed text column through is exactly how personal data reaches a laptop.