@whotracksme/reporting 7.12.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/communication/test/helpers/in-memory-database.js +45 -0
- package/package.json +2 -2
- package/reporting/src/hash-detector-v2/index.js +164 -0
- package/reporting/src/hash-detector-v2/prob.js +599 -0
- package/reporting/src/hash-detector-v2.js +18 -0
- package/reporting/src/observable.js +43 -0
- package/reporting/src/pages.js +11 -12
- package/reporting/src/paused-domains-reporter.js +50 -0
- package/reporting/src/persisted-counters.js +158 -0
- package/reporting/src/popularity-estimator.js +625 -0
- package/reporting/src/popularity-vote-handler.js +219 -0
- package/reporting/src/popularity-vote-sanitizer.js +384 -0
- package/reporting/src/random.js +90 -1
- package/reporting/src/reporting.js +98 -13
- package/reporting/src/utils.js +41 -1
- package/reporting/test/activity-estimator.spec.js +3 -2
- package/reporting/test/alive-check.spec.js +2 -2
- package/reporting/test/country-provider.spec.js +2 -2
- package/reporting/test/index.js +6 -0
- package/reporting/test/job-scheduler.spec.js +2 -2
- package/reporting/test/observable.spec.js +72 -0
- package/reporting/test/page-aggregator.spec.js +3 -0
- package/reporting/test/patterns-updater.spec.js +2 -2
- package/reporting/test/persisted-counters.spec.js +132 -0
- package/reporting/test/popularity-estimator.spec.js +710 -0
- package/reporting/test/popularity-vote-handler.spec.js +420 -0
- package/reporting/test/popularity-vote-sanitizer.spec.js +635 -0
- package/reporting/test/random.spec.js +157 -0
- package/reporting/test/reporting.spec.js +202 -180
- package/reporting/test/utils.spec.js +42 -0
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WhoTracks.Me
|
|
3
|
+
* https://whotracks.me/
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2017-present Ghostery GmbH. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
8
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
9
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { expect, assert } from 'chai';
|
|
13
|
+
import fc from 'fast-check';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
sanitizeHostname,
|
|
17
|
+
sanitizePathSegment,
|
|
18
|
+
backportMaskToOriginalText,
|
|
19
|
+
} from '../src/popularity-vote-sanitizer.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Helper to test if it is possible to start from the full text
|
|
23
|
+
* and remove single characters to end up with the reduced text
|
|
24
|
+
* (not changing order).
|
|
25
|
+
*
|
|
26
|
+
* Example:
|
|
27
|
+
* 1) textCanBeDerivedByRemovingChars({ fullText: 'banana', reducedTo: 'aana' }) ==> true
|
|
28
|
+
* 2) textCanBeDerivedByRemovingChars({ fullText: 'banana', reducedTo: 'xyz' }) ==> false
|
|
29
|
+
*/
|
|
30
|
+
function textCanBeDerivedByRemovingChars({ fullText, reducedTo }) {
|
|
31
|
+
let full = 0;
|
|
32
|
+
let reduced = 0;
|
|
33
|
+
while (reduced < reducedTo.length && full < fullText.length) {
|
|
34
|
+
if (reducedTo[reduced] === fullText[full]) {
|
|
35
|
+
reduced++;
|
|
36
|
+
}
|
|
37
|
+
full++;
|
|
38
|
+
}
|
|
39
|
+
return reduced === reducedTo.length;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('#sanitizeHostname', function () {
|
|
43
|
+
describe('should not modify safe hostnames', function () {
|
|
44
|
+
for (const safeHostname of [
|
|
45
|
+
'example.com',
|
|
46
|
+
'productionresultssa11.blob.core.windows.net',
|
|
47
|
+
'www.google.com',
|
|
48
|
+
'docs.google.com',
|
|
49
|
+
'hackmd.io',
|
|
50
|
+
'audit.verified-data.com',
|
|
51
|
+
'www.google.de',
|
|
52
|
+
'stackoverflow.com',
|
|
53
|
+
'deepwiki.com',
|
|
54
|
+
'discourt.com',
|
|
55
|
+
'taxi.booking.com',
|
|
56
|
+
'ghostery.1password.com',
|
|
57
|
+
'www.figma.com',
|
|
58
|
+
'signin.aws.amazon.com',
|
|
59
|
+
'www.nytimes.com',
|
|
60
|
+
'www.sueddeutsche.de',
|
|
61
|
+
'hilfe.sueddeutsche.de',
|
|
62
|
+
'www.bild.de',
|
|
63
|
+
'www.youtube.com',
|
|
64
|
+
'www.instagram.com',
|
|
65
|
+
'www.tiktok.com',
|
|
66
|
+
'www.tiktok.com',
|
|
67
|
+
'mastodon.social',
|
|
68
|
+
'github.com',
|
|
69
|
+
'www.nbcnews.com',
|
|
70
|
+
'www.amazon.com',
|
|
71
|
+
'www.otto.de',
|
|
72
|
+
'us-east-1.signin.aws',
|
|
73
|
+
'us-east-1.console.aws.amazon.com',
|
|
74
|
+
'wiki.archlinux.org',
|
|
75
|
+
'chat.deepseek.com',
|
|
76
|
+
'chat.mistral.ai',
|
|
77
|
+
'www.finanzen.net',
|
|
78
|
+
'en.wikipedia.org',
|
|
79
|
+
'www.wsj.com',
|
|
80
|
+
'www.lemonde.fr',
|
|
81
|
+
'www.theguardian.com',
|
|
82
|
+
'www.reddit.com',
|
|
83
|
+
'www.reuters.com',
|
|
84
|
+
'app.tuta.com',
|
|
85
|
+
'support.microsoft.com',
|
|
86
|
+
'alexandros-mpomponieres.gr',
|
|
87
|
+
'мой-сайт.рф', // [Cyrillic]
|
|
88
|
+
'www.мой-сайт.рф', // [Cyrillic]
|
|
89
|
+
'www.%D0%BC%D0%BE%D0%B9-%D1%81%D0%B0%D0%B9%D1%82.%D1%80%D1%84', // [Cyrillic] www.мой-сайт.рф
|
|
90
|
+
'մեդիա.ամ', // [Armenia]
|
|
91
|
+
'www.մեդիա.ամ', // [Armenia]
|
|
92
|
+
'www.%D5%B4%D5%A5%D5%A4%D5%AB%D5%A1.%D5%A1%D5%B4', // [Armenia] www.մեդիա.ամ
|
|
93
|
+
]) {
|
|
94
|
+
it(`- ${safeHostname}`, function () {
|
|
95
|
+
expect(sanitizeHostname(safeHostname)).to.eql(safeHostname);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('should mask unsafe parts in hostnames', function () {
|
|
101
|
+
for (const { unsafe, safe } of [
|
|
102
|
+
{
|
|
103
|
+
unsafe: 'c3fbed0c-9713-4c89-8074-73dc15b0b34e.example.com',
|
|
104
|
+
safe: '#??#.example.com',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
unsafe: 'c3fbed0c-9713-4c89-8074-73dc15b0b34e.example.com',
|
|
108
|
+
safe: '#??#.example.com',
|
|
109
|
+
},
|
|
110
|
+
]) {
|
|
111
|
+
it(`- ${unsafe} ==> ${safe}`, function () {
|
|
112
|
+
expect(sanitizeHostname(unsafe)).to.eql(safe);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('[property based testing]', function () {
|
|
118
|
+
it('should only remove, but never add characters', function () {
|
|
119
|
+
fc.assert(
|
|
120
|
+
fc.property(fc.webUrl(), (url) => {
|
|
121
|
+
const { hostname } = new URL(url);
|
|
122
|
+
const sanitized = sanitizeHostname(hostname);
|
|
123
|
+
if (!sanitized.includes('#??#')) {
|
|
124
|
+
return sanitized === hostname;
|
|
125
|
+
}
|
|
126
|
+
if (sanitized.length > hostname.length) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const nonMasked = sanitized.replaceAll('#??#', '');
|
|
130
|
+
return textCanBeDerivedByRemovingChars({
|
|
131
|
+
fullText: hostname,
|
|
132
|
+
reducedTo: nonMasked,
|
|
133
|
+
});
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('#sanitizePathSegment', function () {
|
|
141
|
+
describe('should not modify safe URL path segments', function () {
|
|
142
|
+
for (const safePath of [
|
|
143
|
+
'actions-results',
|
|
144
|
+
'logs',
|
|
145
|
+
'job',
|
|
146
|
+
'job-logs.txt',
|
|
147
|
+
'maps',
|
|
148
|
+
'place',
|
|
149
|
+
'presentation',
|
|
150
|
+
'd',
|
|
151
|
+
'document',
|
|
152
|
+
'edit',
|
|
153
|
+
'projects',
|
|
154
|
+
'page-inspector',
|
|
155
|
+
'dir',
|
|
156
|
+
'questions',
|
|
157
|
+
'how-to-programmatically-skip-a-test-in-mocha',
|
|
158
|
+
'search',
|
|
159
|
+
'invite',
|
|
160
|
+
'en-gb',
|
|
161
|
+
'promotions',
|
|
162
|
+
'free-taxi',
|
|
163
|
+
'ghostery',
|
|
164
|
+
'@ghostery',
|
|
165
|
+
'vaults',
|
|
166
|
+
'all',
|
|
167
|
+
'allitems',
|
|
168
|
+
'tags',
|
|
169
|
+
'proto',
|
|
170
|
+
'Ghostery-Search',
|
|
171
|
+
'oauth',
|
|
172
|
+
'2026',
|
|
173
|
+
'03',
|
|
174
|
+
'24',
|
|
175
|
+
'us',
|
|
176
|
+
'politics',
|
|
177
|
+
'saudi-prince-iran-trump.html',
|
|
178
|
+
'science',
|
|
179
|
+
'archaeology-egypt-hatshepsut.html',
|
|
180
|
+
'politik',
|
|
181
|
+
'muenchen',
|
|
182
|
+
'neuer-login',
|
|
183
|
+
'regional',
|
|
184
|
+
'watch',
|
|
185
|
+
'heidiklum',
|
|
186
|
+
'reel',
|
|
187
|
+
'explore',
|
|
188
|
+
'@',
|
|
189
|
+
'@houseofhighlights',
|
|
190
|
+
'@NBA@sportsbots.xyz',
|
|
191
|
+
'privacy-policy',
|
|
192
|
+
'commits',
|
|
193
|
+
'main',
|
|
194
|
+
'commit',
|
|
195
|
+
'pull',
|
|
196
|
+
'ghostery-extension',
|
|
197
|
+
'38364',
|
|
198
|
+
'specials',
|
|
199
|
+
'unaffordable-america-economy-inflation-us-jobs-prices-bills-stocks',
|
|
200
|
+
's',
|
|
201
|
+
'Apple-iPhone-Version-Desert-Titanium',
|
|
202
|
+
'dp',
|
|
203
|
+
'platform',
|
|
204
|
+
'login',
|
|
205
|
+
'cloudwatch',
|
|
206
|
+
'home',
|
|
207
|
+
'capricorn86',
|
|
208
|
+
'happy-dom',
|
|
209
|
+
'title',
|
|
210
|
+
'Main_page',
|
|
211
|
+
'Frequently_asked_questions',
|
|
212
|
+
'General_troubleshooting',
|
|
213
|
+
'a',
|
|
214
|
+
'chat',
|
|
215
|
+
's',
|
|
216
|
+
'nachricht',
|
|
217
|
+
'aktien',
|
|
218
|
+
'wiki',
|
|
219
|
+
'articles',
|
|
220
|
+
'en',
|
|
221
|
+
'opinion',
|
|
222
|
+
'article',
|
|
223
|
+
'italy-giorgia-meloni-s-failed-gamble-on-judicial-reform_6751782_23.html',
|
|
224
|
+
'lifeandstyle',
|
|
225
|
+
'mar',
|
|
226
|
+
'do-we-really-need-eight-hours-sleep-night',
|
|
227
|
+
'popular',
|
|
228
|
+
'comments',
|
|
229
|
+
'1s2fh5u',
|
|
230
|
+
'curiosity_wheels_taken_yesterday_showing_the',
|
|
231
|
+
'sustainability',
|
|
232
|
+
'bpclsembcorp-jv-wins-indias-lowest-green-hydrogen-supply-contract-2026-03-24',
|
|
233
|
+
'mail',
|
|
234
|
+
'c++',
|
|
235
|
+
'a+b', // because we never want to increase size ("a+b" smaller than "#??#")
|
|
236
|
+
'+@Matthiasberger_',
|
|
237
|
+
'@Matthiasberger_',
|
|
238
|
+
'@ghostery_adblocker',
|
|
239
|
+
'whotracksme',
|
|
240
|
+
'en-us',
|
|
241
|
+
'windows',
|
|
242
|
+
'25',
|
|
243
|
+
'technology',
|
|
244
|
+
'social-media-trial-verdict.html',
|
|
245
|
+
'cegkatalogus',
|
|
246
|
+
'%ce%b4%ce%b9%ce%b5%cf%8d%ce%b8%cf%85%ce%bd%cf%83%ce%b7',
|
|
247
|
+
'armodiotites',
|
|
248
|
+
'%CE%B2%CE%B1%CF%80%CF%84%CE%B9%CF%83%CF%84%CE%B9%CE%BA%CE%B1-%CE%BA%CE%BF%CF%81%CE%B9%CF%84%CF%83%CE%B9', // [Greek] βαπτιστικα-κοριτσι/σετ-βαπτισης-κοριτσι
|
|
249
|
+
'%CF%83%CE%B5%CF%84-%CE%B2%CE%B1%CF%80%CF%84%CE%B9%CF%83%CE%B7%CF%82-%CE%BA%CE%BF%CF%81%CE%B9%CF%84%CF%83%CE%B9', // [Greek] σετ-βαπτισης-κοριτσι
|
|
250
|
+
'%cf%83%cf%87%ce%bf%ce%bb%ce%b9%ce%ba%ce%ae-%ce%ba%ce%bf%ce%b9%ce%bd%cf%8c%cf%84%ce%b7%cf%84%ce%b1', // [Greek] σχολική-κοινότητα
|
|
251
|
+
'%d9%82%d8%b1%d8%a7%d8%b1-%d8%b1%d9%82%d9%85-255-%d8%a7%d9%84%d9%85%d8%a4%d8%b1%d8%ae-%d9%81%d9%8a-25-%d9%81%d9%8a%d9%81%d8%b1%d9%8a-2024-%d8%a7%d9%84%d8%b0%d9%8a-%d9%8a%d8%ad%d8%af%d8%af-%d9%85%d8%b9', // [Arabic] قرار-رقم-255-المؤرخ-في-25-فيفري-2024-الذي-يحدد-مع
|
|
252
|
+
'მაგალითი', // [Georgian]
|
|
253
|
+
'%E1%83%9B%E1%83%90%E1%83%92%E1%83%90%E1%83%9A%E1%83%98%E1%83%97%E1%83%98', // [Georgian] მაგალითი
|
|
254
|
+
'%E1%83%97%E1%83%98%E1%83%A1-%E1%83%98%E1%83%A1-%E1%83%90-%E1%83%9A%E1%83%9D%E1%83%9C%E1%83%92%E1%83%94%E1%83%A0-%E1%83%94%E1%83%A5%E1%83%96%E1%83%94%E1%83%9B%E1%83%9E%E1%83%9A', // [Georgian] თის-ის-ა-ლონგერ-ექზემპლ
|
|
255
|
+
'це-є-тест-довшого-урл', // [Cyrillic letters]
|
|
256
|
+
'%D1%86%D0%B5-%D1%94-%D1%82%D0%B5%D1%81%D1%82-%D0%B4%D0%BE%D0%B2%D1%88%D0%BE%D0%B3%D0%BE-%D1%83%D1%80%D0%BB', // [Cyrillic letters] це-є-тест-довшого-урл
|
|
257
|
+
'հարցազրույց', // [Armenia]
|
|
258
|
+
'%D5%B0%D5%A1%D6%80%D6%81%D5%A1%D5%A6%D6%80%D5%B8%D6%82%D5%B5%D6%81', // [Armenia] հարցազրույց
|
|
259
|
+
]) {
|
|
260
|
+
it(`- "${safePath}"`, function () {
|
|
261
|
+
expect(sanitizePathSegment(safePath)).to.eql(safePath);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe('should mask unsafe parts in URL path segments', function () {
|
|
267
|
+
for (const { unsafe, safe } of [
|
|
268
|
+
{
|
|
269
|
+
unsafe: 'c3fbed0c-9713-4c89-8074-73dc15b0b34e',
|
|
270
|
+
safe: '#??#',
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
unsafe: 'workflow-job-run-5264e576-3c6f-51f6-f055-fab409685f20',
|
|
274
|
+
safe: 'workflow-job-run-#??#',
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
unsafe: '@45.5335096,9.5914633,6z',
|
|
278
|
+
safe: '#??#',
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
unsafe:
|
|
282
|
+
'data=!4m6!3m5!1s0x14e08328df81f339:0x54f774f3db260cf6!8m2!3d34.8714923!4d33.6076734!16zL20vMDhjdnl0',
|
|
283
|
+
safe: '#??#',
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
unsafe:
|
|
287
|
+
'iran-news-heute-lars-klingbeil-plaediert-fuer-benzin-preisobergrenzen-a-51a9d808-0b50-457b-9f02-3b57ea73c1e2',
|
|
288
|
+
safe: 'iran-news-heute-lars-klingbeil-plaediert-fuer-benzin-preisobergrenzen-a-#??#',
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
unsafe: '9XpbVvYa_lFqDCGEWIpICseNdEAuxcq4DgMs0JDfMwi3',
|
|
292
|
+
safe: '#??#',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
unsafe: 'HniR4NtMZLqRsFeuXZ-t_h',
|
|
296
|
+
safe: '#??#',
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
unsafe: '9796qb15-x17b-79x6-4xv2-qv3v28px9x22',
|
|
300
|
+
safe: '#??#',
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
unsafe: 'rn4f8296-8394-781z-rj32-f0zf3rj0r651',
|
|
304
|
+
safe: '#??#',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
unsafe: 'LARNACA+INTERNATIONAL+AIRPORT',
|
|
308
|
+
safe: '#??#',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
unsafe: '@48.1464153,11.5525926,11.75z',
|
|
312
|
+
safe: '#??#',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
unsafe: 'data=!4m3!15m2!1m1!1s%2Fg%2F11s4_3sshh',
|
|
316
|
+
safe: '#??#',
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
unsafe: '48.1564796,11.6311754',
|
|
320
|
+
safe: '#??#',
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
unsafe: 'Wiener+Platz,+81667+M%C3%BCnchen',
|
|
324
|
+
safe: '#??#',
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
unsafe: '@48.1565756,11.6231737,15.29z',
|
|
328
|
+
safe: '#??#',
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
unsafe:
|
|
332
|
+
'data=!4m9!4m8!1m0!1m5!1m1!1s0x479e7580f08e3557:0x9ebb96a9af940857!2m2!1d11.5963084!2d48.1344051!3e1',
|
|
333
|
+
safe: '#??#',
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
unsafe: '32723167',
|
|
337
|
+
safe: '#??#',
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
unsafe: 'Prinzenstra%C3%9Fe+34,+10969+Berlin',
|
|
341
|
+
safe: '#??#',
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
unsafe:
|
|
345
|
+
'data=!4m8!4m7!1m2!1m1!1s0x47a84e27f6193ab3:0xdbe499a344366b2b!1m2!1m1!1s0x47a84e2da4f0f1d7:0x76a0f390734091c0!3e0',
|
|
346
|
+
safe: '#??#',
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
unsafe:
|
|
350
|
+
'when-writing-shards-there-is-a_9db8c020-ea05-4c3e-a9bb-41e877400db7',
|
|
351
|
+
safe: 'when-writing-shards-there-is-#??#',
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
unsafe:
|
|
355
|
+
'ZnOXrIKBwG5Hbsq28oB7cH4MbLLwZUbcA5LvUq8LG8aMe-hoTi4SdcC30NgUj0jtw4_HbaODtTyXwYAI765zmy5vRKeUjbCG-rk4H69cHxfy3ogjMlD2LXG4PG89Jul_Y6XnlFtIg7EId0L2u4-r1Ksg1ggG9YiP3Tr1jiyFMb4cPJk0U7rBGdMJbsLhh1b5kR1l7RqysjBzkp-McAAtwYa80E9Um7Cg5WMKwa3gHsgVy6VgxgCq0aWX8H5huMdh2xKHSLIZG1MbT3q5dXeOi-2GCFMMAggfqO99aDjbmsuGtRn2ipg-cENXNoOtkpJqqc0x8SJIuU6RePpaX1q7uF76hcWHLPPMqFRRwsPVZ1ZvPJyWJS1erITnQaEoHROu03FC5GOU2KJpQIRlKAtuYEhsddrBXi-Ry0gIXS9Q12msXopYA6qo6iiraRNCQLgpb0A1AfDl44alSgkSLHiYKIbxtYYNFcIaCBI3ms-0XzRBIo6kr9JTkwJOXXPsT1wTPyPrv8enAK7D6dXMhW81Dck5WZusefLIdTKqemP24Iq=',
|
|
356
|
+
safe: '#??#',
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
unsafe: 'X3PHB-LW4',
|
|
360
|
+
safe: '#??#',
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
unsafe: '4a405zik6imv2zpvbcyjbvmzny',
|
|
364
|
+
safe: '#??#',
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
unsafe: 'oy7juqz5atpcyfqqiakaudysof',
|
|
368
|
+
safe: '#??#',
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
unsafe: '1cuy4g2rcnoszcic0kgp9orfv0',
|
|
372
|
+
safe: '#??#',
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
unsafe: 'ahnh704vx6nomjylyx8hnbtixl',
|
|
376
|
+
safe: '#??#',
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
unsafe: 'GXFNk9mpiyKYXizAwhE9VE',
|
|
380
|
+
safe: '#??#',
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
unsafe: 'VhyRJ31lL3CL00OZ7kiNfL',
|
|
384
|
+
safe: '#??#',
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
unsafe: '5ztlf8Dazo-Oyj8kqVZwv7aSqg5ZPBlu3_cIbhgJdQfX',
|
|
388
|
+
safe: '#??#',
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
unsafe: 'russland-spione-drohnen-manager-anschlag-li.3458250',
|
|
392
|
+
safe: 'russland-spione-drohnen-manager-anschlag-li#??#',
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
unsafe: 'krieg-trump-iran-verhandlungen-pakistan-li.3457876',
|
|
396
|
+
safe: 'krieg-trump-iran-verhandlungen-pakistan-li#??#',
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
unsafe:
|
|
400
|
+
'muenchen-buergermeisterin-koalition-gruene-stellvertreterin-dominik-krause-li.3457909',
|
|
401
|
+
safe: 'muenchen-buergermeisterin-koalition-gruene-stellvertreterin-dominik-krause-li#??#',
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
unsafe:
|
|
405
|
+
'mario-gomez-fc-bayern-legende-hat-millionen-stress-mit-denkmalamt-69be6e5be2b1286a2c524d8a',
|
|
406
|
+
safe: 'mario-gomez-fc-bayern-legende-hat-millionen-stress-mit-denkmalamt-#??#',
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
unsafe: 'kmwIeEkFYLf',
|
|
410
|
+
safe: '#??#',
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
unsafe: 'DWOQbyEjvCQ',
|
|
414
|
+
safe: '#??#',
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
unsafe: '7620632578755710221',
|
|
418
|
+
safe: '#??#',
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
unsafe: 'a3bdcc71e74e66d1607d2490e197e675ae8b2b7b',
|
|
422
|
+
safe: '#??#',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
unsafe: 'B0DHJ9SCJ4',
|
|
426
|
+
safe: '#??#',
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
unsafe:
|
|
430
|
+
'songmics-gartenliege-1-st-sonnenliege-6cm-dicker-matratze-aluminium-atmungsaktiv-S0B190PP',
|
|
431
|
+
safe: 'songmics-gartenliege-1-st-sonnenli#??#icker-matratze-aluminium-atmungs#??#',
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
unsafe: 'd-906766b033',
|
|
435
|
+
safe: 'd-9#??#',
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
unsafe: '5b1f0808-18b9-4602-8100-6147f2cc9812',
|
|
439
|
+
safe: '#??#',
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
unsafe: 'Spittelmarkt,+10117+Berlin',
|
|
443
|
+
safe: '#??#',
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
unsafe:
|
|
447
|
+
'strategischer-rueckzug-bayer-aktie-schwach-grossaktionaer-trennt-sich-von-aktien-im-dreistelligen-millionenwert-00-15573032',
|
|
448
|
+
safe: 'strategischer-rueckzug-bayer-aktie-schwach-grossaktionaer-trennt-sich-von-aktien-im-dreistelligen-millionenwert-00-#??#',
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
unsafe: '1954973424486608928',
|
|
452
|
+
safe: '#??#',
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
unsafe: 'Jeffrey_W._Ubben',
|
|
456
|
+
safe: 'Jeffr#??#',
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
unsafe: 'fox-nominates-valueact-ceo-jeffrey-ubben-to-board-1443530308',
|
|
460
|
+
safe: 'fox-nominates-valueact-ceo-jeffrey-ubben-to-board-#??#',
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
unsafe: 'RUiFUYKzkz',
|
|
464
|
+
safe: '#??#',
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
unsafe:
|
|
468
|
+
'uF8IEAt2DG_hdNoik_OC5zrh3lt2ncoIWYd1Q-_N-gz-FyCi9Kb6pXEafGc9cCJBEIhIbl_Oj0aPe8yKGj3ZRcIAB4vbNyjCYS-mFVJLSVK-ygPdXpiV4JGdsH1Qsv',
|
|
469
|
+
safe: '#??#',
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
unsafe:
|
|
473
|
+
'vROTCK_qdTD3DStjilJEWWtP1zOO3iVFx9glCW0J8C6IanZ8B4ALln45mK0rj8gf4-0MOMkYOenRqUymMhYkIz==',
|
|
474
|
+
safe: '#??#',
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
unsafe: 'Jhf6-Ie-7x-3',
|
|
478
|
+
safe: '#??#',
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
unsafe: 'EaXSrHR--S-3',
|
|
482
|
+
safe: '#??#',
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
unsafe:
|
|
486
|
+
'free-up-drive-space-in-windows-85529ccb-c365-490d-b548-831022bc9b32',
|
|
487
|
+
safe: 'free-up-drive-space-in-windows-#??#',
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
unsafe:
|
|
491
|
+
'this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text',
|
|
492
|
+
safe: 'this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-some-huge-text-this-is-s#??#',
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
unsafe:
|
|
496
|
+
'5662_3290_-ac-dc-hegesztogep-acelhegeszto-elektroda-acetilen-palack-aggregator-akkumulatortolto-aluminium-hegesztogep-argon-palack-avi-hegesztogep-awi-elektroda-szinei-awi-hegesztes-awi-hegesztogep-badogos-paka-borkoteny-co-hegesztogep-CO2-palack-corgon-palack-csaphegeszto-egoszarak-elektroda-tipusok-elfelrako-elektrodak-femszoras-fogyoelektrodas-hegesztogep-forrasztas-gazpalack-toltes-hasznalt-co-palack-hasznalt-hegesztogep-hegesztes-hegesztes-dunakeszi-hegesztes-kreativitas-hegeszteskreativitas-hegesztestechnika-hegesztestechnika-dunakeszi-hegesztestechnikai-eljarasok-hegeszto-elektroda-tipusok-hegeszto-eszkozok-hegeszto-palack-hegeszto-transzformatorok-hegesztoanyagok-hegesztoelektroda-hegesztoeljarasok-hegesztogep-hegesztogep-alkatresz-hegesztogep-elado-hegesztogep-felulvizsgalat-hegesztogep-gyartas-hegesztogep-javitas-hegesztogep-kolcsonzes-hegesztogep-szerviz-hegesztokabel-hegesztopajzs-hegesztopalca-hegesztopisztoly-helium-palack-hosszu-ivvel-hegesztes-inverter-inverteres-hegesztogep-ipari-ezust-ipari-gazok-iv-lang-hegesztes-ivhegeszto-kevert-gazpalack-kis-langhegeszto-labszarvedo-langhegesztes-langhegeszto-lezersugaras-hegesztes-mag-hegesztogep-markolat-mig-hegesztogepek-MIG-WIG-eljaras-muanyag-hegesztogep-muanyaghegesztes-munkakabel-nagyfrekvencias-hegesztogep-hegesztes-es-kreativitas-nitrogen-palack-nyomascsokkento-oxigenpalack-ontvenypalcak-plazmahegesztes-plazmavago-ponthegesztes-ponthegeszto-porbeles-huzal-propanbutan-palack-reduktor-savallo-huzalok-tig-hegesztogep-vagokorong-vas-langhegesztese-vedogazas-hegesztogep-vedogazos-ivhegesztes-vedokesztyu-vedoszemuveg-vonalhegesztes-vonalhegeszto-wolfram-elektroda-wolframelektrodas-ivhegesztes-Plazma-iv-Kft-Dunakeszi.html',
|
|
497
|
+
safe: '5662_3290_-ac-dc-hegesztogep-acelhegeszto-elektroda-acetilen-palack-aggregator-akkumulatortolto-aluminium-hegesztogep-argon-#??#',
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
unsafe:
|
|
501
|
+
'set-vaptisis-koritsi-ksilini-troley-elena-manakou-origami-bird-7450-1499-17398-17424-17429-17430-17431-17432-17433-17434-17435-detail',
|
|
502
|
+
safe: 'set-vaptisis-koritsi-ksilini-troley-elena-manakou-origami-bird-7450-1499-17398-17424-17429-17430-17431-17432-17433-17434-174#??#',
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
// simulate mixed text: takes a safe Greek text and appends a UUID at the end (which should be masked)
|
|
506
|
+
unsafe:
|
|
507
|
+
'%CE%B2%CE%B1%CF%80%CF%84%CE%B9%CF%83%CF%84%CE%B9%CE%BA%CE%B1-%CE%BA%CE%BF%CF%81%CE%B9%CF%84%CF%83%CE%B9-b6100c59-d9b4-412a-bf57-e0925354971a',
|
|
508
|
+
safe: '%CE%B2%CE%B1%CF%80%CF%84%CE%B9%CF%83%CF%84%CE%B9%CE%BA%CE%B1-%CE%BA%CE%BF%CF%81%CE%B9%CF%84%CF%83%CE%B9-#??#',
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
// simulate mixed text: takes a safe Arabic text and appends a UUID at the end (which should be masked)
|
|
512
|
+
unsafe:
|
|
513
|
+
'%d9%82%d8%b1%d8%a7%d8%b1-%d8%b1%d9%82%d9%85-255-%d8%a7%d9%84%d9%85%d8%a4%d8%b1%d8%ae-%d9%81%d9%8a-25-%d9%81%d9%8a%d9%81%d8%b1%d9%8a-2024-%d8%a7%d9%84%d8%b0%d9%8a-%d9%8a%d8%ad%d8%af%d8%af-%d9%85%d8%b9-b6100c59-d9b4-412a-bf57-e0925354971a',
|
|
514
|
+
safe: '%d9%82%d8%b1%d8%a7%d8%b1-%d8%b1%d9%82%d9%85-255-%d8%a7%d9%84%d9%85%d8%a4%d8%b1%d8%ae-%d9%81%d9%8a-25-%d9%81%d9%8a%d9%81%d8%b1%d9%8a-2024-%d8%a7%d9%84%d8%b0%d9%8a-%d9%8a%d8%ad#??#',
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
// simulate mixed text: takes a safe text with Cyrillic letters and appends a UUID at the end (which should be masked)
|
|
518
|
+
unsafe: 'це-є-тест-довшого-урл-b6100c59-d9b4-412a-bf57-e0925354971a',
|
|
519
|
+
safe: 'це-є-тест-довшого-урл-#??#',
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
// simulate mixed text: takes a safe text with Cyrillic letters and appends a UUID at the end (which should be masked)
|
|
523
|
+
unsafe:
|
|
524
|
+
'%D1%86%D0%B5-%D1%94-%D1%82%D0%B5%D1%81%D1%82-%D0%B4%D0%BE%D0%B2%D1%88%D0%BE%D0%B3%D0%BE-%D1%83%D1%80%D0%BB-b6100c59-d9b4-412a-bf57-e0925354971a',
|
|
525
|
+
safe: '%D1%86%D0%B5-%D1%94-%D1%82%D0%B5%D1%81%D1%82-%D0%B4%D0%BE%D0%B2%D1%88%D0%BE%D0%B3%D0%BE-%D1%83%D1%80%D0%BB-#??#',
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
// simulate mixed text: takes a safe text with Armenian letters and appends a UUID at the end (which should be masked)
|
|
529
|
+
unsafe:
|
|
530
|
+
'%D5%B0%D5%A1%D6%80%D6%81%D5%A1%D5%A6%D6%80%D5%B8%D6%82%D5%B5%D6%81-b6100c59-d9b4-412a-bf57-e0925354971a',
|
|
531
|
+
safe: '%D5%B0%D5%A1%D6%80%D6%81%D5%A1%D5%A6%D6%80%D5%B8%D6%82%D5%B5%D6%81-#??#',
|
|
532
|
+
},
|
|
533
|
+
]) {
|
|
534
|
+
it(`- ${unsafe} ==> ${safe}`, function () {
|
|
535
|
+
const sanitized = sanitizePathSegment(unsafe);
|
|
536
|
+
if (sanitized !== safe) {
|
|
537
|
+
assert.fail(
|
|
538
|
+
`mismatch for example:\n${unsafe} (was the actual result)\n==>\n${sanitized}\n${safe} (would have been correct)`,
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
describe('[property based testing]', function () {
|
|
546
|
+
it('should only remove, but never add characters', function () {
|
|
547
|
+
fc.assert(
|
|
548
|
+
fc.property(fc.webUrl(), (url) => {
|
|
549
|
+
const { pathname } = new URL(url);
|
|
550
|
+
for (const pathSegment of pathname.split('/').filter((x) => x)) {
|
|
551
|
+
const sanitized = sanitizePathSegment(pathSegment);
|
|
552
|
+
if (!sanitized.includes('#??#')) {
|
|
553
|
+
return sanitized === pathSegment;
|
|
554
|
+
}
|
|
555
|
+
if (sanitized.length > pathSegment.length) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
const nonMasked = sanitized.replaceAll('#??#', '');
|
|
559
|
+
return textCanBeDerivedByRemovingChars({
|
|
560
|
+
fullText: pathSegment,
|
|
561
|
+
reducedTo: nonMasked,
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
}),
|
|
565
|
+
);
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
describe('#backportMaskToOriginalText', function () {
|
|
571
|
+
for (const { originalText, maskedDecodedText, expected } of [
|
|
572
|
+
{
|
|
573
|
+
originalText: 'dummy',
|
|
574
|
+
maskedDecodedText: '#??#',
|
|
575
|
+
expected: '#??#',
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
originalText: '%C3%A4%c3%a4',
|
|
579
|
+
maskedDecodedText: '%C3%A4%c3%a4',
|
|
580
|
+
expected: '%C3%A4%c3%a4',
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
originalText: 'before-a3a95e19-5411-4444-9db9-0121fe86fe57-after',
|
|
584
|
+
maskedDecodedText: 'before-#??#-after',
|
|
585
|
+
expected: 'before-#??#-after',
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
originalText:
|
|
589
|
+
'%C3%A4-a3a95e19-5411-4444-9db9-0121fe86fe57-%c3%a4-a3a95e19-5411-4444-9db9-0121fe86fe57',
|
|
590
|
+
maskedDecodedText: 'ä-#??#-ä-#??#',
|
|
591
|
+
expected: '%C3%A4-#??#-%c3%a4-#??#',
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
originalText:
|
|
595
|
+
'%C3%A4%C3%A4-a3a95e19-5411-4444-9db9-0121fe86fe57-%c3%a4-a3a95e19-5411-4444-9db9-0121fe86fe57',
|
|
596
|
+
maskedDecodedText: 'ää-#??#-ä-#??#',
|
|
597
|
+
expected: '%C3%A4%C3%A4-#??#-%c3%a4-#??#',
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
originalText: 'data=!4m3!15m2!1m1!1s%2Fg%2F11s4_3sshh',
|
|
601
|
+
maskedDecodedText: '#??#',
|
|
602
|
+
expected: '#??#',
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
originalText:
|
|
606
|
+
'%d9%82%d8%b1%d8%a7%d8%b1-%d8%b1%d9%82%d9%85-255-%d8%a7%d9%84%d9%85%d8%a4%d8%b1%d8%ae-%d9%81%d9%8a-25-%d9%81%d9%8a%d9%81%d8%b1%d9%8a-2024-%d8%a7%d9%84%d8%b0%d9%8a-%d9%8a%d8%ad%d8%af%d8%af-%d9%85%d8%b9-b6100c59-d9b4-412a-bf57-e0925354971a',
|
|
607
|
+
maskedDecodedText: 'قرار-رقم-255-المؤرخ-في-25-فيفري-2024-الذي-يح#??#',
|
|
608
|
+
expected:
|
|
609
|
+
'%d9%82%d8%b1%d8%a7%d8%b1-%d8%b1%d9%82%d9%85-255-%d8%a7%d9%84%d9%85%d8%a4%d8%b1%d8%ae-%d9%81%d9%8a-25-%d9%81%d9%8a%d9%81%d8%b1%d9%8a-2024-%d8%a7%d9%84%d8%b0%d9%8a-%d9%8a%d8%ad#??#',
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
originalText:
|
|
613
|
+
'Cross-country_skiing_at_the_2026_Winter_Olympics_%E2%80%93_Men%27s_50_kilometre_classical',
|
|
614
|
+
maskedDecodedText:
|
|
615
|
+
'Cross-country_skiing_at_th#??#inter_Olympics_–_Me#??#ometre_classical',
|
|
616
|
+
expected:
|
|
617
|
+
'Cross-country_skiing_at_th#??#inter_Olympics_%E2%80%93_Me#??#ometre_classical',
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
originalText:
|
|
621
|
+
'Universidade%20NOVA%20de%20Lisboa%20-%20Faculdade%20de%20Ci%C3%AAncias%20e%20Tecnologia%20(FCT%20NOVA).html',
|
|
622
|
+
maskedDecodedText: 'Universidade NOV#??#Faculdade de Ciência#??#',
|
|
623
|
+
expected: 'Universidade%20NOV#??#Faculdade%20de%20Ci%C3%AAncia#??#',
|
|
624
|
+
},
|
|
625
|
+
]) {
|
|
626
|
+
it(`- ${originalText} and ${maskedDecodedText}`, function () {
|
|
627
|
+
const actual = backportMaskToOriginalText(
|
|
628
|
+
originalText,
|
|
629
|
+
decodeURIComponent(originalText),
|
|
630
|
+
maskedDecodedText,
|
|
631
|
+
);
|
|
632
|
+
expect(actual).to.eql(expected);
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
});
|