https://github.com/ferperales/anon_app
https://github.com/ferperales/anon_app
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ferperales/anon_app
- Owner: FerPerales
- Created: 2022-01-07T16:35:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-07T16:52:22.000Z (over 3 years ago)
- Last Synced: 2025-01-16T15:13:58.872Z (4 months ago)
- Language: Ruby
- Size: 146 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Anon app
Demo app to show what [PostgreSQL anonymizer](https://postgresql-anonymizer.readthedocs.io/en/stable/index.html) can do for us
# Requirements
Tested with the following tools:
* ruby 2.7.3
* node 14.18.1
* yarn 1.22.17# Install
```bash
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
# Anonymize data
## Download PostreSQL anonymizer extension
```bash
git clone https://gitlab.com/dalibo/postgresql_anonymizer.git```
## Install extension
**Note:** instructions provided for Mac. See [oficial PostgreSQL docs](https://postgresql-anonymizer.readthedocs.io/en/stable/INSTALL.html) to install in a different OS```bash
export C_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include"
make extension
make install
```## Enable extension for our datatabase
```bash
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;"
```## Access your database console
```bash
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