Coder Social home page Coder Social logo

masquerade's Introduction

Masquerade logo

Masquerade

This project is ABANDONED. Thanks for your support!

This project has been abandoned. For a better, faster and more maintained alternative, see Smile's gdpr-dump. We have created our own repository for config files for popular Magento 2 extensions, see elgentos/gdpr-dump-magento-2-extensions.

Faker-driven, platform-agnostic, locale-compatible data faker tool

Point Masquerade to a database, give it a rule-set defined in YAML and Masquerade will anonymize the data for you automatically!

Out-of-the-box supported frameworks

  • Magento 2
  • Shopware 6

Customization

You can add your own configuration files in a directory named config in the same directory as where you run masquerade. The configuration files will be merged with any already present configuration files for that platform, overriding any out-of-the-box values.

See the Magento 2 YAML files as examples for notation.

For example, to override the admin.yaml for Magento 2, you place a file in config/magento2/admin.yaml. For example, if you want to completely disable/skip a group, just add this content;

admin:

You can add your own config files for custom tables or tables from 3rd party vendors. Here are a few examples:

To generate such files, you can run the masquerade identify command. This will look for columns that show a hint of personal identifiable data in the name, such as name or address. It will interactively ask you to add it to a config file for the chosen platform.

Partial anonymization

You can affect only certain records by including a 'where' clause - for example to avoid anonymising certain admin accounts, or to preserve data used in unit tests, like this:

customers:
  customer_entity:
    provider: # this sets options specific to the type of table
      where: "`email` not like '%@mycompany.com'" # leave mycompany.com emails alone

Delete Data

You might want to fully or partially delete data - eg. if your developers don't need sales orders, or you want to keep the database size a lot smaller than the production database. Specify the 'delete' option.

When deleting some Magento data, eg. sales orders, add the command line option --with-integrity which enforces foreign key checks, so for example sales_invoice records will be deleted automatically if their parent sales_order is deleted:

orders:
  sales_order:
    provider:
      delete: true
      where: "customer_id != 3" # delete all except customer 3's orders because we use that for testing
    # no need to specify columns if you're using 'delete'      

If you use 'delete' without a 'where', and without '--with-integrity', it will use 'truncate' to delete the entire table. It will not use truncate if --with-integrity is specified since that bypasses key checks.

Magento EAV Attributes

You can use the Magento2Eav table type to treat EAV attributes just like normal columns, eg.

products:
  catalog_product_entity: # specify the base table of the entity
    eav: true
    provider:
      where: "sku != 'TESTPRODUCT'" # you can still use 'where' and 'delete'
    columns:
      my_custom_attribute:
        formatter: sentence
      my_other_attribute:
        formatter: email

  catalog_category_entity:
    eav: true
    columns:
      description: # refer to EAV attributes like normal columns
        formatter: paragraph

Formatter Options

For formatters, you can use all default Faker formatters.

Custom Data Providers / Formatters

You can also create your own custom providers with formatters. They need to extend Faker\Provider\Base and they need to live in either ~/.masquerade or .masquerade relative from where you run masquerade.

An example file .masquerade/Custom/WoopFormatter.php;

<?php

namespace Custom;

use Faker\Provider\Base;

class WoopFormatter extends Base {

    public function woopwoop() {
        $woops = ['woop', 'wop', 'wopwop', 'woopwoop'];
        return $woops[array_rand($woops)];
    }
}

And then use it in your YAML file. A provider needs to be set on the column name level, not on the formatter level.

customer:
  customer_entity:
    columns:
      firstname:
        provider: \Custom\WoopFormatter
        formatter:
          name: woopwoop

Custom Table Type Providers

Some systems have linked tables containing related data - eg. Magento's EAV system, Drupal's entity fields and Wordpress's post metadata tables. You can provide custom table types. In order to do it you need to implement 2 interfaces:

  • Elgentos\Masquerade\DataProcessorFactory is to instantiate your custom processor. It receives table service factory, output object and whole array of yaml configuration specified for your table.

  • Elgentos\Masquerade\DataProcessor is to process various operations required by run command like:

    • truncate should truncate table in provided table via configuration
    • delete should delete table in provided table via configuration
    • updateTable should update table with values provided by generator based on columns definitions in the configuration. See Elgentos\Masquerade\DataProcessor\RegularTableProcessor::updateTable for a reference.

