@whotracksme/reporting 5.1.38 → 5.2.1
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 +69 -86
- package/reporting/src/request/page-store.js +5 -2
- package/reporting/src/request/steps/token-telemetry/key-pipeline.js +16 -0
- package/reporting/src/request/utils/utils.js +0 -13
- package/reporting/src/request/utils/webrequest.js +0 -1
- package/reporting/test/request/index.test.js +2 -2
|
@@ -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');
|
|
@@ -347,7 +326,7 @@ export default class RequestReporter {
|
|
|
347
326
|
// checkExternalBlocking
|
|
348
327
|
if (response.cancel === true || response.redirectUrl) {
|
|
349
328
|
state.incrementStat('blocked_external');
|
|
350
|
-
|
|
329
|
+
state.page.counter += 1;
|
|
351
330
|
return response.toWebRequestResponse();
|
|
352
331
|
}
|
|
353
332
|
// tokenExaminer.examineTokens
|
|
@@ -368,9 +347,7 @@ export default class RequestReporter {
|
|
|
368
347
|
}
|
|
369
348
|
// checkShouldBlock
|
|
370
349
|
if (
|
|
371
|
-
(state.badTokens.length > 0 &&
|
|
372
|
-
this.qs_whitelist.isUpToDate() &&
|
|
373
|
-
!this.config.paused) === false
|
|
350
|
+
(state.badTokens.length > 0 && this.qs_whitelist.isUpToDate()) === false
|
|
374
351
|
) {
|
|
375
352
|
return response.toWebRequestResponse();
|
|
376
353
|
}
|
|
@@ -385,13 +362,21 @@ export default class RequestReporter {
|
|
|
385
362
|
if (this.checkCompatibilityList(state) === false) {
|
|
386
363
|
return response.toWebRequestResponse();
|
|
387
364
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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);
|
|
393
375
|
return response.toWebRequestResponse();
|
|
394
376
|
}
|
|
377
|
+
|
|
378
|
+
this.applyBlock(state, response);
|
|
379
|
+
|
|
395
380
|
return response.toWebRequestResponse();
|
|
396
381
|
};
|
|
397
382
|
|
|
@@ -420,14 +405,6 @@ export default class RequestReporter {
|
|
|
420
405
|
|
|
421
406
|
this.pageLogger.onBeforeSendHeaders(state);
|
|
422
407
|
|
|
423
|
-
// overrideUserAgent
|
|
424
|
-
if (this.config.overrideUserAgent === true) {
|
|
425
|
-
const domainHash = truncatedHash(state.urlParts.generalDomain);
|
|
426
|
-
if (this.qs_whitelist.isTrackerDomain(domainHash)) {
|
|
427
|
-
response.modifyHeader('User-Agent', 'CLIQZ');
|
|
428
|
-
state.incrementStat('override_user_agent');
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
408
|
// checkHasCookie
|
|
432
409
|
// hasCookie flag is set by pageLogger.onBeforeSendHeaders
|
|
433
410
|
if ((state.hasCookie === true) === false) {
|
|
@@ -463,24 +440,30 @@ export default class RequestReporter {
|
|
|
463
440
|
}
|
|
464
441
|
// shouldBlockCookie
|
|
465
442
|
if (
|
|
466
|
-
(!this.checkIsWhitelisted(state) &&
|
|
467
|
-
this.isCookieEnabled(state) &&
|
|
468
|
-
!this.config.paused) === false
|
|
443
|
+
(!this.checkIsWhitelisted(state) && this.isCookieEnabled(state)) === false
|
|
469
444
|
) {
|
|
470
445
|
state.incrementStat('bad_cookie_sent');
|
|
471
446
|
return response.toWebRequestResponse();
|
|
472
447
|
}
|
|
473
448
|
|
|
474
|
-
this
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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);
|
|
482
466
|
}
|
|
483
|
-
state.page.counter += 1;
|
|
484
467
|
return response.toWebRequestResponse();
|
|
485
468
|
};
|
|
486
469
|
|
|
@@ -542,12 +525,21 @@ export default class RequestReporter {
|
|
|
542
525
|
return response.toWebRequestResponse();
|
|
543
526
|
}
|
|
544
527
|
|
|
545
|
-
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
|
+
}
|
|
546
542
|
|
|
547
|
-
// blockSetCookie
|
|
548
|
-
response.modifyResponseHeader('Set-Cookie', '');
|
|
549
|
-
state.incrementStat('set_cookie_blocked');
|
|
550
|
-
state.page.counter += 1;
|
|
551
543
|
return response.toWebRequestResponse();
|
|
552
544
|
};
|
|
553
545
|
|
|
@@ -613,15 +605,12 @@ export default class RequestReporter {
|
|
|
613
605
|
return true;
|
|
614
606
|
}
|
|
615
607
|
|
|
616
|
-
applyBlock(state,
|
|
617
|
-
const response = _response;
|
|
608
|
+
applyBlock(state, response) {
|
|
618
609
|
const badTokens = state.badTokens;
|
|
619
|
-
const rule = this.getDefaultRule();
|
|
620
610
|
|
|
621
611
|
if (this.debug) {
|
|
622
612
|
console.log(
|
|
623
613
|
'ATTRACK',
|
|
624
|
-
rule,
|
|
625
614
|
'URL:',
|
|
626
615
|
state.urlParts.hostname,
|
|
627
616
|
state.urlParts.pathname,
|
|
@@ -630,32 +619,26 @@ export default class RequestReporter {
|
|
|
630
619
|
);
|
|
631
620
|
}
|
|
632
621
|
|
|
633
|
-
|
|
634
|
-
state.
|
|
635
|
-
|
|
636
|
-
response.shouldIncrementCounter = true;
|
|
637
|
-
return false;
|
|
638
|
-
}
|
|
622
|
+
let path =
|
|
623
|
+
state.urlParts.pathname + state.urlParts.search + state.urlParts.hash;
|
|
624
|
+
const prefix = state.url.split(path)[0];
|
|
639
625
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
tmpUrl = tmpUrl.replace(badTokens[i], this.obfuscate(badTokens[i], rule));
|
|
643
|
-
}
|
|
644
|
-
// In case unsafe tokens were in the hostname, the URI is not valid
|
|
645
|
-
// anymore and we can cancel the request.
|
|
646
|
-
if (!tmpUrl.startsWith(state.urlParts.origin)) {
|
|
647
|
-
response.block();
|
|
648
|
-
return false;
|
|
626
|
+
for (const token of badTokens) {
|
|
627
|
+
path = path.replace(token, this.config.placeHolder);
|
|
649
628
|
}
|
|
650
629
|
|
|
651
|
-
state.incrementStat(`
|
|
630
|
+
state.incrementStat(`token_blocked_placeholder`);
|
|
652
631
|
|
|
653
632
|
this.recentlyModified.add(state.tabId + state.url, RECENTLY_MODIFIED_TTL);
|
|
654
633
|
|
|
655
|
-
response.redirectTo(
|
|
656
|
-
|
|
634
|
+
response.redirectTo(`${prefix}${path}`);
|
|
635
|
+
|
|
636
|
+
if (this.config.sendAntiTrackingHeader) {
|
|
637
|
+
response.modifyHeader(this.config.cliqzHeader, ' ');
|
|
638
|
+
}
|
|
657
639
|
|
|
658
640
|
state.page.counter += 1;
|
|
641
|
+
this.#reportTrackerInteraction('fingerprint-removed', state);
|
|
659
642
|
return true;
|
|
660
643
|
}
|
|
661
644
|
|
|
@@ -77,7 +77,9 @@ export default class PageStore {
|
|
|
77
77
|
chrome.webNavigation.onBeforeNavigate.addListener(this.#onBeforeNavigate);
|
|
78
78
|
chrome.webNavigation.onCommitted.addListener(this.#onNavigationCommitted);
|
|
79
79
|
chrome.webNavigation.onCompleted.addListener(this.#onNavigationCompleted);
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
// Note: not available on Firefox Android
|
|
82
|
+
chrome.windows?.onFocusChanged?.addListener(this.#onWindowFocusChanged);
|
|
81
83
|
|
|
82
84
|
// popupate initially open tabs
|
|
83
85
|
(await chrome.tabs.query({})).forEach((tab) => this.#onTabCreated(tab));
|
|
@@ -103,7 +105,7 @@ export default class PageStore {
|
|
|
103
105
|
chrome.webNavigation.onCompleted.removeListener(
|
|
104
106
|
this.#onNavigationCompleted,
|
|
105
107
|
);
|
|
106
|
-
chrome.windows
|
|
108
|
+
chrome.windows?.onFocusChanged?.removeListener(this.#onWindowFocusChanged);
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
checkIfEmpty() {
|
|
@@ -182,6 +184,7 @@ export default class PageStore {
|
|
|
182
184
|
}
|
|
183
185
|
};
|
|
184
186
|
|
|
187
|
+
// Note: not available on Firefox Android
|
|
185
188
|
#onWindowFocusChanged = async (focusedWindowId) => {
|
|
186
189
|
const activeTabs = await chrome.tabs.query({ active: true });
|
|
187
190
|
for (const { id, windowId } of activeTabs) {
|
|
@@ -87,6 +87,22 @@ export default class KeyPipeline extends CachedEntryPipeline {
|
|
|
87
87
|
}
|
|
88
88
|
let tokensToSend = Object.entries(tokens);
|
|
89
89
|
|
|
90
|
+
// In rare cases, the number of tokens may exceed the message size limit (currently 32K),
|
|
91
|
+
// such as when a website sends high-frequency requests with randomized IDs. To handle
|
|
92
|
+
// this scenario, two approaches were considered:
|
|
93
|
+
//
|
|
94
|
+
// 1. Chunking: Splitting the message into multiple smaller messages.
|
|
95
|
+
// 2. Sampling: Sending a random subset of token hashes.
|
|
96
|
+
//
|
|
97
|
+
// We implemented the second approach because the server-side aggregation aims to identify
|
|
98
|
+
// common tokens seen by enough clients. If a website sends many different values rapidly,
|
|
99
|
+
// they are likely random and unlikely to reach a quorum. Therefore, sending a random sample
|
|
100
|
+
// of token hashes should not impair the server's ability to identify common values and may
|
|
101
|
+
// even reduce noise.
|
|
102
|
+
//
|
|
103
|
+
// Exceeding the limit should be rare, and this measure serves as protection against edge cases.
|
|
104
|
+
// Currently, we are aware of only one page that triggered this issue:
|
|
105
|
+
// https://github.com/ghostery/broken-page-reports/issues/873#issuecomment-2450496021.
|
|
90
106
|
if (tokensToSend.length > this.options.KEY_TOKENS_LIMIT) {
|
|
91
107
|
logger.warn(
|
|
92
108
|
'[Request keys-pipeline]',
|
|
@@ -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])+)?$`,
|
|
@@ -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
|