@whotracksme/reporting 8.0.1 → 9.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.
@@ -5,7 +5,7 @@
5
5
  "ctry": "en",
6
6
  "data": [
7
7
  {
8
- "active": 0,
8
+ "active": 479940,
9
9
  "c": 1,
10
10
  "counter": 0,
11
11
  "frames": {},
@@ -16,7 +16,7 @@
16
16
  "redirects": [],
17
17
  "redirectsPlaceHolder": [],
18
18
  "scheme": "https",
19
- "t": -1732456092505,
19
+ "t": 479940,
20
20
  "tps": {
21
21
  "encrypted-tbn0.gstatic.com": {
22
22
  "c": 8,
@@ -81,14 +81,14 @@
81
81
  "type_11": 1
82
82
  },
83
83
  "www.googleadservices.com": {
84
- "c": 2,
85
- "content_length": 1,
86
- "has_post": 1,
87
- "has_qs": 2,
88
- "resp_ob": 1,
89
- "scheme_https": 2,
90
- "status_204": 1,
91
- "type_10": 1,
84
+ "c": 3,
85
+ "content_length": 3,
86
+ "has_post": 2,
87
+ "has_qs": 3,
88
+ "resp_ob": 3,
89
+ "scheme_https": 3,
90
+ "status_204": 3,
91
+ "type_10": 2,
92
92
  "type_3": 1
93
93
  },
94
94
  "www.gstatic.com": {
@@ -138,7 +138,7 @@
138
138
  "ctry": "en",
139
139
  "data": [
140
140
  {
141
- "active": 0,
141
+ "active": 479940,
142
142
  "c": 1,
143
143
  "counter": 0,
144
144
  "frames": {},
@@ -149,19 +149,20 @@
149
149
  "redirects": [],
150
150
  "redirectsPlaceHolder": [],
151
151
  "scheme": "https",
152
- "t": -1732456106627,
152
+ "t": 479940,
153
153
  "tps": {
154
154
  "bam.nr-data.net": {
155
- "c": 4,
156
- "content_length": 203,
157
- "has_post": 4,
158
- "has_qs": 4,
159
- "referer_leak_path": 4,
160
- "referer_leak_site": 4,
161
- "resp_ob": 4,
162
- "scheme_https": 4,
163
- "status_200": 2,
164
- "status_204": 2,
155
+ "c": 8,
156
+ "content_length": 276,
157
+ "has_post": 8,
158
+ "has_qs": 8,
159
+ "referer_leak_path": 8,
160
+ "referer_leak_site": 8,
161
+ "resp_ob": 8,
162
+ "scheme_https": 8,
163
+ "status_200": 5,
164
+ "status_204": 3,
165
+ "type_10": 4,
165
166
  "type_11": 4
166
167
  },
167
168
  "c.go-mpulse.net": {
@@ -229,16 +230,6 @@
229
230
  "scheme_https": 1,
230
231
  "status_200": 1,
231
232
  "type_2": 1
232
- },
233
- "www.googleadservices.com": {
234
- "c": 1,
235
- "content_length": 2,
236
- "has_post": 1,
237
- "has_qs": 1,
238
- "resp_ob": 2,
239
- "scheme_https": 1,
240
- "status_204": 2,
241
- "type_10": 1
242
233
  }
243
234
  },
244
235
  "triggeringTree": {},
@@ -260,7 +251,7 @@
260
251
  "ctry": "en",
261
252
  "data": [
262
253
  {
263
- "active": 0,
254
+ "active": 479940,
264
255
  "c": 1,
265
256
  "counter": 0,
266
257
  "frames": {},
@@ -271,7 +262,7 @@
271
262
  "redirects": [],
272
263
  "redirectsPlaceHolder": [],
273
264
  "scheme": "https",
274
- "t": -1732456117381,
265
+ "t": 479940,
275
266
  "tps": {
276
267
  "4171764.fls.doubleclick.net": {
277
268
  "c": 3,
@@ -341,17 +332,17 @@
341
332
  "type_11": 3
342
333
  },
343
334
  "bat.bing.com": {
344
- "c": 5,
345
- "content_length": 14574,
346
- "has_post": 1,
347
- "has_qs": 3,
335
+ "c": 6,
336
+ "content_length": 14575,
337
+ "has_post": 2,
338
+ "has_qs": 4,
348
339
  "referer_leak_path": 2,
349
340
  "referer_leak_site": 2,
350
- "resp_ob": 5,
351
- "scheme_https": 5,
341
+ "resp_ob": 6,
342
+ "scheme_https": 6,
352
343
  "status_200": 2,
353
- "status_204": 3,
354
- "type_10": 1,
344
+ "status_204": 4,
345
+ "type_10": 2,
355
346
  "type_2": 2,
356
347
  "type_3": 2
357
348
  },
@@ -701,7 +692,7 @@
701
692
  "ctry": "en",
702
693
  "data": [
703
694
  {
704
- "active": 0,
695
+ "active": 479940,
705
696
  "c": 1,
706
697
  "counter": 0,
707
698
  "frames": {},
@@ -712,7 +703,7 @@
712
703
  "redirects": [],
713
704
  "redirectsPlaceHolder": [],
714
705
  "scheme": "https",
715
- "t": -1732456127382,
706
+ "t": 479940,
716
707
  "tps": {
717
708
  "4171764.fls.doubleclick.net": {
718
709
  "c": 3,
@@ -770,30 +761,31 @@
770
761
  "type_2": 1
771
762
  },
772
763
  "bam.nr-data.net": {
773
- "c": 4,
774
- "content_length": 203,
775
- "has_post": 4,
776
- "has_qs": 4,
777
- "referer_leak_path": 4,
778
- "referer_leak_site": 4,
779
- "resp_ob": 4,
780
- "scheme_https": 4,
781
- "status_200": 2,
782
- "status_204": 2,
764
+ "c": 8,
765
+ "content_length": 276,
766
+ "has_post": 8,
767
+ "has_qs": 8,
768
+ "referer_leak_path": 8,
769
+ "referer_leak_site": 8,
770
+ "resp_ob": 8,
771
+ "scheme_https": 8,
772
+ "status_200": 5,
773
+ "status_204": 3,
774
+ "type_10": 4,
783
775
  "type_11": 4
784
776
  },
785
777
  "bat.bing.com": {
786
- "c": 5,
787
- "content_length": 14574,
788
- "has_post": 1,
789
- "has_qs": 3,
778
+ "c": 6,
779
+ "content_length": 14575,
780
+ "has_post": 2,
781
+ "has_qs": 4,
790
782
  "referer_leak_path": 2,
791
783
  "referer_leak_site": 2,
792
- "resp_ob": 5,
793
- "scheme_https": 5,
784
+ "resp_ob": 6,
785
+ "scheme_https": 6,
794
786
  "status_200": 2,
795
- "status_204": 3,
796
- "type_10": 1,
787
+ "status_204": 4,
788
+ "type_10": 2,
797
789
  "type_2": 2,
798
790
  "type_3": 2
799
791
  },
@@ -948,6 +940,18 @@
948
940
  "type_11": 1,
949
941
  "type_2": 2
950
942
  },
943
+ "region1.analytics.google.com": {
944
+ "c": 2,
945
+ "content_length": 2,
946
+ "has_post": 2,
947
+ "has_qs": 2,
948
+ "referer_leak_path": 2,
949
+ "referer_leak_site": 2,
950
+ "resp_ob": 2,
951
+ "scheme_https": 2,
952
+ "status_204": 2,
953
+ "type_11": 2
954
+ },
951
955
  "reporting.cdndex.io": {
952
956
  "c": 1,
953
957
  "content_length": 8,
@@ -1150,7 +1154,7 @@
1150
1154
  "ctry": "en",
1151
1155
  "data": [
1152
1156
  {
1153
- "active": 0,
1157
+ "active": 479940,
1154
1158
  "c": 1,
1155
1159
  "counter": 0,
1156
1160
  "frames": {},
@@ -1161,7 +1165,7 @@
1161
1165
  "redirects": [],
1162
1166
  "redirectsPlaceHolder": [],
1163
1167
  "scheme": "https",
1164
- "t": -1732456092505,
1168
+ "t": 479940,
1165
1169
  "tps": {
1166
1170
  "encrypted-tbn0.gstatic.com": {
1167
1171
  "c": 8,
@@ -1234,14 +1238,14 @@
1234
1238
  "type_1": 1
1235
1239
  },
1236
1240
  "www.googleadservices.com": {
1237
- "c": 2,
1238
- "content_length": 1,
1239
- "has_post": 1,
1240
- "has_qs": 2,
1241
- "resp_ob": 1,
1242
- "scheme_https": 2,
1243
- "status_204": 1,
1244
- "type_10": 1,
1241
+ "c": 3,
1242
+ "content_length": 3,
1243
+ "has_post": 2,
1244
+ "has_qs": 3,
1245
+ "resp_ob": 3,
1246
+ "scheme_https": 3,
1247
+ "status_204": 3,
1248
+ "type_10": 2,
1245
1249
  "type_3": 1
1246
1250
  },
1247
1251
  "www.gstatic.com": {
@@ -1283,7 +1287,7 @@
1283
1287
  "ctry": "en",
1284
1288
  "data": [
1285
1289
  {
1286
- "active": 0,
1290
+ "active": 479940,
1287
1291
  "c": 1,
1288
1292
  "counter": 0,
1289
1293
  "frames": {},
@@ -1294,19 +1298,20 @@
1294
1298
  "redirects": [],
1295
1299
  "redirectsPlaceHolder": [],
1296
1300
  "scheme": "https",
1297
- "t": -1732456106627,
1301
+ "t": 479940,
1298
1302
  "tps": {
1299
1303
  "bam.nr-data.net": {
1300
- "c": 4,
1301
- "content_length": 203,
1302
- "has_post": 4,
1303
- "has_qs": 4,
1304
- "referer_leak_path": 4,
1305
- "referer_leak_site": 4,
1306
- "resp_ob": 4,
1307
- "scheme_https": 4,
1308
- "status_200": 2,
1309
- "status_204": 2,
1304
+ "c": 8,
1305
+ "content_length": 276,
1306
+ "has_post": 8,
1307
+ "has_qs": 8,
1308
+ "referer_leak_path": 8,
1309
+ "referer_leak_site": 8,
1310
+ "resp_ob": 8,
1311
+ "scheme_https": 8,
1312
+ "status_200": 5,
1313
+ "status_204": 3,
1314
+ "type_10": 4,
1310
1315
  "type_11": 4
1311
1316
  },
1312
1317
  "c.go-mpulse.net": {
@@ -1374,16 +1379,6 @@
1374
1379
  "scheme_https": 1,
1375
1380
  "status_200": 1,
1376
1381
  "type_2": 1
1377
- },
1378
- "www.googleadservices.com": {
1379
- "c": 1,
1380
- "content_length": 2,
1381
- "has_post": 1,
1382
- "has_qs": 1,
1383
- "resp_ob": 2,
1384
- "scheme_https": 1,
1385
- "status_204": 2,
1386
- "type_10": 1
1387
1382
  }
1388
1383
  },
1389
1384
  "triggeringTree": {},
@@ -1405,7 +1400,7 @@
1405
1400
  "ctry": "en",
1406
1401
  "data": [
1407
1402
  {
1408
- "active": 0,
1403
+ "active": 479940,
1409
1404
  "c": 1,
1410
1405
  "counter": 0,
1411
1406
  "frames": {},
@@ -1416,7 +1411,7 @@
1416
1411
  "redirects": [],
1417
1412
  "redirectsPlaceHolder": [],
1418
1413
  "scheme": "https",
1419
- "t": -1732456117381,
1414
+ "t": 479940,
1420
1415
  "tps": {
1421
1416
  "4171764.fls.doubleclick.net": {
1422
1417
  "c": 3,
@@ -1486,17 +1481,17 @@
1486
1481
  "type_11": 3
1487
1482
  },
1488
1483
  "bat.bing.com": {
1489
- "c": 5,
1490
- "content_length": 14574,
1491
- "has_post": 1,
1492
- "has_qs": 3,
1484
+ "c": 6,
1485
+ "content_length": 14575,
1486
+ "has_post": 2,
1487
+ "has_qs": 4,
1493
1488
  "referer_leak_path": 2,
1494
1489
  "referer_leak_site": 2,
1495
- "resp_ob": 5,
1496
- "scheme_https": 5,
1490
+ "resp_ob": 6,
1491
+ "scheme_https": 6,
1497
1492
  "status_200": 2,
1498
- "status_204": 3,
1499
- "type_10": 1,
1493
+ "status_204": 4,
1494
+ "type_10": 2,
1500
1495
  "type_2": 2,
1501
1496
  "type_3": 2
1502
1497
  },
@@ -1846,7 +1841,7 @@
1846
1841
  "ctry": "en",
1847
1842
  "data": [
1848
1843
  {
1849
- "active": 0,
1844
+ "active": 479940,
1850
1845
  "c": 1,
1851
1846
  "counter": 0,
1852
1847
  "frames": {},
@@ -1857,7 +1852,7 @@
1857
1852
  "redirects": [],
1858
1853
  "redirectsPlaceHolder": [],
1859
1854
  "scheme": "https",
1860
- "t": -1732456127382,
1855
+ "t": 479940,
1861
1856
  "tps": {
1862
1857
  "4171764.fls.doubleclick.net": {
1863
1858
  "c": 3,
@@ -1915,30 +1910,31 @@
1915
1910
  "type_2": 1
1916
1911
  },
1917
1912
  "bam.nr-data.net": {
1918
- "c": 4,
1919
- "content_length": 203,
1920
- "has_post": 4,
1921
- "has_qs": 4,
1922
- "referer_leak_path": 4,
1923
- "referer_leak_site": 4,
1924
- "resp_ob": 4,
1925
- "scheme_https": 4,
1926
- "status_200": 2,
1927
- "status_204": 2,
1913
+ "c": 8,
1914
+ "content_length": 276,
1915
+ "has_post": 8,
1916
+ "has_qs": 8,
1917
+ "referer_leak_path": 8,
1918
+ "referer_leak_site": 8,
1919
+ "resp_ob": 8,
1920
+ "scheme_https": 8,
1921
+ "status_200": 5,
1922
+ "status_204": 3,
1923
+ "type_10": 4,
1928
1924
  "type_11": 4
1929
1925
  },
1930
1926
  "bat.bing.com": {
1931
- "c": 5,
1932
- "content_length": 14574,
1933
- "has_post": 1,
1934
- "has_qs": 3,
1927
+ "c": 6,
1928
+ "content_length": 14575,
1929
+ "has_post": 2,
1930
+ "has_qs": 4,
1935
1931
  "referer_leak_path": 2,
1936
1932
  "referer_leak_site": 2,
1937
- "resp_ob": 5,
1938
- "scheme_https": 5,
1933
+ "resp_ob": 6,
1934
+ "scheme_https": 6,
1939
1935
  "status_200": 2,
1940
- "status_204": 3,
1941
- "type_10": 1,
1936
+ "status_204": 4,
1937
+ "type_10": 2,
1942
1938
  "type_2": 2,
1943
1939
  "type_3": 2
1944
1940
  },
@@ -2093,6 +2089,18 @@
2093
2089
  "type_11": 1,
2094
2090
  "type_2": 2
2095
2091
  },
2092
+ "region1.analytics.google.com": {
2093
+ "c": 2,
2094
+ "content_length": 2,
2095
+ "has_post": 2,
2096
+ "has_qs": 2,
2097
+ "referer_leak_path": 2,
2098
+ "referer_leak_site": 2,
2099
+ "resp_ob": 2,
2100
+ "scheme_https": 2,
2101
+ "status_204": 2,
2102
+ "type_11": 2
2103
+ },
2096
2104
  "reporting.cdndex.io": {
2097
2105
  "c": 1,
2098
2106
  "content_length": 8,
@@ -2674,6 +2682,10 @@
2674
2682
  [
2675
2683
  "b019d16305f0eca0cb84d5797c474770",
2676
2684
  true
2685
+ ],
2686
+ [
2687
+ "843d03bdbfa808e9f800c4c0e0275ddb",
2688
+ true
2677
2689
  ]
2678
2690
  ],
2679
2691
  "tracker": "1d5920f4b44b27a8",
@@ -4960,6 +4972,10 @@
4960
4972
  [
4961
4973
  "b019d16305f0eca0cb84d5797c474770",
4962
4974
  true
4975
+ ],
4976
+ [
4977
+ "843d03bdbfa808e9f800c4c0e0275ddb",
4978
+ true
4963
4979
  ]
4964
4980
  ],
4965
4981
  "tracker": "1d5920f4b44b27a8",
@@ -83,6 +83,12 @@ function sanitizePart(str) {
83
83
  str,
84
84
  );
85
85
  decodedStr = undefined;
86
+ } else if (hasInvalidSurrogates(decodedStr)) {
87
+ logger.warn(
88
+ 'Ignoring edge case where the decoded string contains invalid surrogates',
89
+ str,
90
+ );
91
+ decodedStr = undefined;
86
92
  }
87
93
  } catch {
88
94
  // ignore (not well formed)
@@ -104,7 +110,13 @@ function sanitizePart(str) {
104
110
  // Phase 2: text is fixed, but not yet truncated.
105
111
  function sanitizePart__fixedButNotYetTruncated__(str) {
106
112
  if (str.length >= MAX_TEXT_LENGTH) {
107
- const truncated = str.slice(0, MAX_TEXT_LENGTH - MASKED.length);
113
+ let splitAt = MAX_TEXT_LENGTH - MASKED.length;
114
+ if (splitsSurrogatePair(str, splitAt)) {
115
+ // avoid splitting between a unicode pair, since it will result in broken text
116
+ splitAt -= 1;
117
+ }
118
+
119
+ const truncated = str.slice(0, splitAt);
108
120
  logger.debug('Truncating long text segment:', str, '->', truncated);
109
121
  const sanitized = sanitizePart__fixedText__(truncated);
110
122
  return sanitized.endsWith(MASKED) ? sanitized : sanitized + MASKED;
@@ -200,6 +212,13 @@ function maskHashes(str) {
200
212
 
201
213
  for (let size = str.length; size >= MIN_SIZE_TO_BE_MASKED; size -= 1) {
202
214
  for (let start = str.length - size; start >= 0; start -= 1) {
215
+ if (
216
+ splitsSurrogatePair(str, start) ||
217
+ splitsSurrogatePair(str, start + size)
218
+ ) {
219
+ // would result in broken encodings
220
+ continue;
221
+ }
203
222
  const substring = str.slice(start, start + size);
204
223
  if (shouldBeMasked(substring)) {
205
224
  let prefix = '';
@@ -312,6 +331,45 @@ function skipHashDetection(str) {
312
331
  return false;
313
332
  }
314
333
 
334
+ function isHighSurrogate(code) {
335
+ return (code & 0xfc00) === 0xd800;
336
+ }
337
+
338
+ function isLowSurrogate(code) {
339
+ return (code & 0xfc00) === 0xdc00;
340
+ }
341
+
342
+ function hasInvalidSurrogates(str) {
343
+ for (let i = 0; i < str.length; i++) {
344
+ const code = str.charCodeAt(i);
345
+ if (isHighSurrogate(code)) {
346
+ if (!isLowSurrogate(str.charCodeAt(i + 1))) {
347
+ // high surrogate must be followed by a low surrogate
348
+ return true;
349
+ }
350
+ i++; // skip the low surrogate (already validated)
351
+ } else if (isLowSurrogate(code)) {
352
+ // low surrogate without a preceding high surrogate
353
+ return true;
354
+ }
355
+ }
356
+ return false;
357
+ }
358
+
359
+ // If we split an UTF-16 string in the middle of a surrogate pair,
360
+ // it results in broken text. This function detects it.
361
+ function splitsSurrogatePair(str, pos) {
362
+ if (pos <= 0 || pos >= str.length) {
363
+ // spliting at the start or end can never break
364
+ return false;
365
+ }
366
+
367
+ return (
368
+ isHighSurrogate(str.charCodeAt(pos - 1)) &&
369
+ isLowSurrogate(str.charCodeAt(pos))
370
+ );
371
+ }
372
+
315
373
  // visible for testing
316
374
  export function backportMaskToOriginalText(
317
375
  originalText,
@@ -39,9 +39,11 @@ import {
39
39
  checkValidContext,
40
40
  } from './steps/check-context.js';
41
41
  import PageStore from './page-store.js';
42
+ import ChromeStorageMap from './utils/chrome-storage-map.js';
42
43
 
43
44
  const DAY_CHANGE_INTERVAL = 20 * 1000;
44
45
  const RECENTLY_MODIFIED_TTL = 30 * 1000;
46
+ const REPORTED_DOCUMENTS_TTL = 5 * 60 * 1000;
45
47
 
46
48
  function hasBlockingWebRequest() {
47
49
  return chrome.runtime
@@ -87,6 +89,13 @@ export default class RequestReporter {
87
89
  this.pageStore = new PageStore({
88
90
  notifyPageStageListeners: this.onPageStaged.bind(this),
89
91
  });
92
+ // Dedupe tp_events by root documentId so a SW restart that
93
+ // re-flushes a not-yet-persisted #pages.delete can't emit the
94
+ // same page twice.
95
+ this.reportedDocuments = new ChromeStorageMap({
96
+ storageKey: 'wtm-request-reporting:reported-documents',
97
+ ttlInMs: REPORTED_DOCUMENTS_TTL,
98
+ });
90
99
 
91
100
  this.ready = false;
92
101
 
@@ -251,6 +260,7 @@ export default class RequestReporter {
251
260
  DAY_CHANGE_INTERVAL,
252
261
  );
253
262
 
263
+ await this.reportedDocuments.isReady;
254
264
  await this.pageStore.init();
255
265
 
256
266
  this.pageLogger = new PageLogger(this.config.placeHolder);
@@ -719,6 +729,9 @@ export default class RequestReporter {
719
729
 
720
730
  onPageStaged(page) {
721
731
  if (page.state === 'complete' && !page.isPrivate && !page.isPrivateServer) {
732
+ if (this.reportedDocuments.has(page.documentId)) {
733
+ return;
734
+ }
722
735
  const payload = buildPageLoadObject(page);
723
736
  if (
724
737
  payload.scheme.startsWith('http') &&
@@ -728,6 +741,7 @@ export default class RequestReporter {
728
741
  action: 'wtm.attrack.tp_events',
729
742
  payload: [payload],
730
743
  });
744
+ this.reportedDocuments.set(page.documentId, 1);
731
745
  }
732
746
  }
733
747
  }