First you need to start with a factory that will instantiate an actual processor

An example file .masquerade/Custom/WoopTableFactory.php;

<?php

namespace Custom;

use Elgentos\Masquerade\DataProcessor;
use Elgentos\Masquerade\DataProcessor\TableServiceFactory;
use Elgentos\Masquerade\DataProcessorFactory;
use Elgentos\Masquerade\Output;
 
class WoopTableFactory implements DataProcessorFactory 
{

    public function create(
        Output $output, 
        TableServiceFactory $tableServiceFactory,
        array $tableConfiguration
    ): DataProcessor {
        $tableService = $tableServiceFactory->create($tableConfiguration['name']);

        return new WoopTable($output, $tableService, $tableConfiguration);
    }
}

An example file .masquerade/Custom/WoopTable.php;

<?php

namespace Custom;

use Elgentos\Masquerade\DataProcessor;
use Elgentos\Masquerade\DataProcessor\TableService;
use Elgentos\Masquerade\Output;

class WoopTable implements DataProcessor
{
    /** @var Output */
    private $output;

    /** @var array */
    private $configuration;

    /** @var TableService */
    private $tableService;

    public function __construct(Output $output, TableService $tableService, array $configuration)
    {
        $this->output = $output;
        $this->tableService = $tableService;
        $this->configuration = $configuration;
    }

    public function truncate(): void
    {
        $this->tableService->truncate();
    }
    
    public function delete(): void
    {
        $this->tableService->delete($this->configuration['provider']['where'] ?? '');
    }
    
    public function updateTable(int $batchSize, callable $generator): void
    {
        $columns = $this->tableService->filterColumns($this->configuration['columns'] ?? []);
        $primaryKey = $this->configuration['pk'] ?? $this->tableService->getPrimaryKey();
        
        $this->tableService->updateTable(
            $columns, 
            $this->configuration['provider']['where'] ?? '', 
            $primaryKey,
            $this->output,
            $generator,
            $batchSize
        );
    }
}

And then use it in your YAML file. A processor factory needs to be set on the table level, and can be a simple class name, or a set of options which are available to your class.

customer:
  customer_entity:
    processor_factory: \Custom\WoopTableFactory
    some_custom_config:
      option1: "test"
      option2: false
    columns:
      firstname:
        formatter:
          name: firstName

Installation

Download the phar file:

curl -L -o masquerade.phar https://github.com/elgentos/masquerade/releases/latest/download/masquerade.phar

Usage

$ php masquerade.phar run --help

Description:
  List of tables (and columns) to be faked

Usage:
  run [options]

Options:
      --platform[=PLATFORM]
      --driver[=DRIVER]      Database driver [mysql]
      --database[=DATABASE]
      --username[=USERNAME]
      --password[=PASSWORD]
      --host[=HOST]          Database host [localhost]
      --port[=PORT]          Database port [3306]
      --prefix[=PREFIX]      Database prefix [empty]
      --locale[=LOCALE]      Locale for Faker data [en_US]
      --group[=GROUP]        Comma-separated groups to run masquerade on [all]
      --with-integrity       Run with foreign key checks enabled
      --batch-size=BATCH-SIZE  Batch size to use for anonymization [default: 500]

You can also set these variables in a config.yaml file in the same location as where you run masquerade from, for example:

platform: magento2
database: dbnamehere
username: userhere
password: passhere
host: localhost
port: porthere

Running it nightly

Check out the wiki on how to run Masquerade nightly in CI/CD;

Building from source

To build the phar from source you can use the build.sh script. Note that it depends on Box which is included in this repository.

# git clone https://github.com/elgentos/masquerade
# cd masquerade
# composer install
# chmod +x build.sh
# ./build.sh
# bin/masquerade

