Giter Club home page Giter Club logo

dbtoolsbundle's Introduction

Coding standards Static Analysis Documentation build Continuous Integration

DbToolsBundle

A set of Symfony Console Commands to interact with your database

  • Backup: Backup your database and manage your dumps with a simple command.
  • Restore: Easily restore a previous dump of your database.
  • Anonymize: Set up database anonymization with PHP attributes on Doctrine Entities or with a YAML configuration file.
  • Set up a GDPR-friendly workflow: Make it easier to follow GDPR best practices when importing production dump to other environments.

Installation

DbToolsBundle requires PHP 8.1 or higher and Symfony 6.0 or higher. Run the following command to install it in your application:

composer require makinacorpus/db-tools-bundle

Documentation

Read DbToolsBundle documentation on Read the Docs.

Contributing

The DbToolsBundle is an Open Source project, if you want to help check out the contribute page on the documentation.

Licence

This software is published under the MIT License.

dbtoolsbundle's People

Contributors

antoinearesu avatar djlechuck avatar dtrucs avatar evertharmeling avatar lonnytunes avatar maxhelias avatar pounard avatar shakaran avatar simonmellerin 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

dbtoolsbundle's Issues

Add other methods to configure Anonymzation

Par exemple, une API en PHP:

function configure(AnonymiationBuilder $builder) {
    $builder
        ->forTable('demande')
        ->column('nom', NomAnomyzer::class, ['option1' => 'foo', /* ... */])
        ->table('address', AdressAnonymzer::class, [/* ... */]) 
     ;

    $builder
        ->forTable('other_table')
        ->column('nom', NomAnomyzer::class, ['option1' => 'foo', /* ... */])
        ->table('address', AdressAnonymzer::class, [/* ... */])
        // ...
     ;
}

Je fais ça en deux secondes comme ça, mais c'est peut être un sujet à réfléchir dans le futur, ou pas d'ailleurs !
Ça pourrait permettre d'enregister des services, genre:

namespace App\DbTools;

class MonPluginMaConf
{
    #[AnonimizeTable('Table des demandes')]
    public function anonymiseDemande(AnonymiationBuilder $builder): void
    {
    }
}

Et on pourrait imaginer ensuite qu'une commande puisse lister les tables, et lancer table par table ?

Sample table, a better management

Aujourd'hui, chaque anonymizer est responsable de créer et détruire lui même ses tables de sample, du coup ce code est dupliqué à pas mal d'endroits.

L'idée serait de reposer sur la méthode AbstractAnonymizer::createSampleTempTable() systématiquement, et laisser la classe abstraite gérer elle même la suppression des tables ainsi créées:

On modifierait donc:

class AbstractAnonymizer
{
    final public function clean()
    {
        $this->doClean();

        // Fait le job de nettoyage
    }

    /* À surcharger par les classes enfant pour leur propre nettoyage si besoin */
    protected function doClean()
    {
    }
}

Anonymization - Add "collection" notion

The main idea is to tag anonymized column targets using one or more "collection" name:

anonymization:
    default:
        user:
            country: 
                anonymizer: fr_fr.prenom
                collection: other_collection
            prenom: 
                anonymizer: fr_fr.prenom
                collection: [my_collection, other_collection]
            nom: fr_fr.nom

Which enables partial anonymization across many tables in a single connection, such as:

php bin/console db-tools:anonymize --local --collection=some_collection --collection=other_collection

We had a use case in the past, where we needed to proceed to partial data import (regular sync using import files) on a pre-production environment from a third party service that didn't anonymize its own data. Having this command would have allowed us to proceed to selective data anonymization after each sync and keep sensitive data out without running a full database anonymization.

There are probably other existing use cases.

Original copy/paste from our internal bug tracker, in french from @SimonMellerin:

Lors de la configuration de l’anonymisation, on pourrait ajouter une notion de collection

anonymization:
    default:
      user:
        prenom: 
          anonymizer: fr_fr.prenom
          collection: my_collection
        nom: fr_fr.nom

ensuite on pourrait lancer un console db-tools:anonymize -c my_collection pour anonymiser uniquement cette collection.

Le use-case que je vois c'est : j'ai des données de synchronisées avec une API externe, mais sur leur env de test, bin ils nous renvoient des vraies données. Après synchro des données en provenance de cette API, on pourrait lancer l'anonymisation uniquement sur les targets concernées. Pratique pour ne pas envoyer des mails ou des SMS à des vrais endusers

Configure services with PHP

Sujet à discuter:

  • dans le core, Symfony n'utilise plus du tout ni la configuration XML, ni YAML,
  • beaucoup de bundle de la communauté utilisent le XML depuis la nuit des temps,
  • globalement dans les best practices c'est documenté surtout le XML,
  • la variante PHP est relativement nouvelle, mais semble être ce qu'il faut faire maintenant.

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.