data-anonymization icon indicating copy to clipboard operation
data-anonymization copied to clipboard

MongoDB question : is it possible to anonymise a field in a sub-document

Open sylguyot opened this issue 6 years ago • 1 comments

sample of my json document: { "_id" : ObjectId("5ac34319dc0ef65f31755b60"), ..., identity : { "givenName" : [ "Nicolas" ], "sn" : [ "GUYOT" ], ... } }

I have tried to anonymise identity.givenName with the code:

anonymize('identity.givenName').using FieldStrategy::AnonymizeArray.new(FieldStrategy::RandomFirstName.new)

no errors are thrown but it doesn't change the field value ...

sylguyot avatar May 29 '18 12:05 sylguyot

example subdocument anonymization: in case subdocument is array use: https://github.com/sunitparekh/data-anonymization/blob/master/examples/mongodb_whitelist_dsl.rb#L34

in case of subdocument as hash use: https://github.com/sunitparekh/data-anonymization/blob/master/examples/mongodb_whitelist_dsl.rb#L38

sample JSON document for above is: https://github.com/sunitparekh/data-anonymization/blob/master/sample-data/mongo/plans.json

let me know this solves your problem.

sunitparekh avatar May 30 '18 05:05 sunitparekh