Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Database Obfuscation

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
Octocat-spinner-32 omelettes.gemspec
README.md

Omelettes

Basic Usage

gem install omelettes
rails g omelettes:config
rake db:cook

Configuration

After running 'rails g omelettes:config' you will find a config file in 'config/initializers/omelettes.rb'

Omelettes.setup do |config|
  # Ignore tables or columns using strings or regular expressions
  config.ignore_tables = ["schema_migrations", "my_reporting_table", /(a-z_)user/]
  config.ignore_columns = [/(a-z_)*type/i, "name", "city"]

  # Override non-standard table names => classes like this
  #   config.models['admin_users'] = Admin::User

  # Override model specific columns

  User.treat(:nickname).as(:name)
  Person.scramble(:street) {|value| "#{value.reverse}"}

  # Freeze / Ignore columns on specific models
  User.harden(:password)

  # To make a normally "Faker" obfuscated column behave normally, override with :omelette
  User.scramble(:name).as(:omelette)

  # To override the model associated with a specific table, make sure and specify it here:
  config.models['logins'] = User

  # Cleanup data in post
  config.cleanup do 
    Notifications.delete_all
  end
end

By default, the following columns will be Faker-ified (replaced with faker info RATHER than obfuscated using omelettes same-length-and-initial-character)

  • first_name
  • last_name
  • city
  • state
  • country
  • street_address
  • street_name
  • zip_code
  • company_name
  • company
  • email
  • user_name
  • phone
  • contact_phone
  • url
  • website

And the following can be used to 'treat' a column 'as':

  • paragraph
  • paragraphs
  • sentence
  • sentences
  • words

You can also keep model-level configurations within the model itself

class User < ActiveRecord::Base
  treat(:login).as(:user_name)
  ignore :password
end

About

omelettets is obfuscated 'obfuscate'. Omelettes takes strings in your database and replaces them with worlds of the same length and same initial letter.

Something went wrong with that request. Please try again.