@whotracksme/reporting 5.1.37 → 5.2.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 +33 -0
- package/package.json +1 -1
- package/reporting/example/index.js +1 -0
- package/reporting/snapshots/0005/events.log.br +0 -0
- package/reporting/snapshots/0005/snapshot.json +6933 -0
- package/reporting/snapshots/0006/events.log.br +0 -0
- package/reporting/snapshots/0006/snapshot.json +5489 -0
- package/reporting/src/request/config.js +0 -2
- package/reporting/src/request/index.js +93 -91
- package/reporting/src/request/utils/utils.js +0 -13
- package/reporting/src/request/utils/webrequest.js +0 -1
- package/reporting/src/url-analyzer.js +2 -2
- package/reporting/test/request/index.test.js +2 -2
- package/reporting/test/url-analyzer.spec.js +6 -6
|
@@ -24,7 +24,6 @@ import QSWhitelist2 from './qs-whitelist2.js';
|
|
|
24
24
|
import TempSet from './utils/temp-set.js';
|
|
25
25
|
import { HashProb, shouldCheckToken } from './hash/index.js';
|
|
26
26
|
import { COOKIE_MODE, VERSION } from './config.js';
|
|
27
|
-
import { shuffle } from './utils/utils.js';
|
|
28
27
|
import random from '../random.js';
|
|
29
28
|
|
|
30
29
|
import CookieContext from './steps/cookie-context.js';
|
|
@@ -54,6 +53,7 @@ export default class RequestReporter {
|
|
|
54
53
|
logger.info('Tracker', event, 'with url:', state.url);
|
|
55
54
|
},
|
|
56
55
|
isRequestAllowed = () => false,
|
|
56
|
+
dryRunMode = false,
|
|
57
57
|
},
|
|
58
58
|
) {
|
|
59
59
|
this.settings = settings;
|
|
@@ -63,6 +63,14 @@ export default class RequestReporter {
|
|
|
63
63
|
this.onTrackerInteraction = onTrackerInteraction;
|
|
64
64
|
this.getBrowserInfo = getBrowserInfo;
|
|
65
65
|
this.isRequestAllowed = isRequestAllowed;
|
|
66
|
+
if (dryRunMode) {
|
|
67
|
+
logger.warn(
|
|
68
|
+
'[DRY_RUN] dry-run mode is enabled. Fingerprinting removal is disabled.',
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
logger.debug('Fingerprinting removal is enabled');
|
|
72
|
+
}
|
|
73
|
+
this.dryRunMode = dryRunMode;
|
|
66
74
|
this.VERSION = VERSION;
|
|
67
75
|
this.LOG_KEY = 'attrack';
|
|
68
76
|
this.debug = false;
|
|
@@ -125,31 +133,6 @@ export default class RequestReporter {
|
|
|
125
133
|
return false;
|
|
126
134
|
}
|
|
127
135
|
|
|
128
|
-
obfuscate(s, method) {
|
|
129
|
-
// used when action != 'block'
|
|
130
|
-
// default is a placeholder
|
|
131
|
-
switch (method) {
|
|
132
|
-
case 'empty':
|
|
133
|
-
return '';
|
|
134
|
-
case 'replace':
|
|
135
|
-
return shuffle(s);
|
|
136
|
-
case 'same':
|
|
137
|
-
return s;
|
|
138
|
-
case 'placeholder':
|
|
139
|
-
return this.config.placeHolder;
|
|
140
|
-
default:
|
|
141
|
-
return this.config.placeHolder;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
getDefaultRule() {
|
|
146
|
-
if (this.isForceBlockEnabled()) {
|
|
147
|
-
return 'block';
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return 'placeholder';
|
|
151
|
-
}
|
|
152
|
-
|
|
153
136
|
isCookieEnabled() {
|
|
154
137
|
return this.config.cookieEnabled;
|
|
155
138
|
}
|
|
@@ -166,10 +149,6 @@ export default class RequestReporter {
|
|
|
166
149
|
return this.config.referrerEnabled;
|
|
167
150
|
}
|
|
168
151
|
|
|
169
|
-
isForceBlockEnabled() {
|
|
170
|
-
return this.config.forceBlockEnabled;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
152
|
telemetry(message) {
|
|
174
153
|
if (!this.communication) {
|
|
175
154
|
logger.error('No provider provider loaded');
|
|
@@ -307,7 +286,10 @@ export default class RequestReporter {
|
|
|
307
286
|
}
|
|
308
287
|
|
|
309
288
|
onBeforeRequest = (details) => {
|
|
310
|
-
if (!this.ready)
|
|
289
|
+
if (!this.ready) {
|
|
290
|
+
logger.warn('onBeforeRequest skipped (not ready)');
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
311
293
|
const state = WebRequestContext.fromDetails(details, this.pageStore);
|
|
312
294
|
const response = new BlockingResponse(details, 'onBeforeRequest');
|
|
313
295
|
// checkState
|
|
@@ -344,7 +326,7 @@ export default class RequestReporter {
|
|
|
344
326
|
// checkExternalBlocking
|
|
345
327
|
if (response.cancel === true || response.redirectUrl) {
|
|
346
328
|
state.incrementStat('blocked_external');
|
|
347
|
-
|
|
329
|
+
state.page.counter += 1;
|
|
348
330
|
return response.toWebRequestResponse();
|
|
349
331
|
}
|
|
350
332
|
// tokenExaminer.examineTokens
|
|
@@ -365,9 +347,7 @@ export default class RequestReporter {
|
|
|
365
347
|
}
|
|
366
348
|
// checkShouldBlock
|
|
367
349
|
if (
|
|
368
|
-
(state.badTokens.length > 0 &&
|
|
369
|
-
this.qs_whitelist.isUpToDate() &&
|
|
370
|
-
!this.config.paused) === false
|
|
350
|
+
(state.badTokens.length > 0 && this.qs_whitelist.isUpToDate()) === false
|
|
371
351
|
) {
|
|
372
352
|
return response.toWebRequestResponse();
|
|
373
353
|
}
|
|
@@ -382,18 +362,29 @@ export default class RequestReporter {
|
|
|
382
362
|
if (this.checkCompatibilityList(state) === false) {
|
|
383
363
|
return response.toWebRequestResponse();
|
|
384
364
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
365
|
+
if (this.dryRunMode) {
|
|
366
|
+
logger.warn(
|
|
367
|
+
'[DRY_RUN]: Skipping fingerprint removal for URL:',
|
|
368
|
+
details.url,
|
|
369
|
+
);
|
|
370
|
+
logger.info('[DRY_RUN]: Skipped fingerprint removal. Details:', {
|
|
371
|
+
details,
|
|
372
|
+
badTokens: state.badTokens,
|
|
373
|
+
});
|
|
374
|
+
this.#reportTrackerInteraction('fingerprint-detected', state);
|
|
390
375
|
return response.toWebRequestResponse();
|
|
391
376
|
}
|
|
377
|
+
|
|
378
|
+
this.applyBlock(state, response);
|
|
379
|
+
|
|
392
380
|
return response.toWebRequestResponse();
|
|
393
381
|
};
|
|
394
382
|
|
|
395
383
|
onBeforeSendHeaders = (details) => {
|
|
396
|
-
if (!this.ready)
|
|
384
|
+
if (!this.ready) {
|
|
385
|
+
logger.warn('onBeforeSendHeaders skipped (not ready)');
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
397
388
|
const state = WebRequestContext.fromDetails(details, this.pageStore);
|
|
398
389
|
const response = new BlockingResponse(details, 'onBeforeSendHeaders');
|
|
399
390
|
// checkState
|
|
@@ -414,14 +405,6 @@ export default class RequestReporter {
|
|
|
414
405
|
|
|
415
406
|
this.pageLogger.onBeforeSendHeaders(state);
|
|
416
407
|
|
|
417
|
-
// overrideUserAgent
|
|
418
|
-
if (this.config.overrideUserAgent === true) {
|
|
419
|
-
const domainHash = truncatedHash(state.urlParts.generalDomain);
|
|
420
|
-
if (this.qs_whitelist.isTrackerDomain(domainHash)) {
|
|
421
|
-
response.modifyHeader('User-Agent', 'CLIQZ');
|
|
422
|
-
state.incrementStat('override_user_agent');
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
408
|
// checkHasCookie
|
|
426
409
|
// hasCookie flag is set by pageLogger.onBeforeSendHeaders
|
|
427
410
|
if ((state.hasCookie === true) === false) {
|
|
@@ -457,29 +440,38 @@ export default class RequestReporter {
|
|
|
457
440
|
}
|
|
458
441
|
// shouldBlockCookie
|
|
459
442
|
if (
|
|
460
|
-
(!this.checkIsWhitelisted(state) &&
|
|
461
|
-
this.isCookieEnabled(state) &&
|
|
462
|
-
!this.config.paused) === false
|
|
443
|
+
(!this.checkIsWhitelisted(state) && this.isCookieEnabled(state)) === false
|
|
463
444
|
) {
|
|
464
445
|
state.incrementStat('bad_cookie_sent');
|
|
465
446
|
return response.toWebRequestResponse();
|
|
466
447
|
}
|
|
467
448
|
|
|
468
|
-
this
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
449
|
+
if (this.dryRunMode) {
|
|
450
|
+
logger.warn('[DRY_RUN]: Skipping cookie removal for URL:', details.url);
|
|
451
|
+
logger.info('[DRY_RUN]: Skipped fingerprint removal. Details:', {
|
|
452
|
+
details,
|
|
453
|
+
cookie: state.getCookieData(),
|
|
454
|
+
});
|
|
455
|
+
this.#reportTrackerInteraction('cookie-detected', state);
|
|
456
|
+
} else {
|
|
457
|
+
// blockCookie
|
|
458
|
+
state.incrementStat('cookie_blocked');
|
|
459
|
+
state.incrementStat('cookie_block_tp1');
|
|
460
|
+
response.modifyHeader('Cookie', '');
|
|
461
|
+
if (this.config.sendAntiTrackingHeader) {
|
|
462
|
+
response.modifyHeader(this.config.cliqzHeader, ' ');
|
|
463
|
+
}
|
|
464
|
+
state.page.counter += 1;
|
|
465
|
+
this.#reportTrackerInteraction('cookie-removed', state);
|
|
476
466
|
}
|
|
477
|
-
state.page.counter += 1;
|
|
478
467
|
return response.toWebRequestResponse();
|
|
479
468
|
};
|
|
480
469
|
|
|
481
470
|
onHeadersReceived = (details) => {
|
|
482
|
-
if (!this.ready)
|
|
471
|
+
if (!this.ready) {
|
|
472
|
+
logger.warn('onHeadersReceived skipped (not ready)');
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
483
475
|
const state = WebRequestContext.fromDetails(details, this.pageStore);
|
|
484
476
|
const response = new BlockingResponse(details, 'onHeadersReceived');
|
|
485
477
|
// checkState
|
|
@@ -533,17 +525,29 @@ export default class RequestReporter {
|
|
|
533
525
|
return response.toWebRequestResponse();
|
|
534
526
|
}
|
|
535
527
|
|
|
536
|
-
this
|
|
528
|
+
if (this.dryRunMode) {
|
|
529
|
+
logger.warn('[DRY_RUN]: Skipping cookie removal for URL:', details.url);
|
|
530
|
+
logger.info('[DRY_RUN]: Skipped cookie removal. Details:', {
|
|
531
|
+
details,
|
|
532
|
+
cookie: state.getResponseHeader('Set-Cookie'),
|
|
533
|
+
});
|
|
534
|
+
this.#reportTrackerInteraction('cookie-detected', state);
|
|
535
|
+
} else {
|
|
536
|
+
// blockSetCookie
|
|
537
|
+
response.modifyResponseHeader('Set-Cookie', '');
|
|
538
|
+
state.incrementStat('set_cookie_blocked');
|
|
539
|
+
state.page.counter += 1;
|
|
540
|
+
this.#reportTrackerInteraction('cookie-removed', state);
|
|
541
|
+
}
|
|
537
542
|
|
|
538
|
-
// blockSetCookie
|
|
539
|
-
response.modifyResponseHeader('Set-Cookie', '');
|
|
540
|
-
state.incrementStat('set_cookie_blocked');
|
|
541
|
-
state.page.counter += 1;
|
|
542
543
|
return response.toWebRequestResponse();
|
|
543
544
|
};
|
|
544
545
|
|
|
545
546
|
onCompleted = (details) => {
|
|
546
|
-
if (!this.ready)
|
|
547
|
+
if (!this.ready) {
|
|
548
|
+
logger.warn('onCompleted skipped (not ready)');
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
547
551
|
this.whitelistedRequestCache.delete(details.requestId);
|
|
548
552
|
const state = WebRequestContext.fromDetails(details, this.pageStore);
|
|
549
553
|
// checkState
|
|
@@ -559,7 +563,10 @@ export default class RequestReporter {
|
|
|
559
563
|
};
|
|
560
564
|
|
|
561
565
|
onErrorOccurred = (details) => {
|
|
562
|
-
if (!this.ready)
|
|
566
|
+
if (!this.ready) {
|
|
567
|
+
logger.warn('onErrorOccurred skipped (not ready)');
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
563
570
|
this.whitelistedRequestCache.delete(details.requestId);
|
|
564
571
|
};
|
|
565
572
|
|
|
@@ -598,15 +605,12 @@ export default class RequestReporter {
|
|
|
598
605
|
return true;
|
|
599
606
|
}
|
|
600
607
|
|
|
601
|
-
applyBlock(state,
|
|
602
|
-
const response = _response;
|
|
608
|
+
applyBlock(state, response) {
|
|
603
609
|
const badTokens = state.badTokens;
|
|
604
|
-
const rule = this.getDefaultRule();
|
|
605
610
|
|
|
606
611
|
if (this.debug) {
|
|
607
612
|
console.log(
|
|
608
613
|
'ATTRACK',
|
|
609
|
-
rule,
|
|
610
614
|
'URL:',
|
|
611
615
|
state.urlParts.hostname,
|
|
612
616
|
state.urlParts.pathname,
|
|
@@ -615,32 +619,26 @@ export default class RequestReporter {
|
|
|
615
619
|
);
|
|
616
620
|
}
|
|
617
621
|
|
|
618
|
-
|
|
619
|
-
state.
|
|
620
|
-
|
|
621
|
-
response.shouldIncrementCounter = true;
|
|
622
|
-
return false;
|
|
623
|
-
}
|
|
622
|
+
let path =
|
|
623
|
+
state.urlParts.pathname + state.urlParts.search + state.urlParts.hash;
|
|
624
|
+
const prefix = state.url.split(path)[0];
|
|
624
625
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
tmpUrl = tmpUrl.replace(badTokens[i], this.obfuscate(badTokens[i], rule));
|
|
628
|
-
}
|
|
629
|
-
// In case unsafe tokens were in the hostname, the URI is not valid
|
|
630
|
-
// anymore and we can cancel the request.
|
|
631
|
-
if (!tmpUrl.startsWith(state.urlParts.origin)) {
|
|
632
|
-
response.block();
|
|
633
|
-
return false;
|
|
626
|
+
for (const token of badTokens) {
|
|
627
|
+
path = path.replace(token, this.config.placeHolder);
|
|
634
628
|
}
|
|
635
629
|
|
|
636
|
-
state.incrementStat(`
|
|
630
|
+
state.incrementStat(`token_blocked_placeholder`);
|
|
637
631
|
|
|
638
632
|
this.recentlyModified.add(state.tabId + state.url, RECENTLY_MODIFIED_TTL);
|
|
639
633
|
|
|
640
|
-
response.redirectTo(
|
|
641
|
-
|
|
634
|
+
response.redirectTo(`${prefix}${path}`);
|
|
635
|
+
|
|
636
|
+
if (this.config.sendAntiTrackingHeader) {
|
|
637
|
+
response.modifyHeader(this.config.cliqzHeader, ' ');
|
|
638
|
+
}
|
|
642
639
|
|
|
643
640
|
state.page.counter += 1;
|
|
641
|
+
this.#reportTrackerInteraction('fingerprint-removed', state);
|
|
644
642
|
return true;
|
|
645
643
|
}
|
|
646
644
|
|
|
@@ -709,6 +707,10 @@ export default class RequestReporter {
|
|
|
709
707
|
}
|
|
710
708
|
|
|
711
709
|
recordClick(event, context, href, sender) {
|
|
710
|
+
if (!this.ready) {
|
|
711
|
+
logger.warn('recordClick skipped (not ready)');
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
712
714
|
this.cookieContext.setContextFromEvent(event, context, href, sender);
|
|
713
715
|
this.oAuthDetector.recordClick(sender);
|
|
714
716
|
}
|
|
@@ -27,19 +27,6 @@ export function truncateDomain(host, depth) {
|
|
|
27
27
|
.join('.')}.${generalDomain}`;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function shuffle(s) {
|
|
31
|
-
const a = s.split('');
|
|
32
|
-
const n = a.length;
|
|
33
|
-
|
|
34
|
-
for (let i = n - 1; i > 0; i -= 1) {
|
|
35
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
36
|
-
const tmp = a[i];
|
|
37
|
-
a[i] = a[j];
|
|
38
|
-
a[j] = tmp;
|
|
39
|
-
}
|
|
40
|
-
return a.join('');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
30
|
const ipv4Part = '0*([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'; // numbers 0 - 255
|
|
44
31
|
const ipv4Regex = new RegExp(
|
|
45
32
|
`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}([:]([0-9])+)?$`,
|
|
@@ -31,8 +31,8 @@ const URL_PATTERNS = [
|
|
|
31
31
|
{
|
|
32
32
|
category: 'search-gov',
|
|
33
33
|
regexp:
|
|
34
|
-
/^https:[/][/][^/]*[.]google[.].*?[#?&;]((q=[^&]+&([^&]+&)*
|
|
35
|
-
prefix: 'search?
|
|
34
|
+
/^https:[/][/][^/]*[.]google[.].*?[#?&;]((q=[^&]+&([^&]+&)*udm=7)|(udm=7&([^&]+&)*q=[^&]+))/,
|
|
35
|
+
prefix: 'search?udm=7&q=',
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
category: 'search-go',
|
|
@@ -326,7 +326,7 @@ describe('RequestReporter', function () {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
for (const snapshotName of ['0001', '0002', '0003', '0004']) {
|
|
329
|
+
for (const snapshotName of ['0001', '0002', '0003', '0004', '0005', '0006']) {
|
|
330
330
|
it(snapshotName, async function () {
|
|
331
331
|
const messages = [];
|
|
332
332
|
communicationEmiter.addListener('send', (message) =>
|
|
@@ -336,7 +336,7 @@ describe('RequestReporter', function () {
|
|
|
336
336
|
|
|
337
337
|
// run twice to allow token telemetry to trigger
|
|
338
338
|
playSnapshotScenario(chrome, snapshotName, {
|
|
339
|
-
rewriteUrls: { 'onet.pl': 'wp.pl', 'soundcloud.com': 'google.com' },
|
|
339
|
+
rewriteUrls: { 'onet.pl': 'wp.pl', 'soundcloud.com': 'google.com', 'nike.com': 'adidas.com' },
|
|
340
340
|
});
|
|
341
341
|
await processRunloopUntil(
|
|
342
342
|
reporter.tokenTelemetry
|
|
@@ -83,21 +83,21 @@ describe('#UrlAnalyzer', function () {
|
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
'search-gov': {
|
|
86
|
-
'https://www.google.com/search?q=cat&
|
|
86
|
+
'https://www.google.com/search?sca_esv=332c1457e26e21ac&q=cat&udm=7&fbs=AEQNm0A6bwEop21ehxKWq5cj-cHa02QUie7apaStVTrDAEoT1CkRGSL-1wA3X2bR5dRYtRFmaZPN2OTOpML6Nzk89AWekIwYOcUmK2FR_flIZE9vn1EXAsBBBo_DOK7IqycIPr8oX9r_c2Y_H6YSW9sBv2zzlY5ifH_0oIYtOJi92VlQNOEZ0mbOIl6RYJLN-zdoMIA2J145wwYej0xWX2q5hfw8qzQw7g&sa=X&ved=2ahUKEwjPk4Dr2e-JAxWBgf0HHfEsNsYQtKgLegQIGhAB&biw=882&bih=1002&dpr=0.9':
|
|
87
87
|
{
|
|
88
88
|
query: 'cat',
|
|
89
|
-
doublefetchUrl: 'https://www.google.com/search?
|
|
89
|
+
doublefetchUrl: 'https://www.google.com/search?udm=7&q=cat',
|
|
90
90
|
},
|
|
91
|
-
'https://www.google.de/search?q=katze&
|
|
91
|
+
'https://www.google.de/search?sca_esv=332c1457e26e21ac&q=katze&udm=7&fbs=AEQNm0A6bwEop21ehxKWq5cj-cHa02QUie7apaStVTrDAEoT1CkRGSL-1wA3X2bR5dRYtRGv3dh0WX48pQ0OijG3Ir_Ily36WNjIM66TUeQQm6v5pCxPr2gtqfjkC7ffv6Tr7pov6Kj4r20q4qdHCSHuZ8l9l_oCqEwoxOcaGtTQ9oNU0Tr95ug&sa=X&ved=2ahUKEwjDvfjh3u-JAxVY3AIHHUZkIcUQtKgLegQIIhAB&biw=958&bih=898&dpr=1':
|
|
92
92
|
{
|
|
93
93
|
query: 'katze',
|
|
94
|
-
doublefetchUrl: 'https://www.google.de/search?
|
|
94
|
+
doublefetchUrl: 'https://www.google.de/search?udm=7&q=katze',
|
|
95
95
|
},
|
|
96
|
-
'https://www.google.co.uk/search?q=British+Shorthair&
|
|
96
|
+
'https://www.google.co.uk/search?sca_esv=332c1457e26e21ac&q=British+Shorthair&udm=7&fbs=AEQNm0A6bwEop21ehxKWq5cj-cHa02QUie7apaStVTrDAEoT1CkRGSL-1wA3X2bR5dRYtRGv3dh0WX48pQ0OijG3Ir_I75oFM8mN67hQ5D8L2f_4aId2Ld_vPyIeJPxAzy5CcO-5UtDBOirlUmpUozWrwxQJT3cKh-XbNOVVNXNxn1wGeq30DpZD8xJuzexvjnEe-Ql_N82o&sa=X&ved=2ahUKEwi5hIO_2u-JAxVm3AIHHXc1E7UQtKgLegQIEBAB':
|
|
97
97
|
{
|
|
98
98
|
query: 'British Shorthair',
|
|
99
99
|
doublefetchUrl:
|
|
100
|
-
'https://www.google.co.uk/search?
|
|
100
|
+
'https://www.google.co.uk/search?udm=7&q=British+Shorthair',
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
103
|
'search-go': {
|