{"id":13518644,"url":"https://github.com/elgentos/masquerade","last_synced_at":"2025-03-31T10:32:08.693Z","repository":{"id":33574139,"uuid":"140482706","full_name":"elgentos/masquerade","owner":"elgentos","description":"Faker-driven, configuration-based, platform-agnostic, locale-compatible data faker tool","archived":true,"fork":false,"pushed_at":"2023-10-19T12:17:24.000Z","size":11953,"stargazers_count":237,"open_issues_count":20,"forks_count":42,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-11T16:49:33.200Z","etag":null,"topics":["faker","hacktoberfest","magento","magento2","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elgentos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-07-10T20:15:45.000Z","updated_at":"2024-11-19T08:50:22.000Z","dependencies_parsed_at":"2023-01-15T01:29:24.697Z","dependency_job_id":"4d299054-1136-46d6-97b4-511f3bfef91e","html_url":"https://github.com/elgentos/masquerade","commit_stats":{"total_commits":173,"total_committers":24,"mean_commits":7.208333333333333,"dds":"0.35838150289017345","last_synced_commit":"dee1599ac920f78807f2e9b7dd3d49170fcdd30d"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgentos%2Fmasquerade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgentos%2Fmasquerade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgentos%2Fmasquerade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elgentos%2Fmasquerade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elgentos","download_url":"https://codeload.github.com/elgentos/masquerade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246453721,"owners_count":20779998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["faker","hacktoberfest","magento","magento2","php"],"created_at":"2024-08-01T05:01:47.255Z","updated_at":"2025-03-31T10:32:07.257Z","avatar_url":"https://github.com/elgentos.png","language":"PHP","funding_links":[],"categories":["PHP","Tools"],"sub_categories":["Meet Magento"],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg width=\"400\" height=\"125\" src=\"https://raw.githubusercontent.com/elgentos/masquerade/master/art/logo.png\" alt=\"Masquerade logo\" /\u003e\n\u003c/p\u003e\n\n# Masquerade\n\n## This project is ABANDONED. Thanks for your support!\n\nThis project has been abandoned. For a better, faster and more maintained alternative, see Smile's [gdpr-dump](https://github.com/smile-SA/gdpr-dump/). We have created our own repository for config files for popular Magento 2 extensions, see [elgentos/gdpr-dump-magento-2-extensions](https://github.com/elgentos/gdpr-dump-magento-2-extensions/).\n\n## Faker-driven, platform-agnostic, locale-compatible data faker tool\n\nPoint Masquerade to a database, give it a rule-set defined in YAML and Masquerade will anonymize the data for you\n automatically!\n\n\u003cimg src=\"https://user-images.githubusercontent.com/431360/42574650-30e8d186-851f-11e8-9693-c23b426c43f2.png\" width=\"600\" /\u003e\n\n### Out-of-the-box supported frameworks\n\n- Magento 2\n- Shopware 6\n\n### Customization\n\nYou 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.\n\nSee the [Magento 2 YAML files](https://github.com/elgentos/masquerade/tree/master/src/config/magento2) as examples for notation.\n\nFor 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;\n\n```\nadmin:\n```\n\nYou can add your own config files for custom tables or tables from 3rd party vendors. Here are a few examples:\n- [Magento 2 Aheadworks YAML file](https://github.com/elgentos/masquerade/wiki/%5BMagento-2%5D-Aheadworks-YAML-file)\n- [Magento 2 Amasty YAML file](https://github.com/elgentos/masquerade/wiki/%5BMagento-2%5D-Amasty-YAML-file)\n- [Shopware 6 Frosh YAML file](https://github.com/elgentos/masquerade/wiki/%5BShopware-6%5D-Frosh-YAML-file)\n\nTo 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.\n\n### Partial anonymization\n\nYou 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:\n\n```yaml\ncustomers:\n  customer_entity:\n    provider: # this sets options specific to the type of table\n      where: \"`email` not like '%@mycompany.com'\" # leave mycompany.com emails alone\n```\n\n### Delete Data\n\nYou 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.\n\nWhen 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:\n\n```yaml\norders:\n  sales_order:\n    provider:\n      delete: true\n      where: \"customer_id != 3\" # delete all except customer 3's orders because we use that for testing\n    # no need to specify columns if you're using 'delete'      \n```\n\nIf 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.\n\n### Magento EAV Attributes\n\nYou can use the Magento2Eav table type to treat EAV attributes just like normal columns, eg.\n\n```yaml\nproducts:\n  catalog_product_entity: # specify the base table of the entity\n    eav: true\n    provider:\n      where: \"sku != 'TESTPRODUCT'\" # you can still use 'where' and 'delete'\n    columns:\n      my_custom_attribute:\n        formatter: sentence\n      my_other_attribute:\n        formatter: email\n\n  catalog_category_entity:\n    eav: true\n    columns:\n      description: # refer to EAV attributes like normal columns\n        formatter: paragraph\n\n```\n\n### Formatter Options\n\nFor formatters, you can use all default [Faker formatters](https://github.com/fzaninotto/Faker#formatters).\n\n#### Custom Data Providers / Formatters\n\nYou 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.\n\nAn example file `.masquerade/Custom/WoopFormatter.php`;\n\n```php\n\u003c?php\n\nnamespace Custom;\n\nuse Faker\\Provider\\Base;\n\nclass WoopFormatter extends Base {\n\n    public function woopwoop() {\n        $woops = ['woop', 'wop', 'wopwop', 'woopwoop'];\n        return $woops[array_rand($woops)];\n    }\n}\n```\n\nAnd then use it in your YAML file. A provider needs to be set on the column name level, not on the formatter level.\n\n```\ncustomer:\n  customer_entity:\n    columns:\n      firstname:\n        provider: \\Custom\\WoopFormatter\n        formatter:\n          name: woopwoop\n```\n\n### Custom Table Type Providers\n\nSome 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. \nIn order to do it you need to implement 2 interfaces:\n - `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.\n - `Elgentos\\Masquerade\\DataProcessor` is to process various operations required by run command like:\n\n   - `truncate` should truncate table in provided table via configuration\n   - `delete` should delete table in provided table via configuration\n   - `updateTable` should update table with values provided by generator based on columns definitions in the configuration. \n     See `Elgentos\\Masquerade\\DataProcessor\\RegularTableProcessor::updateTable` for a reference.\n\n\nFirst you need to start with a factory that will instantiate an actual processor\n\nAn example file `.masquerade/Custom/WoopTableFactory.php`;\n```php\n\u003c?php\n\nnamespace Custom;\n\nuse Elgentos\\Masquerade\\DataProcessor;\nuse Elgentos\\Masquerade\\DataProcessor\\TableServiceFactory;\nuse Elgentos\\Masquerade\\DataProcessorFactory;\nuse Elgentos\\Masquerade\\Output;\n \nclass WoopTableFactory implements DataProcessorFactory \n{\n\n    public function create(\n        Output $output, \n        TableServiceFactory $tableServiceFactory,\n        array $tableConfiguration\n    ): DataProcessor {\n        $tableService = $tableServiceFactory-\u003ecreate($tableConfiguration['name']);\n\n        return new WoopTable($output, $tableService, $tableConfiguration);\n    }\n}\n```\n\nAn example file `.masquerade/Custom/WoopTable.php`;\n\n```php\n\u003c?php\n\nnamespace Custom;\n\nuse Elgentos\\Masquerade\\DataProcessor;\nuse Elgentos\\Masquerade\\DataProcessor\\TableService;\nuse Elgentos\\Masquerade\\Output;\n\nclass WoopTable implements DataProcessor\n{\n    /** @var Output */\n    private $output;\n\n    /** @var array */\n    private $configuration;\n\n    /** @var TableService */\n    private $tableService;\n\n    public function __construct(Output $output, TableService $tableService, array $configuration)\n    {\n        $this-\u003eoutput = $output;\n        $this-\u003etableService = $tableService;\n        $this-\u003econfiguration = $configuration;\n    }\n\n    public function truncate(): void\n    {\n        $this-\u003etableService-\u003etruncate();\n    }\n    \n    public function delete(): void\n    {\n        $this-\u003etableService-\u003edelete($this-\u003econfiguration['provider']['where'] ?? '');\n    }\n    \n    public function updateTable(int $batchSize, callable $generator): void\n    {\n        $columns = $this-\u003etableService-\u003efilterColumns($this-\u003econfiguration['columns'] ?? []);\n        $primaryKey = $this-\u003econfiguration['pk'] ?? $this-\u003etableService-\u003egetPrimaryKey();\n        \n        $this-\u003etableService-\u003eupdateTable(\n            $columns, \n            $this-\u003econfiguration['provider']['where'] ?? '', \n            $primaryKey,\n            $this-\u003eoutput,\n            $generator,\n            $batchSize\n        );\n    }\n}\n```\n\nAnd 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.\n\n```yaml\ncustomer:\n  customer_entity:\n    processor_factory: \\Custom\\WoopTableFactory\n    some_custom_config:\n      option1: \"test\"\n      option2: false\n    columns:\n      firstname:\n        formatter:\n          name: firstName\n```\n\n### Installation\n\nDownload the phar file:\n\n```\ncurl -L -o masquerade.phar https://github.com/elgentos/masquerade/releases/latest/download/masquerade.phar\n```\n\n### Usage\n\n```\n$ php masquerade.phar run --help\n\nDescription:\n  List of tables (and columns) to be faked\n\nUsage:\n  run [options]\n\nOptions:\n      --platform[=PLATFORM]\n      --driver[=DRIVER]      Database driver [mysql]\n      --database[=DATABASE]\n      --username[=USERNAME]\n      --password[=PASSWORD]\n      --host[=HOST]          Database host [localhost]\n      --port[=PORT]          Database port [3306]\n      --prefix[=PREFIX]      Database prefix [empty]\n      --locale[=LOCALE]      Locale for Faker data [en_US]\n      --group[=GROUP]        Comma-separated groups to run masquerade on [all]\n      --with-integrity       Run with foreign key checks enabled\n      --batch-size=BATCH-SIZE  Batch size to use for anonymization [default: 500]\n```\n\nYou can also set these variables in a `config.yaml` file in the same location as where you run masquerade from, for example:\n\n```yaml\nplatform: magento2\ndatabase: dbnamehere\nusername: userhere\npassword: passhere\nhost: localhost\nport: porthere\n```\n\n### Running it nightly\n\nCheck out the wiki on how to run Masquerade nightly in CI/CD;\n- [Usage with Gitlab CI/CD](https://github.com/elgentos/masquerade/wiki/Usage-with-Gitlab-CI-CD)\n- [Usage with Github Actions](https://github.com/elgentos/masquerade/wiki/Usage-with-Github-Actions)\n- [Usage with Bitbucket Pipelines](https://github.com/elgentos/masquerade/wiki/Usage-with-Bitbucket-Pipelines)\n\n### Building from source\n\nTo build the phar from source you can use the `build.sh` script. Note that it depends on [Box](https://github.com/box-project/box) which is included in this repository.\n\n```\n# git clone https://github.com/elgentos/masquerade\n# cd masquerade\n# composer install\n# chmod +x build.sh\n# ./build.sh\n# bin/masquerade\n```\n\n### Debian Packaging\n\nTo build a deb for this project run:\n\n```\n# apt-get install debhelper cowbuilder git-buildpackage\n# export ARCH=amd64\n# export DIST=buster\n# cowbuilder --create --distribution buster --architecture amd64 --basepath /var/cache/pbuilder/base-$DIST-amd64.cow --mirror http://ftp.debian.org/debian/ --components=main\n# echo \"USENETWORK=yes\" \u003e ~/.pbuilderrc\n# git clone https://github.com/elgentos/masquerade\n# cd masquerade\n# gbp buildpackage --git-pbuilder --git-dist=$DIST --git-arch=$ARCH --git-ignore-branch -us -uc -sa --git-ignore-new\n```\n\nTo generate a new `debian/changelog` for a new release:\n```\nexport BRANCH=master\nexport VERSION=$(date \"+%Y%m%d.%H%M%S\")\ngbp dch --debian-tag=\"%(version)s\" --new-version=$VERSION --debian-branch $BRANCH --release --commit\n```\n\n#### Credits\n\n- Built by [elgentos](https://github.com/elgentos)\n- Logo by [Caneco](https://twitter.com/caneco)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felgentos%2Fmasquerade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felgentos%2Fmasquerade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felgentos%2Fmasquerade/lists"}