No commit activity in last 3 years
No release in over 3 years
A database anonymizer for Rails 4+
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

DatabaseAnonymizer

Gem Version Dependency Status

A database anonymizer for Rails 4+

Installation

Put this line in your Gemfile:

gem 'database_anonymizer'

Then bundle:

$ bundle

Create config/database_anonymizer/whitelist.yml by:

$ bin/rails generate database_anonymizer:install

Then, only string or text type column table structures are created.

Usage

See below sample config/database_anonymizer/whitelist.yml file.

'User':
# name:
  email:
    anonymized_by: User.anonymize_email
# address:
# tel:
  remarks:
    anonymized_by: nil
# comment:

Asteriskize

if a column is commented out, the column will be replaced by asterisks.

Default asterisks size is 8.

If validate_length_of is present, the number of asterisks size may not be 8. For details, see the method asterisk_length at lib/database_anonymizer/metamorphosis.rb.

Anonymize

If a column needs a specific anonymizer, remove #, and add anonymized_by: Model.anonymize_method. You have to define your own anonymize method.

Do Nothing

If a column don't need to be asteriskized or anonymized, remove #, and add anonymized_by: nil.

Run rake task

Finally, run below rake task:

$ RAILS_ENV=TARGET_ENV bin/rake database_anonymizer:execute

Specification

If RAILS_ENV is production,bin/rake database_anonymizer:execute fails.

Contributing

  1. Fork it ( https://github.com/blp1526/database_anonymizer/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request