Demo app to show what PostgreSQL anonymizer can do for us
Tested with the following tools:
- ruby 2.7.3
- node 14.18.1
- yarn 1.22.17
git clone https://github.com/FerPerales/anon_app.git
cd anon_app
bundle install
yarn install
rails db:create
rails db:migrate
rails db:seed
rails server
Go to localhost:3000/users to see the original users data
git clone https://gitlab.com/dalibo/postgresql_anonymizer.git
Note: instructions provided for Mac. See oficial PostgreSQL docs to install in a different OS
export C_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include"
make extension
make install
psql anon_app_development -c "ALTER DATABASE anon_app_development SET session_preload_libraries = 'anon'"
psql anon_app_development -c "CREATE EXTENSION IF NOT EXISTS anon CASCADE;"
psql anon_app_development
Inside your database console, run this:
SELECT anon.init();
SECURITY LABEL FOR anon ON COLUMN users.first_name
IS 'MASKED WITH FUNCTION anon.fake_first_name()';
SECURITY LABEL FOR anon ON COLUMN users.last_name
IS 'MASKED WITH FUNCTION anon.fake_last_name()';
SECURITY LABEL FOR anon ON COLUMN users.street_line1
IS 'MASKED WITH VALUE ''CONFIDENTIAL'' ';
SECURITY LABEL FOR anon ON COLUMN users.street_line2
IS 'MASKED WITH VALUE ''CONFIDENTIAL'' ';
SECURITY LABEL FOR anon ON COLUMN users.zipcode
IS 'MASKED WITH FUNCTION anon.random_zip()';
SECURITY LABEL FOR anon ON COLUMN users.email
IS 'MASKED WITH FUNCTION anon.partial_email(users.email)';
SELECT anon.anonymize_database();
Check localhost:300 again and you will see all data anonymized