Debian Packaging

To build a deb for this project run:

# apt-get install debhelper cowbuilder git-buildpackage
# export ARCH=amd64
# export DIST=buster
# cowbuilder --create --distribution buster --architecture amd64 --basepath /var/cache/pbuilder/base-$DIST-amd64.cow --mirror http://ftp.debian.org/debian/ --components=main
# echo "USENETWORK=yes" > ~/.pbuilderrc
# git clone https://github.com/elgentos/masquerade
# cd masquerade
# gbp buildpackage --git-pbuilder --git-dist=$DIST --git-arch=$ARCH --git-ignore-branch -us -uc -sa --git-ignore-new

To generate a new debian/changelog for a new release:

export BRANCH=master
export VERSION=$(date "+%Y%m%d.%H%M%S")
gbp dch --debian-tag="%(version)s" --new-version=$VERSION --debian-branch $BRANCH --release --commit

Credits

masquerade's People

Contributors

bad avatar caneco avatar dependabot[bot] avatar erfanimani avatar erikhansen avatar ivanchepurnyi avatar jeroenboersma avatar jknipper avatar johnorourke avatar julesleynaud avatar luksurious avatar matheusgontijo avatar michielgerritsen avatar peterjaap avatar rickkuilman avatar tdgroot avatar tjitse-e avatar vdloo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

masquerade's Issues

Unable to process a line with a primary key set to zero

First at all, thanks for this wonderful project.

I am having an issue with a primary key having the zero value
(It's an existing database, don't ask me how it happens)

How to reproduce

Given the following schema:

CREATE TABLE `my_table` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `label` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
) ENGINE=InnoDB AUTO_INCREMENT=3745 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci

I insert a record with a primary key set to zero:

TRUNCATE my_table;
ALTER TABLE my_table CHANGE id id INT(10) UNSIGNED NOT NULL;
INSERT INTO my_table (id, label) VALUES (0, 'test 0');
INSERT INTO my_table (id, label) VALUES (1, 'test 1');
select * from my_table

If I run the tool with the config below, the entry 0 is not altered:

entry:
  my_table:
    columns:
      label:
        formatter: firstName

Other entry are changed

Best way to share yaml files for extensions?

Now that we've added a try/catch block we can add YAML definitions for tables that don't necessarily have to be present in an install.

In our projects, we include YAML files for all possible extensions we use. If a project doesn't have that table, it'll just skip it now.

I've put a few of those YAML files in the Wiki, see:

What would be the best way to share these? I don't think adding them to Masquerade itself would be wise, since that'll clutter stuff and maybe even introduce unexpected behavior. A separate repo maybe? Keep placing them in the wiki? Any other ideas?

cc @tdgroot @johnorourke @Tjitse-E @erikhansen

Delete action: array to string conversion

Example creditmemo.yaml:

creditmemo:
  sales_creditmemo:
    provider:
      delete: true

Run: php bin/masquerade run --with-integrity

Result:

