• Stars
    star
    339
  • Rank 121,191 (Top 3 %)
  • Language
    Ruby
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Universal tool to anonymize database. GDPR (General Data Protection Regulation) data protection act supporting tool.

Build Status Test Coverage

Anonymizer

Anonymizer is a universal tool to create anonymized DBs for projects.

Why is it so important to work with anonymized databases? In the development process, you should never use your production database - it is risky and against the law. Working with a production database in development is risky, because by some mistake, you can might make your clients data available to the whole world. In our world, general data is one of most valuable things and EU tries to protect citizens' general data via the General Data Protection Regulation (GDPR).

Some more quick wins for GDPR? Take a look at our recent blog post.

How does Anonymizer work?

Anonymizer replaces all data in your database by anonymized random data. The most important feature of Anonymizer is data formatting. All generated data is similar to the original data used by real users. The example below shows anonymized data in a Magento 1 sales_flat_quote_address table.

Anonymized data example

Requirements

  • ruby >= 2.2
  • mysql >= 5.6

Supported frameworks

  • Magento 1.9.x / 2.x
  • Pimcore 4 / 5
  • Sylius 1.0.0-beta.2

Of course you can anonymize any other database - this is just an example.

Getting started

Clone this repository and add a configuration file for your first project to the config/project/ directory.

Configuration file

File name

The file name reflects the anonymized database's name. For example, if you need to anonymize a db dump named example.sql.gz, the configuration file should be named example.json.

Basic configuration

Project type

Project configuration files always have an extended type. In the project configuration file, you have to set the type and basic_type which is connected with the supported framework. Only framework configuration files use the basictype.

Available basic types

  • custom
  • magento_1_9
  • magento_2_0
  • pimcore_4
  • pimcore_5
  • sylius

Change anonymized file's name

The anonymized dump is given the same name as the original database dump file. If you want to change this name, you can set the key random_string in configuration file - the value of this key will be added to end of the filename. In the example below, the output file will be named example_ba74a64a152b84ec004d03caba15ba95.sql.gz.

Example

