Anonymizing data
ibm-bai-utils.jslt in a custom JSLT file that is referenced in a
transformer.
Input obj:
The examples in this section use the following input object:
{
"id" : "w23q7ca1-8729-24923-922b-1c0517ddffjf1",
"firstName" : "John",
"lastName" : "Doe",
"personal.ssn" : "999-999-999",
"personal.id" : "9999999",
"maritalStatus": "single"
}
Obfuscating data with stars
In obfuscate-stars-regex(regex, obj) you can replace the property value with
stars *.
Replacing the property value with stars * preserves the length of the replaced
values. All the object properties from obj that match the regular expression
regex is updated. This is a non reversible update.
Example 1: Single property
Transformer:
import "ibm-bai-utils.jslt" as ie
{
"displayName" : .firstName + " " + .lastName,
} + ie:obfuscate-stars-regex("personal.ssn",.)
Result:
{
"id" : "w23q7ca1-8729-24923-922b-1c0517ddffjf1",
"firstName" : "John",
"lastName" : "Doe",
"personal.ssn" : "***-***-***",
"personal.id" : "9999999",
"maritalStatus" : "single",
"displayName" : "John Doe"
}
Example 2: Multiple properties (single regexp)
Transformer:
import "ibm-bai-utils.jslt" as ie
{
"displayName" : .firstName + " " + .lastName,
} + ie:obfuscate-stars-regex("personal.*",.)
Result:
{
"id" : "w23q7ca1-8729-24923-922b-1c0517ddffjf1",
"firstName" : "John",
"lastName" : "Doe",
"personal.ssn" : "***-***-***",
"personal.id" : "*******",
"maritalStatus" : "single",
"displayName" : "John Doe"
}
Example 3: Multiple regexp
Transformer:
import "ibm-bai-utils.jslt" as ie
{
"displayName" : .firstName + " " + .lastName,
} + ie:obfuscate-stars-regex("personal.*|maritalStatus",.)
Result:
{
"id" : "w23q7ca1-8729-24923-922b-1c0517ddffjf1",
"firstName" : "John",
"lastName" : "Doe",
"personal.ssn" : "***-***-***",
"personal.id" : "*******",
"maritalStatus" : "******",
"displayName" : "John Doe"
}
Hashing data with SHA-256
In obfuscate-sha256-regex(regex, obj) you can replace the matching property
value with the result of the sha-256 hash value. All object properties from the
obj that match the regular expression regex are updated. It does
not preserve the length of the replaced values. This is a non-reversible update of the value.
Example
Transformer:
import "ibm-bai-utils.jslt" as ie
{
"displayName" : .firstName + " " + .lastName,
} + ie:obfuscate-sha256-regex("personal.*",.)
{
"id" : "w23q7ca1-8729-24923-922b-1c0517ddffjf1",
"firstName" : "John",
"lastName" : "Doe",
"personal.ssn" : "3360b177c3116188382fbd11cdfa854c2738cf1f785a8dca8bf5fbcc2122619e",
"personal.id" : "b7e60b19dbf9d2bcb319ba66eec45eb9c67f205f537f36ec18f2896f9febb742",
"maritalStatus" : "single",
"displayName" : "John Doe"
}Encoding data with base64
In obfuscate-base64-regex(regex, obj) you can code the matching property value
in base64. All the object properties from obj that match the
regular expression regex are updated. It does not preserve the length of the
replaced values. This is a reversible update of the value.
Example
Transformer:
import "ibm-bai-utils.jslt" as ie
{
"displayName" : .firstName + " " + .lastName,
} + ie:obfuscate-base64-regex("maritalStatus",.)
{
"id" : "w23q7ca1-8729-24923-922b-1c0517ddffjf1",
"firstName" : "John",
"lastName" : "Doe",
"personal.ssn" : "999-999-999",
"personal.id" : "9999999",
"maritalStatus" : "c2luZ2xl",
"displayName" : "John Doe"
}