._ _  _. _ _.    _ .__. _| _
| | |(_|_>(_||_|(/_|(_|(_|(/_
            |
                   by elgentos
                        v0.3.0
PHP Warning:  Invalid argument supplied for foreach() in /Users/tjitse/sites/masquerade/src/Elgentos/Masquerade/Console/RunCommand.php on line 129

Warning: Invalid argument supplied for foreach() in /Users/tjitse/sites/masquerade/src/Elgentos/Masquerade/Console/RunCommand.php on line 129
PHP Notice:  Array to string conversion in /Users/tjitse/sites/masquerade/src/Elgentos/Masquerade/Console/SymfonyOutput.php on line 92

Notice: Array to string conversion in /Users/tjitse/sites/masquerade/src/Elgentos/Masquerade/Console/SymfonyOutput.php on line 92
Deleting records from Array table
PHP Notice:  Array to string conversion in /Users/tjitse/sites/masquerade/src/Elgentos/Masquerade/Console/SymfonyOutput.php on line 92

Notice: Array to string conversion in /Users/tjitse/sites/masquerade/src/Elgentos/Masquerade/Console/SymfonyOutput.php on line 92
Records have been deleted from Array table

Updating [sales_creditmemo_comment]
    0/0 [----->----------------------]   0% < 1 sec Complete

vat formatter not available for all locales

Only for;

  • at_AT
  • bg_BG
  • es_ES
  • fr_BE
  • fr_FR
  • it_IT (vatId)
  • nl_BE
  • nl_NL
  • pl_PL (taxpayerIdentificationNumber)
  • zh_TW

For example, running the en_US locale on magento2 platform now gives an error for quote, customer & order groups.

delete: true gives errors

@johnorourke I just ran into this;

PHP Notice:  Undefined index: columns in phar:///usr/bin/masquerade/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php on line 27
PHP Warning:  Invalid argument supplied for foreach() in phar:///usr/bin/masquerade/src/Elgentos/Masquerade/DataProcessor/DefaultDataProcessorFactory.php on line 27
PHP Notice:  Array to string conversion in phar:///usr/bin/masquerade/src/Elgentos/Masquerade/Console/SymfonyOutput.php on line 92
Deleting records from Array table
In Connection.php line 669:
                                                                               
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
  n your SQL syntax; check the manual that corresponds to your MySQL server v  
  ersion for the right syntax to use near 'as `main`' at line 1 (SQL: delete   
  from `swissup_checkoutfields_values` as `main`)                              
                                                                               
In PDOConnection.php line 72:
                                                                               
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
  n your SQL syntax; check the manual that corresponds to your MySQL server v  
  ersion for the right syntax to use near 'as `main`' at line 1                
                                                                               
In PDOConnection.php line 67:
                                                                               
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i  
  n your SQL syntax; check the manual that corresponds to your MySQL server v  
  ersion for the right syntax to use near 'as `main`' at line 1    

This is the yaml file I'm using; https://github.com/elgentos/masquerade/wiki/Swissup-YAML-file

Any idea?

Split databases compatibility

Haven't tried it yet, but I was wondering if it's possible to run on separate dumps from a split database environment?
There would be 3 dumps:

  • default
  • checkout (quotes)
  • sales

In other words, does it rely on all the usual tables being present?

Custom config files do not seem to be working

Issue: I followed the documentation surrounding how to add custom config values, but masquerade does not seem to find my custom configuration.

My ultimate goal is to completely override the admin.yaml file, as I don't want to masquerade any values in the admin_user table. But I'm first trying to get masquerade to pickup my custom config files.

Steps to reproduce:

  1. Create a config/admin.yaml file with these contents:

    admin:
      admin_user:
        pk: user_id
        columns:
          firstname:
            formatter: firstName
          lastname2:
            formatter: lastName
    
  2. Run masquerade groups

Expected results:

+----------+------------------+---------------------------------------+--------------------+---------------------+
| Platform | Group            | Table                                 | Column             | Formatter           |
+----------+------------------+---------------------------------------+--------------------+---------------------+
| magento2 | admin            | admin_user                            | firstname          | email           |
| magento2 | admin            | admin_user                            | lastname           | lastName            |
| magento2 | admin            | admin_user                            | lastname2          | lastName            |
| magento2 | admin            | admin_user                            | email              | email               |
| magento2 | admin            | admin_user                            | username           | firstName           |
| magento2 | admin            | admin_user                            | password           | password            |
…

Actual results:

+----------+------------------+---------------------------------------+--------------------+---------------------+
| Platform | Group            | Table                                 | Column             | Formatter           |
+----------+------------------+---------------------------------------+--------------------+---------------------+
| magento2 | admin            | admin_user                            | firstname          | firstName           |
| magento2 | admin            | admin_user                            | lastname           | lastName            |
| magento2 | admin            | admin_user                            | email              | email               |
| magento2 | admin            | admin_user                            | username           | firstName           |
| magento2 | admin            | admin_user                            | password           | password            |
…

Screenshot, verifying my setup:

masquerade

Unique customer email addresses not so unique

Sorry for all the issuing lately.

I'm getting the following error when anonymizing the customer_entity table:

Updating customer_entity
   6480/107551 [=>--------------------------]   6%
In Connection.php line 664:
                                                                                                                                     
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[email protected]' for key 'CUSTOMER_ENTITY_EMAIL_WEBSIT  
  E_ID' (SQL: update `customer_entity` set `email` = [email protected], `prefix` = , `firstname` = Ramon, `middlename` = , `lastnam  
  e` = Rice, `suffix` =  where `entity_id` = 6515)

Even though email is set to unique, faker sometimes generates email addresses which have already been used in the same runtime. This probably happens because faker only has so many data that recurrence might happen.

Here are some ideas to fix this issue:

  • Regenerate the value if it's already been used in current runtime (up to x times)
  • Write own Internet formatter
  • Add customer entity_id to email address

Make data random within a set

When updating a row in a table, and setting the firstname, lastname and email address, all three are completely random. This means the email address does not 'match' the name, or username, for example;

user_id	firstname	lastname	email	username	password
1	Jasper	van de Berg	[email protected]	Megan	.3O[&rw/oR^6p

This is, for Magento, in itself not problematic. The only point where it does not match but it should, is where the order data differs from the quote data, which shouldn't occur in a natural environment.

Maybe we can find a way to make this more matching.

"maximum number of steps is not set." in verbose mode

After masquerade silently fails i tried verbose mode to get an idea what happens there, but it does not work for -vv or -vvv

Box Requirements Checker
========================

> Using PHP 7.3.27
> PHP is using the following php.ini file:
  /usr/local/etc/php/php.ini

> Checking Box requirements:
  ......

                                                                                
 [OK] Your system is ready to run the application.                              
                                                                                

[Foreign key constraint checking is off - deletions will not affect linked tables]

._ _  _. _ _.    _ .__. _| _
| | |(_|_>(_||_|(/_|(_|(_|(/_
            |
                   by elgentos
                        v0.3.4
Updating table using the following data
array (
  'processor' => 'Elgentos\\Masquerade\\DataProcessor\\RegularTableProcessor',
  'configuration' => 
  array (
    'pk' => 'user_id',
    'columns' => 
    array (
      'firstname' => 
      array (
        'formatter' => 'firstName',
      ),
      'lastname' => 
      array (
        'formatter' => 'lastName',
      ),
      'email' => 
      array (
        'formatter' => 'email',
        'nullColumnBeforeRun' => true,
        'unique' => true,
      ),
      'username' => 
      array (
        'formatter' => 'firstName',
        'nullColumnBeforeRun' => true,
        'unique' => true,
      ),
      'password' => 
      array (
        'formatter' => 'password',
      ),
    ),
    'name' => 'admin_user',
    'provider' => 
    array (
    ),
  ),
)

Nullifying columns in batches for [admin_user]
 ERROR:                                                                          
 Unable to display the estimated time if the maximum number of steps is not set.

PHP Warning: Wrong COM_STMT_PREPARE response size on masquerade run.

hi, lately i'm finding this error on an attempted run of masquerade to anonymise a magento DB for sandboxing.

i have tried this with a few recent db dumps from the last few months, and they all fail, while i've been using it successfully for a year and a half.

results of a verbose run here:

$ php masquerade.phar run -vvv

Box Requirements Checker
========================

> Using PHP 7.4.19
> PHP is using the following php.ini file:
  /etc/php.ini

> Checking Box requirements:
  ✔ The application requires the version "^7.2" or greater.
  ✔ The application requires the extension "zlib".
  ✔ The package "doctrine/dbal" requires the extension "pdo".
  ✔ The package "illuminate/database" requires the extension "json".
  ✔ The package "illuminate/support" requires the extension "json".
  ✔ The package "nesbot/carbon" requires the extension "json".


 [OK] Your system is ready to run the application.


[Foreign key constraint checking is off - deletions will not affect linked tables]
PHP Warning:  Wrong COM_STMT_PREPARE response size. Received 7 in phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 67
PHP Fatal error:  Uncaught Error: Call to a member function execute() on bool in phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/vendor/illuminate/database/Connection.php:463
Stack trace:
#0 phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/vendor/illuminate/database/Connection.php(662): Illuminate\Database\Connection->Illuminate\Database\{closure}('SET GLOBAL sql_...', Array)
#1 phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/vendor/illuminate/database/Connection.php(629): Illuminate\Database\Connection->runQueryCallback('SET GLOBAL sql_...', Array, Object(Closure))
#2 phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/vendor/illuminate/database/Connection.php(464): Illuminate\Database\Connection->run('SET GLOBAL sql_...', Array, Object(Closure))
#3 phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/src/Elgentos/Masquerade/Console/RunCommand.php(330): Illuminate\Database\Connection->statement('SET GLOBAL sql_...')
#4 phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/src/Elgent in phar:///var/www/firetoys-sand1/masquerade/masquerade.phar/vendor/illuminate/database/Connection.php on line 463

I have double checked the config.yaml a few times, and it all seems in order. the only results i can see anywhere else all point to laravel issues, and masquerade is the only laravel user on this server as far as i'm aware. has this been seen before?

far as i can tell, foreign constraint checking is ON, and i have reset it in mysql with SET GLOBAL FOREIGN_KEY_CHECKS = 1; to no avail

Simplify formatter syntax in yaml

After closing #6 , the syntax has become a little bit unwieldy;

creditmemo:
  sales_creditmemo:
    columns:
      customer_note:
        formatter:
          name: sentence
      transaction_id:
        formatter:
          name: randomNumber
          nbDigits: 8

A better option would be to also allow this;

creditmemo:
  sales_creditmemo:
    columns:
      customer_note:
        formatter: sentence
      transaction_id:
        formatter: randomNumber

So we can use the simplified syntax when not passing on any arguments to the formatter.

Update identify command

Add identify command to find possible columns to anonimize.

It should;

  • Loop over all tables in a given database
  • Loop over all columns in every table
  • Check if the column is (partly?) named like a formatter that is available (firstname, email, etc)
  • For every identified column, ask whether a yaml entry should be created in a custom yaml file
  • Get the list of excluded tables dynamically from the YAML files
  • Not just exclude the whole table but take given column names into account

Error after install

Hi
I have followed the installation instructions and "Download the phar file:

curl -L -o masquerade.phar https://github.com/elgentos/masquerade/releases/latest/download/masquerade.phar
"

When I then run

php masquerade.phar run --help

I get the error

PHP Warning: require(phar:///home/ubuntu/masquerade.phar/vendor/composer/../symfony/translation/Resources/functions.php): failed to open stream: phar error: "vendor/symfony/translation/Resources/functions.php" is not a file in phar "/home/ubuntu/masquerade.phar" in phar:///home/ubuntu/masquerade.phar/vendor/composer/autoload_real.php on line 69 PHP Fatal error: require(): Failed opening required 'phar:///home/ubuntu/masquerade.phar/vendor/composer/../symfony/translation/Resources/functions.php' (include_path='.:/usr/share/php') in phar:///home/ubuntu/masquerade.phar/vendor/composer/autoload_real.php on line 69

Am I missing a step?

I am trying to run it on Ubuntu 20.04 with php 7.3.26

Thanks
Rob

Skip if table does not exist

Hello,

is skipping not existing tables possible? I can see #11 resolved non-existing columns issue, but it would be great not to fail when the specific table isn't present (i.e. with a cmd flag switch?)

Installation not working with last release (0.1.10)

Hello and thank you for sharing the code,

I've tried to install Masquerade by following the instructions described in README.md (line 61) :

wget https://github.com/elgentos/masquerade/releases/download/0.1.10/masquerade.phar

and i received a 404 error.

However, it works with release v 0.1.9

Best regards

Shopware 6 anonymization does not anonymize completely

But for some reason it duplicates the to-be-anonimized record and anonimizes that one. Maybe because of the binary UUID's?

But not all tables. customer, customer_address, newsletter_recipient, user, etc seem to be unaffected. order_customer and order_address contain the duplicate records.

Fixing default package version

Current it default to branch: (20180711.080851) which is from 4 years old, unless you specify right tag.

Think this old branch should be deleted or renamed, so that composer doesn't think it's newest tag.

doubt about making new build

Hi! First of all thank your for this tool!

I'm trying to build a new .phar file following your process but it doesn't seem to work. So I decided just to clone your repo and try to build the same .phar and I found differences between the phar uploaded here and the phar is being created when I use the build process.

  • clone project && composer install
  • download box
  • run build.sh

Being more specific I found a difference in one of the depencencies: elgentos/parser.
composer.lock is pointing to 1.4.2 (5ef1c392c83d928bdb58778618c7811e24f82416) If you take a look at the FileAbstract class inside your actual phar you will see the next code (I'm not able to find this code inside elgentos/parser repository):

private function safePath(string $path): string
{
    while (($newPath = str_replace('..', '', $path)) !== $path) {
        $path = $newPath;
    }
    return $path;
}

But if you take a look at the referenced code in composer.lock FileAbstract you will notice that the code differs:

private function safePath(string $path): string
{
    while (($newPath = str_replace(['..', '//'], ['', '/'], $path)) !== $path) {
         $path = $newPath;
    }
     return str_replace(['..', '//'], ['', '/'], $path);
}

So the new builds can't find correctly the config folder (here is where it fails

Error message:

In Glob.php line 55:
 RecursiveDirectoryIterator::__construct(phar:/blablabla/dist/masquerade.phar/src/config/magento2): failed to open dir: No such file or directory

I think that maybe a rebase broke this depencency, any idea why is this happening?

Thank you in advance.

Delete data and anonymize the remaining records

The idea is that we will delete all of the older customer data (for example, delete customers that have been created more than 30 days ago), so that the DB dump will be a lot smaller + reducing Masquerade execution time. The remaining data should be anonymized so we can use it anymwhere.

Example config:

  customer_grid_flat:
    provider:
      delete: true
      where: "`created_at` < now() - interval 30 day"
    columns:
      name:
        formatter: name
      email:
        formatter: email
        unique: true
        nullColumnBeforeRun: true
      dob:
        formatter: dateTimeThisCentury
        optional: true
      billing_full:
         ....

Currently, Masquerade just executes the delete, then it moves on to the next table, leaving the remaining records in the table anonymized. Very logical, but it would be nice to have the possibility to delete AND anonymize.

What would be the best place to implement this feature?

Configuration ignored or wrong usage on my side

Hi,

I try to anonymize the customer entity except several domain

So i create a yaml file under

src/config/magento2/customer.yaml

in my yaml file i try first with only one domain to be sure everything is working as expected like

customers:
  customer_entity:
    provider: # this sets options specific to the type of table
      where: "`email` not LIKE '%@domaineA.com' "

I run my command like that :

./masquerade.phar run --group=customer --platform=magento2 --config=src/config/magento2/

but all customer entities are "rewriten" to fake one including the one with domainA.com in the email field.

What I've done wrong ? and is it available to add a multiple filter like we can do on sql

customers:
  customer_entity:
    provider: # this sets options specific to the type of table
      where: "`email` not LIKE '%@domaineA.com' AND `email` not LIKE '%@domaineB.com'"

Thanks for your help and thumb up to @peterjaap for the slack help also :)

PostgreSQL compatibility

Hello,

Is Masquerade compatible with PostgreSQL ? I am having many errors:

SQLSTATE[42704]: Undefined object: 7 ERROR: unrecognized configuration parameter "foreign_key_checks"
SQLSTATE[42704]: Undefined object: 7 ERROR: unrecognized configuration parameter "sql_mode"
SQLSTATE[42703]: Undefined column: 7 ERROR: column "column_key" does not exist

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.