-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunner.php
51 lines (35 loc) · 1.4 KB
/
runner.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env php
<?php
/**
* Example to set-up and call Anonymizer
* Martin Latter, 04/07/2021
*/
declare(strict_types=1);
use Anonymizer\Configuration;
use Anonymizer\Logger;
use Anonymizer\Connect;
use Anonymizer\Truncate;
use Anonymizer\Clip;
use Anonymizer\Filter;
use Anonymizer\CharGenerator;
require 'src/autoloader.php';
## INIT
$config = new Configuration(); # Configuration class contains database credentials
$log = Logger::setup($config); # toggle logging to file
$db = Connect::getInstance($config); # database connection object
## DATABASE ACTIONS
$numRows = 100; # number of rows to remain in clipped tables
$tablesToTruncate = ['misc']; # array of table names to be truncated
$anonymize =
[
# table columns in which to obliterate personal data
# table_name => [column1, column2 ...]
'users' => ['email']
// 'users' => ['first_name','last_name','birthday', 'email','telephone','SSN','password_bcrypt','description','bio','cost','amount','active','added','upd']
];
# truncate large tables specified in $tablesToTruncate (comment out to skip this action)
$t = new Truncate($db, $tablesToTruncate);
# clip ALL database table rows to value of $numRows (comment out to skip this action)
$c = new Clip($db, $numRows);
# filter/anonymize personal data columns contained in $anonymize array
$f = new Filter($db, $anonymize, $numRows);