From 6ed43eecf06389aae8d3b75f566443058372224b Mon Sep 17 00:00:00 2001 From: lise Date: Tue, 22 Oct 2024 14:22:18 +0200 Subject: [PATCH 1/4] add social security number anonymizer --- .../NumeroSecuriteSocialeAnonymizer.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php diff --git a/src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php b/src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php new file mode 100644 index 0000000..77741f9 --- /dev/null +++ b/src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php @@ -0,0 +1,51 @@ +expression(); + + + $update->set( + $this->columnName, + $this->getSetIfNotNullExpression( + $expr->concat( + $expr->lpad($this->getRandomIntExpression(4), 1, '0'), + $expr->lpad($this->getRandomIntExpression(9), 1, '0'), + $expr->lpad($this->getRandomIntExpression(9), 1, '0'), + // 13 correspond aux caractères 4 et 5 soit le mois de l'année 13=impossible + '13', + $expr->lpad($this->getRandomIntExpression(999999999), 10, '0'), + + ) + ) + ); + + + } +} + From 64270932d9b7fe3497e3fcf252515072e60503a4 Mon Sep 17 00:00:00 2001 From: lise Date: Thu, 24 Oct 2024 14:32:58 +0200 Subject: [PATCH 2/4] few fix --- .gitignore | 4 +++- README.md | 5 +++-- src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3e99efa..153f9b1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ /phpstan.neon /phpunit.xml /vendor/ -test_db \ No newline at end of file +test_db +/test +/test_ db.sqlite diff --git a/README.md b/README.md index e6af68f..861f318 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,15 @@ This pack provides: * `fr-fr.address`: Same as address from core but with a sample of 500 dumb french addresses * `fr-fr.firstname`: Anonymize with a random french first names from a sample of ~500 items * `fr-fr.lastname`: Anonymize with a random french last names from a sample of ~500 items -* `fr-fr.phone`: Anonymize french telephone numbers, (only option is `mode`: `mobile` or `landline` +* `fr-fr.phone`: Anonymize french telephone numbers, (only option is `mode`: `mobile` or `landline`) +* `fr-fr.secu`: Anonymize french social sécurity numbers ## Installation Run the following command to add this pack to your application: ```sh -composer require db-tools-bundle/pack-fr-fr +composer require dbtoolsbundle/pack-fr-fr ``` Learn more about how to use this package reading [the DbToolsBundle documentation](https://dbtoolsbundle.readthedocs.io/) on Read the Docs. diff --git a/src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php b/src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php index 77741f9..381b3bd 100644 --- a/src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php +++ b/src/Anonymizer/NumeroSecuriteSocialeAnonymizer.php @@ -37,7 +37,7 @@ public function anonymize(Update $update): void $expr->lpad($this->getRandomIntExpression(4), 1, '0'), $expr->lpad($this->getRandomIntExpression(9), 1, '0'), $expr->lpad($this->getRandomIntExpression(9), 1, '0'), - // 13 correspond aux caractères 4 et 5 soit le mois de l'année 13=impossible + //The 13 corresponds to the 4th and 5th characters, which represent the month of the year. However, 13 is not a valid month, so this would not be a valid social security number. '13', $expr->lpad($this->getRandomIntExpression(999999999), 10, '0'), From 91ed2edd77a3b62c30d131cb91f70a31af8f2cdd Mon Sep 17 00:00:00 2001 From: lise Date: Thu, 24 Oct 2024 16:28:44 +0200 Subject: [PATCH 3/4] add credit card numbers --- src/Anonymizer/CreditCardNumberAnonymizer.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/Anonymizer/CreditCardNumberAnonymizer.php diff --git a/src/Anonymizer/CreditCardNumberAnonymizer.php b/src/Anonymizer/CreditCardNumberAnonymizer.php new file mode 100644 index 0000000..27f12bb --- /dev/null +++ b/src/Anonymizer/CreditCardNumberAnonymizer.php @@ -0,0 +1,70 @@ + Date: Thu, 24 Oct 2024 16:37:10 +0200 Subject: [PATCH 4/4] fixBug --- README.md | 1 + src/Anonymizer/CreditCardNumberAnonymizer.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 861f318..77f3fb2 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This pack provides: * `fr-fr.lastname`: Anonymize with a random french last names from a sample of ~500 items * `fr-fr.phone`: Anonymize french telephone numbers, (only option is `mode`: `mobile` or `landline`) * `fr-fr.secu`: Anonymize french social sécurity numbers +* `fr-fr.cb` : Anonymize credit card numbers with a sample of 40 items ## Installation diff --git a/src/Anonymizer/CreditCardNumberAnonymizer.php b/src/Anonymizer/CreditCardNumberAnonymizer.php index 27f12bb..e90e404 100644 --- a/src/Anonymizer/CreditCardNumberAnonymizer.php +++ b/src/Anonymizer/CreditCardNumberAnonymizer.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace DbToolsBundle\PackDeDE\Anonymizer; +namespace DbToolsBundle\PackFrFR\Anonymizer; use MakinaCorpus\DbToolsBundle\Anonymization\Anonymizer\AbstractEnumAnonymizer; use MakinaCorpus\DbToolsBundle\Attribute\AsAnonymizer; #[AsAnonymizer( name: 'cb', - pack: 'de-de', + pack: 'fr-fr', description: <<