Skip to content

Commit

Permalink
#35 - Added more fake users data, fixed issue of not using all fake u…
Browse files Browse the repository at this point in the history
…sers records for anonymization (#36)
  • Loading branch information
michalbiarda authored Jul 18, 2022
1 parent ac7f0a6 commit b507065
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 2 deletions.
135 changes: 135 additions & 0 deletions .driver/anonymize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,138 @@ anonymize:
phone: 852-555-0129
company: Hello World, Inc.
ip: 197.45.92.201

- firstname: Michael
lastname: Jordan
street: 4182 Grim Avenue
city: Hartford
postcode: '06103'
phone: 860-555-4398
company: Big Shoe
ip: 71.9.45.231

- firstname: Zinedine
lastname: Zidane
street: 4640 Hawks Nest Lane
city: San Diego
postcode: 92103
phone: 619-555-2688
company: French Fries
ip: 122.90.87.291

- firstname: Bruce
lastname: Lee
street: 3767 Clearview Drive
city: St Louis
postcode: 63101
phone: 314-555-3035
company: Karate Kids
ip: 91.23.211.34

- firstname: Cameron
lastname: Diaz
street: 3294 Diamond Cove
city: Greenwood Village
postcode: 80111
phone: 303-555-9124
company: Nice Movies, Ltd.
ip: 198.34.22.201

- firstname: Jennifer
lastname: Lopez
street: 910 Terry Lane
city: Providence
postcode: '02908'
phone: 401-555-9265
company: Jay-El-Oh
ip: 198.56.81.156

- firstname: Brad
lastname: Pitt
street: 14 Atha Drive
city: Orlando
postcode: 32810
phone: 321-555-9183
company: Handsome Guys
ip: 19.234.98.125

- firstname: John
lastname: Doe
street: 1975 Pinchelone Street
city: Bakersfield
postcode: 93301
phone: 661-730-4347
company: Missing People, LLC
ip: 211.50.26.120

- firstname: Harlan
lastname: Coben
street: 3182 Nancy Street
city: Durham
postcode: 27713
phone: 919-555-2387
company: Myron & Bolitar, Ltd.
ip: 89.57.34.90

- firstname: Stephen
lastname: King
street: 4922 Wescam Court
city: Portsmouth
postcode: 23707
phone: 757-555-1396
company: IT Lovers
ip: 78.197.204.90

- firstname: Will
lastname: Smith
street: 3748 Archwood Avenue
city: Cambridge
postcode: '02141'
phone: 781-555-0073
company: Men In Black
ip: 38.56.111.78

- firstname: Marlon
lastname: Brando
street: 3072 Jadewood Farms
city: Morristown
postcode: '07960'
phone: 973-555-2129
company: Tea Vee
ip: 50.38.194.29

- firstname: Amitkumar
lastname: Solanki
street: 2436 Eden Drive
city: Powell
postcode: 82435
phone: 307-555-6448
company: India Express
ip: 163.28.218.109

- firstname: Martha
lastname: Stuart
street: 3854 Still Pastures Drive
city: Charles City
postcode: 23030
phone: 804-555-2583
company: Cook With Us, LLC
ip: 238.12.1.58

- firstname: Arnold
lastname: Schwarzenegger
street: 3869 Beeghley Street
city: Chester
postcode: 29706
phone: 803-555-2026
company: Magic Gym
ip: 89.45.149.18

- firstname: Bobby
lastname: Dingo
street: 2651 Cecil Street
city: Covington
postcode: 76636
phone: 254-555-8792
company: Doggy Barber
ip: 79.3.65.214
7 changes: 5 additions & 2 deletions src/Engines/MySql/Transformation/Anonymize.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ private function queryGeneral(string $type, string $columnName, string $mainTabl
$table = Seed::FAKE_USER_TABLE;
$salt = $this->seed->getSalt();
$count = $this->seed->getCount();
return "(SELECT ${table}.${type} FROM ${table} WHERE ${table}.id = "
. "(SELECT 1 + MOD(ORD(MD5(CONCAT(\"${salt}\", ${mainTable}.${columnName}))), ${count})) LIMIT 1)";
return "(SELECT ${table}.${type} FROM ${table} WHERE ${table}.id = (SELECT 1 + MOD("
. "ORD(SUBSTRING(MD5(CONCAT(\"${salt}\", ${mainTable}.${columnName})), 1, 1)) + "
. "ORD(SUBSTRING(MD5(CONCAT(\"${salt}\", ${mainTable}.${columnName})), 2, 1)) + "
. "ORD(SUBSTRING(MD5(CONCAT(\"${salt}\", ${mainTable}.${columnName})), 3, 1)) * "
. "ORD(SUBSTRING(MD5(CONCAT(\"${salt}\", ${mainTable}.${columnName})), 4, 1)), ${count})) LIMIT 1)";
}

private function queryEmpty(): string
Expand Down

0 comments on commit b507065

Please sign in to comment.