sunitparekh/data-anonymization

How do I anonymize jsonb fields?

josh-levinson opened this issue · 3 comments

I am just looking for a little guidance here on how to anonymize jsonb fields. The docs are a little unclear to me how I would go about using a Custom Strategy.

What I'm looking to do is basically go into some of our jsonb fields and maintain the keys but replace the values. I don't have a problem writing a custom method to do this, but I don't really know where to put it or how to connect it the data anon DSL.

Does anybody have any examples? Or at least maybe can show me how CustomStrategy examples work so I can add one that could read the data fields and output something?

Thanks so much.

@sunitparekh I have looked at those docs but I don't really understand how to use the custom strategies.

In your example you show

class MyFieldStrategy

    # method anonymize is what required
    def anonymize field
      # write your code here
    end

end

But its not clear a) where this should be, or b) how to call it

Does this go to the end of the anonymization file? In a separate class? I would love to see a real example of how to use this and I imagine so would others

# to keep it simple create your own strategy class in same file
class AbcFieldStrategy

    # method anonymize is what required
    def anonymize field
      # write your code here
    end

end

# use it like just another anonymization strategies for required field
...
 collection 'users' do
        anonymize('your_field').using FieldStrategy::AbcFieldStrategy.new
 end
...