Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I anonymize jsonb fields? #84

Open
josh-levinson opened this issue Nov 3, 2023 · 3 comments
Open

How do I anonymize jsonb fields? #84

josh-levinson opened this issue Nov 3, 2023 · 3 comments

Comments

@josh-levinson
Copy link

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
Copy link
Owner

sunitparekh commented Nov 7, 2023 via email

@josh-levinson
Copy link
Author

josh-levinson commented Nov 13, 2023

@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

@sunitparekh
Copy link
Owner

# 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
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants