From 3992576fa19eceb2ad130c9d74d1fd873ce9a839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 6 Apr 2024 17:18:25 +0200 Subject: [PATCH 1/2] fix typos in readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b3b4fea..8229094 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Database Anonimizer +# Database Anonymizer **Database Anonymizer** is a tool written in GO that allows **anonymizing or deleting data from a MySQL or PostgreSQL database**. -It addresses various use cases such as **providing developers with an anonymized copy of a database** or **satisfying the need to anonymize or delete data in accordance with GDPR (General Data Protection Regulation) requirements. data protection)**, depending on the retention periods. defined in the processing register. +It addresses various use cases such as **providing developers with an anonymized copy of a database** or **satisfying the need to anonymize or delete data in accordance with GDPR** (General Data Protection Regulation), depending on the retention periods defined in the processing register. The project includes a vast array of fakers. It also enables data generation via Twig-written templates. You can specify precise rules for each table or global rules applied to all tables in your configuration. @@ -37,7 +37,7 @@ rules: delete: true ``` -### Exécution +### Run To display help, use `-h`: @@ -56,7 +56,7 @@ database-anonymizer --dsn "postgres://postgres:postgres@localhost:5432/test" --s #### Special fakers -- `"null"` : set `null` +- `"null"`: set `null` - `""` or `"_"`: do nothing #### Others From 75efdde05cad5b07ca0a7b78bec51b5f67420a82 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 18 Jul 2024 10:02:33 +0200 Subject: [PATCH 2/2] add lorem fakers --- CHANGELOG.md | 9 +++++++++ README.fr.md | 6 ++++++ README.md | 6 ++++++ faker/faker.go | 16 ++++++++++++++++ go.mod | 1 + go.sum | 2 ++ 6 files changed, 40 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb80916..cf96c32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ ## [Unreleased] +## v1.2.0 +### Added +- add "lorem_word" faker +- add "lorem_sentence" faker +- add "lorem_paragraph" faker +- add "lorem_words_2" to "lorem_words_10" fakers +- add "lorem_sentences_2" to "lorem_sentences_10" fakers +- add "lorem_paragraphs_2" to "lorem_paragraphs_10" fakers + ## v1.1.0 ### Added - PostgreSQL: manage all number types diff --git a/README.fr.md b/README.fr.md index ccd6b73..737f7ee 100644 --- a/README.fr.md +++ b/README.fr.md @@ -61,6 +61,12 @@ database-anonymizer --dsn "postgres://postgres:postgres@localhost:5432/test" --s #### Les autres +- `"lorem_word"` +- `"lorem_sentence"` +- `"lorem_paragraph"` +- `"lorem_words_2"` to `"lorem_words_10"` +- `"lorem_sentences_2"` to `"lorem_sentences_10"` +- `"lorem_paragraphs_2"` to `"lorem_paragraphs_10"` - `"address"` - `"address_buildingnumber"` - `"address_city"` diff --git a/README.md b/README.md index 8229094..ab77546 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,12 @@ database-anonymizer --dsn "postgres://postgres:postgres@localhost:5432/test" --s #### Others +- `"lorem_word"` +- `"lorem_sentence"` +- `"lorem_paragraph"` +- `"lorem_words_2"` to `"lorem_words_10"` +- `"lorem_sentences_2"` to `"lorem_sentences_10"` +- `"lorem_paragraphs_2"` to `"lorem_paragraphs_10"` - `"address"` - `"address_buildingnumber"` - `"address_city"` diff --git a/faker/faker.go b/faker/faker.go index 2bd84b0..07d7436 100644 --- a/faker/faker.go +++ b/faker/faker.go @@ -2,7 +2,9 @@ package faker import ( "fmt" + "github.com/go-loremipsum/loremipsum" base_faker "github.com/jaswdr/faker" + "math/rand" "strconv" ) @@ -10,12 +12,26 @@ type FakeManager struct { Fakers map[string]func() string } +func NewLoremFaker() *loremipsum.LoremIpsum { + return loremipsum.NewWithSeed(rand.Int63()) +} + func NewFakeManager() FakeManager { manager := FakeManager{} datas := make(map[string]func() string) fake := base_faker.New() + datas["lorem_word"] = func() string { return NewLoremFaker().Word() } + datas["lorem_sentence"] = func() string { return NewLoremFaker().Sentence() } + datas["lorem_paragraph"] = func() string { return NewLoremFaker().Paragraph() } + + for i := 2; i <= 10; i++ { + datas[fmt.Sprintf("lorem_words_%d", i)] = func() string { return NewLoremFaker().Words(i) } + datas[fmt.Sprintf("lorem_sentences_%d", i)] = func() string { return NewLoremFaker().Sentences(i) } + datas[fmt.Sprintf("lorem_paragraphs_%d", i)] = func() string { return NewLoremFaker().Paragraphs(i) } + } + datas["address"] = func() string { return fake.Address().Address() } datas["address_buildingnumber"] = func() string { return fake.Address().BuildingNumber() } datas["address_city"] = func() string { return fake.Address().City() } diff --git a/go.mod b/go.mod index 08d1b50..42e6567 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/go-loremipsum/loremipsum v1.1.3 // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect diff --git a/go.sum b/go.sum index e8c409e..f24f1ef 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-loremipsum/loremipsum v1.1.3 h1:ZRhA0ZmJ49lGe5HhWeMONr+iGftWDsHfrYBl5ktDXso= +github.com/go-loremipsum/loremipsum v1.1.3/go.mod h1:OJQjXdvwlG9hsyhmMQoT4HOm4DG4l62CYywebw0XBoo= github.com/go-sql-driver/mysql v1.8.0 h1:UtktXaU2Nb64z/pLiGIxY4431SJ4/dR5cjMmlVHgnT4= github.com/go-sql-driver/mysql v1.8.0/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/jaswdr/faker v1.19.1 h1:xBoz8/O6r0QAR8eEvKJZMdofxiRH+F0M/7MU9eNKhsM=