{
    "type": "extended",
    "basic_type": "magento_1_9",
    "random_string": "ba74a64a152b84ec004d03caba15ba95",

Database dump location

Anonymizer can work with both locally and remotely stored database dumps. Database dumps from remote servers are downloaded by rsync.

Working with local database dump

In the example below, the database dump file is in the /path/to/database/dump/ directory.

"dump_server": {
    "host": "",
    "port": "",
    "user": "",
    "path": "/path/to/database/dump/"
}

Working with remote database dump

In the example below, the database dump file is stored on a remote server with an IP address of 1.2.3.4 and ssh port of 5022. The ssh user's name is anonymizer, the directory on remote host with the database dump is /path/to/database/dump/. In this case, let's assume that we need to add --rsync-path=\"sudo rsync\" option to our rsync dump download command.

"dump_server": {
    "host": "10.15.4.254",
    "user": "anonymizer",
    "port": "5022",
    "passphrase": "",
    "path": "/media/drbd0/backup/sqldump/sqldump",
    "rsync_options": "--rsync-path=\"sudo rsync\""
}

Tables to anonymization

Anonymizer can replace the original data by anonymized entries or truncate the data in the destination table.

Available types of data

Simple types
  • firstname
  • lastname
  • login
  • email
  • telephone
  • company
  • street
  • postcode
  • city
  • full_address
  • vat_id
  • ip
  • quote
  • website
  • iban
  • json
Special types
  • uniq_email - unique email address, because of bug in mysql, anonymizer can't generate uniq email address based on email and some uniqeu value form UUID mysql methiod
  • uniq_login - unique login
  • regon - Polish REGON number with validation
  • pesel - Polish PESEL number with validation

How to replace data in a table?

In the example below, data in the user_address table will be replaced by new, anonymized data. The example database contains a user_address table with the following columns - firstname, lastname, postcode, address, city, email, phone, company, vat_id. We will replace all columns' contents with some valid data, consistent with its previous type.

"tables": {
    "user_address": {
        "firstname": {
            "type": "firstname",
            "action": "update"
        },
        "lastname": {
            "type": "lastname",
            "action": "update"
        },
        "postcode": {
            "type": "postcode",
            "action": "update"
        },
        "address": {
            "type": "street",
            "action": "update"
        },
        "city": {
            "type": "city",
            "action": "update"
        },
        "email": {
            "type": "email",
            "action": "update"
        },
        "phone": {
            "type": "telephone",
            "action": "update"
        },
        "company": {
            "type": "company",
            "action": "update"
        },
        "vat_id": {
            "type": "vat_id",
            "action": "update"
        }
    }
}

How to truncate data in a table?

In the example below, the data in the log_customer table will be truncated.

"tables": {
    "log_customer": {
        "only_truncate": {
            "action": "truncate"
        }
    }
}

How to empty only selected columns in a table?

In the example below we will empty data in column with configuration values, keeping other columns intact.

"tables": {
    "some_configuration_table": {
        "config_value": {
            "action": "empty"
        }
    }
}

How to set static value to a column?

In below example value PLN will be assigned to column base_currency for all users.

"tables": {
    "users": {
        "base_currency": {
            "action": "set_static",
            "value": "PLN"
        }
    }
}

How to use Anonymizer with Magento EAV?

Anonymizer can also work with Magento's EAV model. In the example below, the customer attribute about_me in the customer_entity_text table will be replaced with a random phrase.

"tables": {
    "customer_entity_text": {
        "value": {
            "action": "eav_update",
            "attributes": [
                {
                    "code": "about_me",
                    "type": "quote",
                    "entity_type": "customer"
                }
            ]
        }
    }
}

How to work with JSON data

Anonymizer can now update values of JSON encoded data. In below example we anonymize json stored in additional_data column. You should familiarize with MySQL JSON path expressions.

{ "id": 123, "user": { "first_name": "John", "last_name": "Smith", "phone": "123-456-789" }, (...) }
"tables":{
    "subscriptions":{
        "additional_data":{
            "action":"json_update",
            "fields":[
                {
                    "path":"$.user.first_name",
                    "type":"firstname"
                },
                {
                    "path":"$.user.last_name",
                    "type":"lastname"
                },
                {
                    "path":"$.user.phone",
                    "type":"telephone"
                }
            ]
        }
    }
}

How to run custom queries

Anonymizer can run custom, row queries before and after anonymization process. In the example below, the anonymizer runs two queries before and one after.

"tables": {
},
"custom_queries": {
    "before": [
        "DELETE FROM some_column WHERE date > '2019-12-25'",
        "INSERT INTO some_column2 SET table = 'value'"
    ],
    "after": [
        "INSERT INTO some_column SET name = 'admin', pass = '1234567890'",
    ]
}

Example configuration file

{
    "type": "extended",
    "basic_type": "magento_1_9",
    "random_string": "ba74a64a152b84ec004d03caba15ba95",
    "dump_server": {
        "host": "10.15.4.254",
        "user": "anonymizer",
        "port": "5022",
        "passphrase": "",
        "path": "/media/drbd0/backup/sqldump/sqldump",
        "rsync_options": "--rsync-path=\"sudo rsync\""
    }
    "tables": {
        "user_address": {
            "firstname": {
                "type": "firstname",
                "action": "update"
            },
            ...
        },
        "log_customer": {
            "only_truncate": {
                "action": "truncate"
            }
        },
        "customer_entity_text": {
            "value": {
                "action": "eav_update",
                "attributes": [
                    {
                        "code": "about_me",
                        "type": "quote",
                        "entity_type": "customer"
                    }
                ]
            }
        },
        "subscriptions":{
            "additional_data":{
                "action":"json_update",
                "fields":[
                    {
                        "path":"$.user.first_name",
                        "type":"firstname"
                    },
                    {
                        "path":"$.user.last_name",
                        "type":"lastname"
                    },
                    {
                        "path":"$.user.phone",
                        "type":"telephone"
                    }
                ]
            },
            "comment": {
                "type": "quote",
                "action": "update"
            }
        }
    }

How to run the anonymization process

Configuration file for environment

Before you run anonymizer you should add configuration file. Copy sample config file from config/env/sample.yml to config/env/<env_name>.yml

RUBY_ENV=<env_name> bundle exec rake project:anonymize[example]

Development

Build environment

Run development docker environment using the command below:

docker-compose -f dev/docker/docker-compose.dev.yml up

How to run the tests

On docker environment run the commands:

bundle install
bundle exec rspec spec/

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Licensing

The code featured in this project is licensed under MIT license.

About Authors

Divante-logo

We are a Software House from Europe, existing from 2008 and employing about 150 people. Our core competencies are built around Magento, Pimcore and bespoke software projects (we love Symfony3, Node.js, Angular, React, Vue.js). We specialize in sophisticated integration projects trying to connect hardcore IT with good product design and UX.

We work for Clients like INTERSPORT, ING, Odlo, Onderdelenwinkel or CDP, the company that produced The Witcher game. We develop two projects: Open Loyalty - loyalty program in open source and Vue.js Storefront.

We are part of the OEX Group which is listed on the Warsaw Stock Exchange. Our annual revenue has been growing at a minimum of about 30% year on year.

Visit our website Divante.co for more information.

More Repositories

1

microservices-book

"Microservices Architecture for eCommerce" is an Open Source Book on Microservices and Headless eCommerce. Feel invited to contribute! Read online or download a PDF
JavaScript
376
star
2

storefront-integration-sdk

If You like to integrate Vue Storefront - PWA for eCommerce with 3rd party platform, use this SDK
JavaScript
138
star
3

woocommerce2vuestorefront

This is WooCommerce to Vue Storefront data bridge. Harness the power of Progressive Web Apps for Your Woo Commerce shop!
JavaScript
134
star
4

coreshop-vsbridge

CoreShop Vue Storefront integration - first Progressive Web App (PWA) framework for Pimcore
PHP
72
star
5

magento2-rapid-theme

Divante Rapid Theme for Magento 2. More information http://go.divante.co/divante-for-fashion/
CSS
66
star
6

shopware2vuestorefront

First Progressive Web App for Shopware 6. Made with ❀️ by Vue Storefront
JavaScript
59
star
7

magento1-vsbridge

Run the Progressive Web App (PWA) on top of Magento 1.9. This is a Vue Storefront bridge for Magento 1.x. MIT License
PHP
57
star
8

spartacus-capybara

SAP Spartacus Theme based on https://storefrontui.io look and feel and design system. Headless storefront solution for Hybris. Always Open Source, MIT license. Made with πŸ’™ by Divante
TypeScript
46
star
9

pimcore2vuestorefront

Project has been moved ->
JavaScript
40
star
10

next

Vue Storefront Next is R&D branch of Vue Storefront.
TypeScript
40
star
11

pimcore-magento2-bridge

Pimcore module for Magento 2 integration
PHP
35
star
12

magento2-review-api

Long awaited Magento2 API for reviews!
PHP
31
star
13

pimcore-graphql

Create Your own GraphQL API with admin panel based on Pimcore
PHP
31
star
14

magento2-pimcore-bridge

Magento 2 module for Pimcore integration.
PHP
31
star
15

bigcommerce2vuestorefront

This is a Big Commerce 2 Vue Storefront bridge based on https://github.com/DivanteLtd/vue-storefront-integration-boilerplate
JavaScript
23
star
16

magento1-vsbridge-indexer

This is an official, native Vue Storefront data indexer for Magento 1.9
PHP
18
star
17

magento2-module-groupped-products-manager

Magento 2 Module "Grouped Products Manager" adds new features for grouped products
PHP
16
star
18

pimcore5-notifications

Notifications bundle for pimcore 5
PHP
16
star
19

magento2-rapid-uikit

Magento 2 Divante Uikit Module. More information http://go.divante.co/divante-for-fashion/
HTML
13
star
20

magento2-vsbridge-pagebuilder

PHP
13
star
21

pimcore4-magento2-connector

This is a deprecated repository. Please visit https://go.divante.co/pimcore-magento/ for newest information.
PHP
12
star
22

orocommerce-elasticsearch-bundle

PHP
11
star
23

magento2-external-checkout

The project is now maintained by VENDIC: https://github.com/Vendic/magento2-external-checkout
PHP
11
star
24

pimcore5-clipboard

Pimcore 5 Clipboard Bundle gives you the possibility to shelve your objects into a separated area and perform chosen actions only on these separated objects - without changing anything in your project structure!
PHP
11
star
25

pimcore-translation-bundle

PHP
10
star
26

salesforce-cc-graphql-bridge

Salesforce Commerce Cloud GraphQL bridge (based on sfcc-sample-apps)
TypeScript
10
star
27

pimcore-devkit

Set of tools that helps developing Pimcore applications
PHP
9
star
28

pimcore-elasticsearch-plugin

Flexible ElasticSearch Plugin for Pimcore - now with DSL!
PHP
9
star
29

vue-storefront-simple-api

Minimalistic API implementation for Vue Storefront.
Shell
8
star
30

jquery-validation-polish

Polish methods for jQuery validation
JavaScript
8
star
31

headless-security.org

This is an Open Source repository of the Best Practices for Headless app development brought to you by the Vue Storefront Community and the partners
CSS
8
star
32

magento2-vsbridge

Vue Storefront tools for Magento2 - optional package improving data sync
PHP
8
star
33

vsf-mobile-wrapper-ios

iOS wrapper for the Vue Storefront to provide the PWA with all the iOS missing features like push notifications capabilities
Swift
7
star
34

pimcore5-user-tracking

GDPR plugin for Pimcore 5
PHP
7
star
35

pimcore-helm-chart

Helm chart example for pimcore
PHP
6
star
36

magento-open-loyalty

Integration between OpenLoyalty system and Magento
PHP
6
star
37

pimcore-notifications

Notifications plugin for Pimcore
PHP
6
star
38

orocommerce-ga

OroCommerce - Google Analytics and Google Tag Manager
PHP
6
star
39

Elastics

Magento 2.x catalog search with Elasticsearch
PHP
5
star
40

pimcore-scheduled-export

Scheduled Export lets you run ordinary grid exports in background.
PHP
5
star
41

vue-storefront-starter

This is a WIP boilerplate to be used for new Vue Storefront websites. Please don't use it until it will be ready ;)
5
star
42

MultiWishlist

Magento 1.x module that allows you to add multiple wishlists. Now you can marge, copy and move products between wishlists.
PHP
5
star
43

magento2-module-topbar

Module destiny is to write tests in MTF (Magento Testing Framework).
PHP
4
star
44

pwa-book

4
star
45

pimcore-workflow-dashboard

Dashboard for Pimcore 5 Workflow
PHP
4
star
46

pimcore-document-copier

PHP
4
star
47

pimcore-google-login

Allows using google credentials for logging into Pimcore's admin panel
PHP
4
star
48

apparently

TypeScript
4
star
49

backend-user-wrapper

Wrapper for Pimcore's User Model
PHP
3
star
50

magento1-vsbridge-client

JavaScript
3
star
51

pimcore-contact-form

PHP
3
star
52

pimcore-class-locker

PHP
3
star
53

Validation-plugin

Forms validation for Magento & jQuery - with customizable settings on data-* attributes based on jQuery Validation Plugin.
JavaScript
3
star
54

pimcore-classification-tree

Classification Tree for Pimcore 5
PHP
3
star
55

LiveEditor

Magento 2 module which allows user do some dynamic editings of Magento pages (category, product, cms blocks) in live ajax editor.
PHP
3
star
56

php-magento2-swagger

PHP
3
star
57

pimcore5-docker

3
star
58

orocommerce-cookie-consent-bundle

PHP
2
star
59

magento1-external-checkout

PHP
2
star
60

spartacus-localized-routing

Example implementation of localized routing
TypeScript
2
star
61

pimcore-enrichment-progress

Pimcore Enrichment Progress Bundle
PHP
2
star
62

pimcore-docker-php-fpm

2
star
63

Manufacturer

This Magento 1.x module allows to add additional options to product attribute 'manufacturer'.
PHP
2
star
64

varnish-docker

Docker with Varnish Cache
VCL
2
star
65

magento2-gtm

PHP
2
star
66

CustomerLog

This Magento 1.x module raports all changes made by customer. Could be used for example for GIODO compilance
PHP
2
star
67

capistrano-pimcore

Pimcore plugin for capistrano
Ruby
2
star
68

AdSection

Magento 1.x module that allows you to add custom banner sections in any XML-layout block
PHP
2
star
69

vue-storefront-community

The driving force behind the various VueStorefront and Storefront UI projects is without a doubt its community. This repository contains information on everything that has to do with you, the community.
2
star
70

pimcore-coding-standards

Coding standards rulesets for Pimcore 4 and Pimcore 5
2
star
71

pimcore-mysql-object-search

Similar to Pimcore's Advanced Object Search, but does not need Elasticsearch
PHP
1
star
72

pimcore-auto-import

Auto Import runs Import Definitions automatically on created assets
PHP
1
star
73

vsf-pagebuilder

1
star
74

DivanteAdventure

PHP
1
star
75

pimcore-asset-unicode-name

PHP
1
star
76

connector-magento-module-rest-api-client

Connector Client Magento 1 Module REST-API
PHP
1
star
77

woohoolabs-yin-bundle

PHP
1
star
78

pimcore-workflow-validation

Additional validation for Pimcore workflows
PHP
1
star
79

svelte-graphcms

POC based on SvelteKit and GraphCMS
Svelte
1
star
80

PersonalReceipt

This Magento 1.x module allows to add new shipping method - personal receipt. In this method, you can add several pickup locations, by seperate them with "|" sign.
PHP
1
star
81

CodFee

This Magento 1.x module extends "Cash on delivery" payment method, to manage rates per delivery type.
PHP
1
star
82

woocommerce2vuestorefront-api

1
star
83

capistrano-pimcore5

Capistrano plugin for Pimcore 5
Ruby
1
star
84

pimcore-object-fields-permissions

JavaScript
1
star