Standard transformers
Standard transformers are ready-to-use methods that require no customization and perform with just as little as parameters input. Below you can find an index of all standard transformers currently available in Greenmask.
Transformer names
Transformer names are case-sensitive and written in PascalCase, exactly as greenmask list-transformers prints them. A name such as random_email or nullify fails validation with transformer not found. The table maps common search terms to the actual transformer names:
| You are looking for | Transformer name |
|---|---|
| nullify, set to NULL | SetNull |
| random text | RandomString, RandomWord, RandomSentence, RandomParagraph |
| random email | RandomEmail |
| hash | Hash |
| shift a date (date noise) | NoiseDate |
| random IP address | RandomIp |
| constant value | Replace |
Applying transformers in the config
Transformers are set per table under dump.transformation. Each table entry has schema, name and a transformers list; each transformer has a name and params:
dump:
transformation:
- schema: "public"
name: "account"
transformers:
- name: "RandomEmail"
params:
column: "email"
engine: "hash"
- name: "RandomString"
params:
column: "login"
min_length: 8
max_length: 16
- name: "RandomSentence"
params:
column: "bio"
- name: "Hash"
params:
column: "external_id"
function: "sha256"
- name: "NoiseDate"
params:
column: "birth_date"
max_ratio: "1 year"
truncate: "day"
- name: "RandomIp"
params:
column: "last_login_ip"
subnet: "10.0.0.0/8"
- name: "SetNull"
params:
column: "notes"
See Configuration for the rest of the dump section.
The keep_null parameter
keep_null controls what happens when the original value is NULL:
true— theNULLis left as is and nothing is generated for this row.false— the transformer generates a value for the row as if the original were notNULL.
Non-NULL values are transformed either way. Transformers that support keep_null and its default:
| Transformers | Default |
|---|---|
| RandomBool, RandomChoice, RandomDate, RandomUnixTimestamp, RandomEmail, RandomFloat, RandomInt, RandomNumeric, RandomString, RandomUuid, HashedPassword, Replace, Json | true |
| RandomLatitude, RandomLongitude, RandomMonthName, RandomYearString, RandomDayOfWeek, RandomDayOfMonth, RandomCentury, RandomTimezone, RandomDomainName, RandomURL, RandomUsername, RandomPassword, RandomWord, RandomSentence, RandomParagraph, RandomCCType, RandomCCNumber, RandomCurrency, RandomAmountWithCurrency, RandomPhoneNumber, RandomTollFreePhoneNumber, RandomE164PhoneNumber | true |
RandomPerson, RandomCompany (set per item in columns) | true |
RealAddress (set per item in columns) | false |
Transformers without keep_null handle NULL in a fixed way:
Hash,NoiseDate,NoiseFloat,NoiseInt,NoiseNumeric,MaskingandRegexpReplacealways leaveNULLunchanged.RandomIpalways generates a value, also forNULL.Dictcan mapNULLlike any other value, see Dict.SetNullalways writesNULL.
All standard transformers
- Cmd — transforms data via external program using
stdinandstdoutinteraction. - Dict — replaces values matched by dictionary keys.
- Hash — generates a salted hash of the text value.
- HashedPassword — replaces a password hash with a bcrypt hash of one known password.
- Masking — masks a value using one of the masking behaviors depending on your domain.
- NoiseDate — randomly adds or subtracts a duration within the provided ratio interval to the original date value.
- NoiseFloat — adds or subtracts a random fraction to the original float value.
- NoiseNumeric — adds or subtracts a random fraction to the original numeric value.
- NoiseInt — adds or subtracts a random fraction to the original integer value.
- RandomBool — generates random boolean values.
- RandomChoice — replaces values randomly chosen from a provided list.
- RandomDate — generates a random date in a specified interval.
- RandomFloat — generates a random float within the provided interval.
- RandomInt — generates a random integer within the provided interval.
- RandomString — generates a random string using the provided characters within the specified length range.
- RandomUuid — generates a random unique user ID.
- RandomLatitude — generates a random latitude value.
- RandomLongitude — generates a random longitude value.
- RandomUnixTimestamp — generates a random Unix timestamp.
- RandomDayOfWeek — generates a random day of the week.
- RandomDayOfMonth — generates a random day of the month.
- RandomMonthName — generates the name of a random month.
- RandomYearString — generates a random year as a string.
- RandomCentury — generates a random century.
- RandomCompany — generates a random company.
- RandomTimezone — generates a random timezone.
- RandomEmail — generates a random email address.
- RandomUsername — generates a random username.
- RandomPassword — generates a random password.
- RandomDomainName — generates a random domain name.
- RandomURL — generates a random URL.
- RandomMac — generates a random MAC addresses.
- RandomIp — generates a random IPv4 or IPv6 addresses.
- RandomWord — generates a random word.
- RandomSentence — generates a random sentence.
- RandomParagraph — generates a random paragraph.
- RandomCCType — generates a random credit card type.
- RandomCCNumber — generates a random credit card number.
- RandomCurrency — generates a random currency code.
- RandomAmountWithCurrency — generates a random monetary amount with currency.
- RandomPerson — generates a random person data (first name, last name, etc.)
- RandomPhoneNumber — generates a random phone number.
- RandomTollFreePhoneNumber — generates a random toll-free phone number.
- RandomE164PhoneNumber — generates a random phone number in E.164 format.
- RealAddress — generates a real address.
- RegexpReplace — replaces a string using a regular expression.
- Replace — replaces an original value by the provided one.
- SetNull — sets
NULLvalue to the column.