-
Notifications
You must be signed in to change notification settings - Fork 22
/
patterns.yml
259 lines (249 loc) · 10.4 KB
/
patterns.yml
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: Personally identifiable information (PII)
patterns:
- name: Credit Cards
type: credit_cards
regex:
pattern: |
(4[0-9]{12}(?:[0-9]{3})?|(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|(34|37)[0-9]{13})
# 4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}
expected:
# MasterCard
- name: credit-cards.txt
start_offset: 234
end_offset: 250
- name: credit-cards.txt
start_offset: 251
end_offset: 267
- name: credit-cards.txt
start_offset: 268
end_offset: 284
- name: credit-cards.txt
start_offset: 285
end_offset: 301
- name: credit-cards.txt
start_offset: 302
end_offset: 318
# Visa
# - name: credit-cards.txt
# start_offset: 331
# end_offset: 347
# - name: credit-cards.txt
# start_offset: 364
# end_offset: 380
# - name: credit-cards.txt
# start_offset: 397
# end_offset: 410
# American Express
- name: credit-cards.txt
start_offset: 452
end_offset: 467
- name: credit-cards.txt
start_offset: 468
end_offset: 483
- name: credit-cards.txt
start_offset: 484
end_offset: 499
- name: credit-cards.txt
start_offset: 500
end_offset: 515
- name: credit-cards.txt
start_offset: 516
end_offset: 531
# Australian BankCard
- name: credit-cards.txt
start_offset: 559
end_offset: 575
# Diners Club
- name: credit-cards.txt
start_offset: 595
end_offset: 609
- name: credit-cards.txt
start_offset: 610
end_offset: 624
# Discover
- name: credit-cards.txt
start_offset: 639
end_offset: 655
- name: credit-cards.txt
start_offset: 656
end_offset: 672
# JCB
- name: credit-cards.txt
start_offset: 683
end_offset: 699
- name: credit-cards.txt
start_offset: 700
end_offset: 716
# Dankort (PBS)
# - name: credit-cards.txt
# start_offset: 738
# end_offset: 749
# - name: credit-cards.txt
# start_offset: 750
# end_offset: 766
# Switch/Solo (Paymentech)
# - name: credit-cards.txt
# start_offset: 798
# end_offset: 814
test:
data: |
3530111333300000
start_offset: 0
end_offset: 16
comments:
- "Only supports Visa, MasterCard, and American Express"
- name: Credit Cards - Visa
type: credit_card_visa
regex:
pattern: |
4[0-9]{12}(?:[0-9]{3})?
expected:
- name: credit-cards.txt
start_offset: 331
end_offset: 347
- name: credit-cards.txt
start_offset: 364
end_offset: 380
- name: credit-cards.txt
start_offset: 397
end_offset: 410
test:
data: |
4012888888881881
start_offset: 0
end_offset: 16
- name: Credit Cards - MasterCard
type: credit_card_mastercard
regex:
pattern: |
(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}
expected:
- name: credit-cards.txt
start_offset: 234
end_offset: 250
- name: credit-cards.txt
start_offset: 251
end_offset: 267
- name: credit-cards.txt
start_offset: 268
end_offset: 284
- name: credit-cards.txt
start_offset: 285
end_offset: 301
- name: credit-cards.txt
start_offset: 302
end_offset: 318
test:
data: |
5555555555554444
start_offset: 0
end_offset: 16
- name: Credit Cards - American Express
type: credit_cards_american_express
regex:
pattern: |
(34|37)[0-9]{13}
expected:
- name: credit-cards.txt
start_offset: 452
end_offset: 467
- name: credit-cards.txt
start_offset: 468
end_offset: 483
- name: credit-cards.txt
start_offset: 484
end_offset: 499
- name: credit-cards.txt
start_offset: 500
end_offset: 515
- name: credit-cards.txt
start_offset: 516
end_offset: 531
test:
data: |
378282246310005
start_offset: 0
end_offset: 15
- name: Credit Cards - Discover
type: credit_card_discovery
regex:
pattern: |
6(?:011|5[0-9]{2})[0-9]{12}
expected:
- name: credit-cards.txt
start_offset: 639
end_offset: 655
- name: credit-cards.txt
start_offset: 656
end_offset: 672
test:
data: |
6011111111111117
start_offset: 0
end_offset: 16
- name: IBAN
type: iban
regex:
pattern: |
[A-Z]{2}[0-9]{2}(?:[ -]?[A-Z0-9]{4}|(?:[ -]?[0-9]){4})?(?:[ -]?[0-9]){9,25}(?:[ -]?[A-Z0-9]){0,3}
start: |
\A|[^A-Za-z0-9-]
end: |
\z|[^A-Za-z0-9 -]|[ ][^0-9A-Z]|[ ]?\z
additional_not_match:
# hex strings that don't match a country code, or lots of zeros (so probably an example)
- ^(?:(?:A[ABC]|BC|C[BE]|D[A-DF]|E[ABDF]|F[A-F]).*|[A-Z]{2}(?:0[ -]?)+)$
# examples we know about from the test set - so we need different synthetic versions!
# split into 4 (and no more) because of current length limitations and number of matches limits
- ^(?:AL35202111090000000001234567|AD1400080001001234567890|AT483200000012345864|AZ77VTBA00000000001234567890|BH02CITI00001077181611|BE71096123456769|BA393385804800211234|BR1500000000000010932840814P2|BG18RZBB91550123456789|CR23015108410026012345|HR1723600001101234565|CY21002001950000357001234567|CZ5508000000001234567899|FO9264600123456789|GL8964710123456789|DK9520000123456789|DO22ACAU00000000000123456789|EE471000001020145685|EG800002000156789012345180002|FI1410093000123458|FR7630006000011234567890189|GE60NB0000000123456789|DE75512108001245126199|GI56XAPO000001234567890|GR9608100010000001234567890|GT20AGRO00000000001234567890|HU93116000060000000012345676|IS750001121234563108962099|IE64IRCE92050112345678|IL170108000000012612345|IT60X0542811101000000123456|JO71CBJO0000000000001234567890|KZ244350000012344567|XK051212012345678906|KW81CBKU0000000000001234560101|LV97HABA0012345678910|LB92000700000000123123456123|LI7408806123456789012|LT601010012345678901|LU120010001234567891)$
- ^(?:MK07200002785123453|MT31MALT01100000000000000000123|MR1300020001010000123456753|MU43BOMM0101123456789101000MUR|MD21EX000000000001234567|MC5810096180790123456789085|ME25505000012345678951|NL02ABNA0123456789|NO8330001234567|PK36SCBL0000001123456702|PS92PALS000000000400123456702|PL10105000997603123456789123|PT50002700000001234567833|QA54QNBA000000000000693123456|RO66BACX0000001234567890|SM76P0854009812123456789123|LC14BOSL123456789012345678901234|ST23000200000289355710148|SA4420000001234567891234|RS35105008123123123173|SK8975000000000012345671|SI56192001234567892|ES7921000813610123456789|SE7280000810340009783242|CH5604835012345678009|TL380010012345678910106|TN5904018104004942712345|TR320010009999901234567890|AE460090000000123456789|GB33BUKB20201555555555|VA59001123000012345678|VG07ABVI0000000123456789|UA903052992990004149123456789|SC74MCBL01031234567890123456USD|IQ20CBIQ861800101010500|BY86AKBB10100000002966000000|SV43ACAT00000000000000123123|LY38021001000000123456789)$
- ^(?:SD8811123456789012|BI43220001131012345678912345|DJ2110002010010409943020008|RU0204452560040702810412345678901|SO061000001123123456789|GB82[ -]?[TW]EST[ -]?1234[ -]?5698[ -]?7654[ -]?325?|SA03[ -]?8000[ -]?0000[ -]?6080[ -]?1016[ -]?7519|DE89[ -]?3704[ -]?0044[ -]?0532[ -]?0130[ -]?00|AT61[ -]?1904[ -]?3002[ -]?3457[ -]?3201|NL20INGB0001234567|AZ96AZEJ00000000001234567890|GI04BARC000001234567890|VA22VA59001123000012345678|KZ563190000012344567|RO09BCYP0000001234567890|SC52BAHL01031234567890123456USD|VG21PACG0000000123456789|FR14[ -]?2004[ -]?1010[ -]?0505[ -]?0001[ -]?3|AO06004400006729503010102|BF42BF0840101300463574000390|BJ66BJ0610100100144390000769|CF4220001000010120069700160|CG3930011000101013451300019|CI93CI0080111301134291200589|CM2110002000300277976315008|CV64000500000020108215144|DZ580002100001113000000570|GA2140021010032001890020126|GQ7050002001003715228190196|GW04GW1430010181800637601|IR710570029971601460641001|MA64011519000001205000534921)
- ^(?:MG4600005030071289421016045|ML13ML0160120102600100668497|MZ59000301080016367102371|NE58NE0380100100130305000268|SN08SN0100152000048500003035|TD8960002000010271091600153|TG53TG0090604310346500400070|KM4600005000010010904400137|HN54PISA00000000000000123124|NI92BAMC000000000000000003123123|MN580050099123456789)$
expected:
- name: iban.txt
start_offset: 68
end_offset: 90
- name: iban.txt
start_offset: 91
end_offset: 118
- name: iban.txt
start_offset: 119
end_offset: 146
- name: iban.txt
start_offset: 147
end_offset: 174
- name: iban.txt
start_offset: 175
end_offset: 208
- name: iban.txt
start_offset: 209
end_offset: 242
test:
data: |
AL35202111090000000001234566
start_offset: 0
end_offset: 28
comments:
- This can produce false positives, since it doesn't check the checksum pair after the Country Code
- Examples include YouTube playlist IDs and Italian tax codes
- If this is a problem, try the individual country IBAN patterns, based on the published IBAN structures on https://iban.com/structure
- name: Norwegian national identity number/D number
type: no_national_id_number
regex:
pattern: |
(([04][1-9]|[15][0-9]|[26][0-9])(0[1-9]|1[0-2])|[37]0(0[469]|11)|[37][01](0[13578]|1[02]))[0-9]{2} ?[0-9]{3} ?[0-9]{2}
start: |
\A|[^0-9A-Za-z_.+/\\-]
end: |
\z|[^0-9A-Za-z_.+/\\=-]
additional_not_match:
- 1111111111[123]|11112222333|01123456978|410185 ?123 ?45|220676 ?123 ?45|01010202010|01010101023
test:
data: |
41018512346
start_offset: 0
end_offset: 11
comments:
- With no validation of the checksum this can cause a lot of false positives
- The example test data does not have a valid checksum - it is one of the examples used with one digit in the checksum changed
- You can test using the correct checksum, but it is used as a NOT match here to prevent false positives on other test data