Function: redactSharedData
Goal: Redact Sensitive Data prior to sharing.
-
This function redactSharedData will remove sensitive data and write "safe" redacted records.
-
Requires a metadata bucket, a source bucket, and a destination bucket aliased to "aws_bkt" in mode read+write.
-
Will operate on all documents where doc.type === "master_profile".
-
Will create redacted documents in real-time of doc.type === "shared_profile".
-
The destination bucket can be shared (or replicated via XCDR to a business partner).
function OnUpdate(doc, meta) {
// only process our profile documents
if (doc.type !== "master_profile") return;
// aws_bkt is a bucket alias to the target bucket to replicate to AWS via
// XCDR. Write the minimal (non-sensitive) profile doc to the bucket for AWS.
aws_bkt["shared_profile::"+doc.id] = {
"type": "shared_profile",
"first_name": doc.first_name,
"id": doc.id,
"basic_profile": doc.basic_profile,
"timezone": doc.timezone
};
}
INPUT: KEY master_profile::80927079070
{
"type": "master_profile",
"first_name": "Peter",
"last_name": "Chang",
"id": 80927079070,
"basic_profile": {
"partner_id": 80980221,
"services": [
{
"music": true
},
{
"radio": true
},
{
"video": false
}
]
},
"sensitive_profile": {
"ssn": "111-11-1111",
"credit_card": {
"number": "3333-333-3333-3333",
"expires": "01/09",
"ccv": "111"
}
},
"address": {
"home": {
"street": "4032 Kenwood Drive",
"city": "Boston",
"zip": "02102"
},
"billing": {
"street": "541 Bronx Street",
"city": "Boston",
"zip": "02102"
}
},
"phone": {
"home": "800-555-9201",
"work": "877-123-8811",
"cell": "878-234-8171"
},
"locale": "en_US",
"timezone": -7,
"gender": "M"
}
UPDATED/OUTPUT: KEY shared_profile::80927079070
{
"type": "shared_profile",
"first_name": "Peter",
"id": 80927079070,
"basic_profile": {
"partner_id": 80980221,
"services": [
{
"music": true
},
{
"radio": true
},
{
"video": false
}
]
},
"timezone": -7
}