-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
136 lines (91 loc) · 6.43 KB
/
example.php
File metadata and controls
136 lines (91 loc) · 6.43 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
require __DIR__ . '/../../../vendor/autoload.php';
$content = '';
$content .= file_get_contents(__DIR__ . '/testdata/AustraliaMedicareNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/AustraliaTaxFileNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BankGenericCreditCards.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BankIbanAccountNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BankSwiftCodes.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BelgiumNationalNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BelgiumNationalRegisterNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BrazilCpfNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BrazilLegalEntityNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/BrazilNationalIdCard.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/CanadaBritishColumbiaInsuranceNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/CanadaOntarioInsuranceNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/CanadaPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/CanadaQuebecInsuranceNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/CanadaSocialInsuranceNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/ChileNationalIdNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/ChinaPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/CroatiaPersonalIdentificationNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/CzechRepublicNationalIdCard.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/DenmarkPersonalIdentificationNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/FranceINSEENumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/FranceNationalIdCard.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/FrancePassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/GermanyPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/IndiaPermanentAccountNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/IsraelNationalIdNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/JapanPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MaxicoPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MexicoNationalNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscCoordinates.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscCopyright.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscCusip.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscDate.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscPotentialPasswords.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscSwearword.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscEmails.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscICD-10CMCodes.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscICD-9CMCodes.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/MiscIPs.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/NetherlandsIdNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/NewZealandHealthNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/NorwayNationalIdNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/PolandNationalIdCard.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/PolandNationalIdNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/PolandPassport.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SingaporeNationalIdCard.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SouthAfricaNationalIdNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SouthKoreaPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SpainNieNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SpainNifNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SpainPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SwedenNationalIdNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/SwedenPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/TaiwanNationalIdNumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKDrivingLicenses.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKNationalInsuranceNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKNHSNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKPassports.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKPhoneNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKPlateNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKPostCodes.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UKTaxpayerNumbers.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UsDEANumber.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UsZip.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UsPassport.txt') . "\n";
$content .= file_get_contents(__DIR__ . '/testdata/UsSSN.txt') . "\n";
$manager = new \SME\ContentDetectors\DetectionManager();
$matches = $manager->getMatchingTypes($content);
echo "Enabled Detectors:\n";
foreach ($manager->getDetectors() as $detector) {
echo sprintf("----> %s\n", $detector);
}
echo sprintf("\n" , $detector);
echo sprintf("Detecting content in files:\n", $detector);
foreach ($matches as $match) {
$type = $match->getMatchType();
$content = $match->getMatchingContent();
$data = $match->getData();
$dataString = '';
if (is_array($data) && count($data)) {
// For ease of rendering let's filter out on string values.
$data = array_filter($data, function($value, $key) {
return is_string($value);
}, ARRAY_FILTER_USE_BOTH);
$dataString = '(' . http_build_query($data, '', ', ') . ')';
}
echo sprintf("Found '%s' '%s' %s\n", $type, $content, $dataString);
}