@whotracksme/reporting 5.1.25 β†’ 5.1.27

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.
Files changed (51) hide show
  1. package/.github/workflows/tests.yml +3 -1
  2. package/CHANGELOG.md +34 -0
  3. package/package.json +3 -2
  4. package/reporting/example/index.js +14 -3
  5. package/reporting/example/manifests/chromium.json +1 -2
  6. package/reporting/karma.conf.cjs +2 -0
  7. package/reporting/package.json +2 -1
  8. package/reporting/src/bloom-filters.js +4 -4
  9. package/reporting/src/fixed-size-cache.js +1 -1
  10. package/reporting/src/logger.js +0 -1
  11. package/reporting/src/md5.js +1 -1
  12. package/reporting/src/network.js +1 -1
  13. package/reporting/src/pages.js +84 -21
  14. package/reporting/src/persisted-bitarray.js +2 -2
  15. package/reporting/src/request/config.js +2 -2
  16. package/reporting/src/request/hash.js +2 -2
  17. package/reporting/src/request/index.js +31 -70
  18. package/reporting/src/request/page-telemetry.js +4 -4
  19. package/reporting/src/request/qs-whitelist2.js +3 -3
  20. package/reporting/src/request/steps/cookie-context.js +6 -6
  21. package/reporting/src/request/steps/oauth-detector.js +3 -3
  22. package/reporting/src/request/steps/page-logger.js +3 -7
  23. package/reporting/src/request/steps/redirect-tagger.js +1 -25
  24. package/reporting/src/request/steps/token-checker/index.js +3 -3
  25. package/reporting/src/request/steps/token-checker/token-domain.js +3 -3
  26. package/reporting/src/request/steps/token-examiner.js +5 -5
  27. package/reporting/src/request/steps/token-telemetry/cached-entry-pipeline.js +3 -3
  28. package/reporting/src/request/steps/token-telemetry/index.js +4 -4
  29. package/reporting/src/request/steps/token-telemetry/key-pipeline.js +1 -1
  30. package/reporting/src/request/steps/token-telemetry/token-pipeline.js +1 -1
  31. package/reporting/src/request/utils/bloom-filter-packed.js +1 -1
  32. package/reporting/src/request/utils/chrome-storage-map.js +6 -0
  33. package/reporting/src/request/utils/subject.js +1 -1
  34. package/reporting/src/request/utils/temp-set.js +1 -1
  35. package/reporting/src/request-reporter.js +3 -3
  36. package/reporting/src/sanitizer.js +11 -3
  37. package/reporting/src/utils/pacemaker.js +1 -1
  38. package/reporting/src/utils/url.js +0 -29
  39. package/reporting/src/webrequest-pipeline/page-store.js +219 -150
  40. package/reporting/src/webrequest-pipeline/webrequest-context.js +1 -33
  41. package/reporting/test/helpers/fetch-mock.js +2 -2
  42. package/reporting/test/helpers/scenarios.js +104 -0
  43. package/reporting/test/pages.spec.js +52 -4
  44. package/reporting/test/request/index.spec.js +2 -9
  45. package/reporting/test/request-reporter.test.js +255 -0
  46. package/reporting/test/sanitizer.spec.js +16 -0
  47. package/reporting/test/utils/url.spec.js +1 -26
  48. package/reporting/test/webrequest-pipeline/index.test.js +101 -3
  49. package/reporting/test/webrequest-pipeline/page-store.test.js +36 -17
  50. package/reporting/src/request/dnt.js +0 -24
  51. package/reporting/src/webrequest-pipeline/page.js +0 -117
@@ -14,4 +14,6 @@ jobs:
14
14
  - uses: actions/checkout@v2
15
15
  - uses: jdx/mise-action@v2
16
16
  - run: npm ci
17
- - run: npm test
17
+ - run: npm run lint
18
+ - run: npm run test
19
+ - run: npm run test.unit
package/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ # v5.1.27 (Wed Oct 23 2024)
2
+
3
+ #### πŸ› Bug Fix
4
+
5
+ - Remove main_frame redirect detection [#108](https://github.com/whotracksme/webextension-packages/pull/108) ([@chrmod](https://github.com/chrmod))
6
+
7
+ #### 🏠 Internal
8
+
9
+ - webrequest-pipeline cleanup [#106](https://github.com/whotracksme/webextension-packages/pull/106) ([@chrmod](https://github.com/chrmod))
10
+ - PageStore cleanup [#105](https://github.com/whotracksme/webextension-packages/pull/105) ([@chrmod](https://github.com/chrmod))
11
+ - PageStore cleanup [#104](https://github.com/whotracksme/webextension-packages/pull/104) ([@chrmod](https://github.com/chrmod))
12
+
13
+ #### Authors: 1
14
+
15
+ - Krzysztof Modras ([@chrmod](https://github.com/chrmod))
16
+
17
+ ---
18
+
19
+ # v5.1.26 (Wed Oct 02 2024)
20
+
21
+ #### πŸ› Bug Fix
22
+
23
+ - Basic tp_events integration test [#103](https://github.com/whotracksme/webextension-packages/pull/103) ([@chrmod](https://github.com/chrmod))
24
+ - Preserve "openedFrom" information during redirects that are openend in a new tab. [#97](https://github.com/whotracksme/webextension-packages/pull/97) ([@philipp-classen](https://github.com/philipp-classen))
25
+ - Filter out uncommon URLs where the hostname is an IPv4 address. [#101](https://github.com/whotracksme/webextension-packages/pull/101) ([@philipp-classen](https://github.com/philipp-classen))
26
+ - Unit test: play pre-recorded events [#98](https://github.com/whotracksme/webextension-packages/pull/98) ([@chrmod](https://github.com/chrmod))
27
+
28
+ #### Authors: 2
29
+
30
+ - Krzysztof Modras ([@chrmod](https://github.com/chrmod))
31
+ - Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
32
+
33
+ ---
34
+
1
35
  # v5.1.25 (Mon Sep 23 2024)
2
36
 
3
37
  #### πŸ› Bug Fix
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@whotracksme/reporting",
3
- "version": "5.1.25",
3
+ "version": "5.1.27",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "scripts": {
7
7
  "lint": "eslint reporting/ communication/",
8
8
  "lint.fix": "eslint --fix reporting/ communication/",
9
- "test": "npm run lint && npm run test --workspaces --if-present && npm run test.unit --workspaces --if-present",
9
+ "test": "npm run test --workspaces --if-present ",
10
+ "test.unit": "npm run test.unit --workspaces --if-present",
10
11
  "release": "auto shipit"
11
12
  },
12
13
  "publishConfig": {
@@ -112,9 +112,20 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
112
112
  sender,
113
113
  );
114
114
  } else if (request.action === 'debug') {
115
- sendResponse({
116
- tabs: [...webRequestPipeline.pageStore.tabs._inMemoryMap.values()],
117
- });
115
+ (async () => {
116
+ const tabs = await chrome.tabs.query({});
117
+
118
+ sendResponse({
119
+ tabs: tabs.map((tab) =>
120
+ webRequestPipeline.pageStore.getPageForRequest({
121
+ tabId: tab.id,
122
+ frameId: 0,
123
+ }),
124
+ ),
125
+ });
126
+ })();
127
+
128
+ return true;
118
129
  }
119
130
  });
120
131
 
@@ -11,8 +11,7 @@
11
11
  "webRequest",
12
12
  "tabs",
13
13
  "storage",
14
- "scripting",
15
- "windows"
14
+ "scripting"
16
15
  ],
17
16
  "action": {
18
17
  "default_title": "WTM/Reporting Inspector"
@@ -17,6 +17,8 @@ module.exports = function (config) {
17
17
  client: {
18
18
  TEST_FIXTURES_URL: process.env.TEST_FIXTURES_URL, // for test/search-extractor.spec.js
19
19
  REPLAY_FIXTURES_URL: process.env.REPLAY_FIXTURES_URL, // for test/pages.spec.js
20
+ VERBOSE_REPLAY: process.env.VERBOSE_REPLAY, // for test/pages.spec.js (better debugging)
21
+ ENABLE_SELF_CHECKS: process.env.ENABLE_SELF_CHECKS, // for test/pages.spec.js (might catch different bugs)
20
22
  },
21
23
  });
22
24
  };
@@ -7,7 +7,7 @@
7
7
  "start.firefox": "cp example/manifests/firefox.json example/manifest.json && web-ext run -s ./example -t firefox-desktop",
8
8
  "build": "rollup -c",
9
9
  "watch": "rollup -c -w",
10
- "test.unit": "mocha --file ./test/setup.unit.js ./test/**/*.test.js",
10
+ "test.unit": "mocha --file ./test/setup.unit.js './test/**/*.test.js'",
11
11
  "test.unit.watch": "npm run test.unit -- --node-option=watch",
12
12
  "test": "karma start --single-run --browsers ChromeHeadless karma.conf.cjs"
13
13
  },
@@ -19,6 +19,7 @@
19
19
  "@rollup/plugin-node-resolve": "^13.3.0",
20
20
  "chai": "^4.3.6",
21
21
  "chai-as-promised": "^7.1.1",
22
+ "fake-indexeddb": "^6.0.0",
22
23
  "fast-check": "^3.3.0",
23
24
  "karma": "^6.4.1",
24
25
  "karma-chai": "^0.1.0",
@@ -9,10 +9,10 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import logger from './logger';
13
- import { fastHash } from './utils';
14
- import PersistedBitarray from './persisted-bitarray';
15
- import SelfCheck from './self-check';
12
+ import logger from './logger.js';
13
+ import { fastHash } from './utils.js';
14
+ import PersistedBitarray from './persisted-bitarray.js';
15
+ import SelfCheck from './self-check.js';
16
16
 
17
17
  const SECOND = 1000;
18
18
  const MINUTE = 60 * SECOND;
@@ -9,7 +9,7 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import LRU from './LRU';
12
+ import LRU from './LRU.js';
13
13
 
14
14
  /* Fixed length lookup cache. Allows expensive operations to be cached for later lookup. Once
15
15
  * the cache limit is exceeded, least recently used values are removed.
@@ -103,7 +103,6 @@ export function setLogLevel(level, { prefix = '*' } = {}) {
103
103
  if (!SUPPORTED_LOG_LEVELS.has(level)) {
104
104
  throw new Error(`Unknow log level '${level}'`);
105
105
  }
106
-
107
106
  if (prefix === '*') {
108
107
  DEFAULT_LOG_LEVEL = level;
109
108
  }
@@ -9,7 +9,7 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import MapCache from './fixed-size-cache';
12
+ import MapCache from './fixed-size-cache.js';
13
13
 
14
14
  /**
15
15
  * Largely based on js-md5 (https://github.com/emn178/js-md5)
@@ -9,7 +9,7 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import logger from './logger';
12
+ import logger from './logger.js';
13
13
 
14
14
  const SECOND = 1000;
15
15
  const MINUTE = 60 * SECOND;
@@ -975,6 +975,10 @@ export default class Pages {
975
975
  windowId,
976
976
  lastUpdatedAt: now,
977
977
  };
978
+ if (!entry.pageId || entry.url !== oldTabEntry.url) {
979
+ entry.pageId = ++this._pageIdGenerator;
980
+ }
981
+
978
982
  this._initAllOptionalFields(tabId, entry, now);
979
983
  this.openTabs.set(tabId, entry);
980
984
  return;
@@ -1035,6 +1039,19 @@ export default class Pages {
1035
1039
  }
1036
1040
  }
1037
1041
 
1042
+ // Note that 'redirecting' did not originate from the browser API; it is
1043
+ // a meta state that represents the transition of an old to a new page.
1044
+ // If a link opened in a new tab, we need to merge the opener.
1045
+ if (
1046
+ entry.openedFrom?.status === 'redirecting' &&
1047
+ entry.openedFrom.openerTab
1048
+ ) {
1049
+ entry.openedFrom = {
1050
+ ...entry.openedFrom.openerTab,
1051
+ ...entry.openedFrom,
1052
+ };
1053
+ }
1054
+
1038
1055
  const previousUrl = entry.openedFrom?.url;
1039
1056
  if (isRealPage(previousUrl)) {
1040
1057
  entry.previousUrl = previousUrl;
@@ -1233,6 +1250,7 @@ export default class Pages {
1233
1250
  const entry = {
1234
1251
  status: 'created',
1235
1252
  ...oldEntry,
1253
+ pageId: ++this._pageIdGenerator,
1236
1254
  windowId,
1237
1255
  lastUpdatedAt: Date.now(),
1238
1256
  openerTab: { ...openerTab },
@@ -1241,9 +1259,8 @@ export default class Pages {
1241
1259
  }
1242
1260
 
1243
1261
  chrome_webNavigation_onBeforeNavigate(details) {
1244
- if (details.frameId !== 0) {
1245
- return;
1246
- }
1262
+ if (details.frameId !== 0) return; // not top-level frame (of the active page)
1263
+
1247
1264
  const { tabId, url } = details;
1248
1265
  const oldEntry = this.openTabs.get(tabId);
1249
1266
  if (oldEntry && oldEntry.url !== url) {
@@ -1265,9 +1282,8 @@ export default class Pages {
1265
1282
  // Safari quirks:
1266
1283
  // * The API exists, but "transitionType" is not supported
1267
1284
  chrome_webNavigation_onCommitted(details) {
1268
- if (details.frameId !== 0) {
1269
- return;
1270
- }
1285
+ if (details.frameId !== 0) return; // not top-level frame (of the active page)
1286
+
1271
1287
  const isBackOrForward =
1272
1288
  details.transitionQualifiers?.includes('forward_back');
1273
1289
 
@@ -1294,12 +1310,17 @@ export default class Pages {
1294
1310
  }
1295
1311
  }
1296
1312
 
1297
- // TODO: this needs to be thought through (the timing between chrome.tab and webNavigation might be subtle)
1298
- //
1299
1313
  // Safari quirks:
1300
1314
  // * This API is not available
1315
+ //
1316
+ // Firefox quirks (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation/TransitionQualifier):
1317
+ // * 'server_redirect' is limited to top-level frames
1318
+ // * 'client_redirect' is not supplied when redirections are created by JavaScript.
1301
1319
  chrome_webNavigation_onHistoryStateUpdated(details) {
1302
- const { tabId } = details;
1320
+ const { tabId, frameId, parentFrameId } = details;
1321
+ if (frameId !== 0) return; // not top-level frame (of the active page)
1322
+ if (parentFrameId !== -1) return; // not main frame
1323
+
1303
1324
  const entry = this.openTabs.get(tabId);
1304
1325
  if (!entry) {
1305
1326
  logger.warn('Navigation event in a non-existing tab detected!');
@@ -1360,25 +1381,22 @@ export default class Pages {
1360
1381
  }
1361
1382
  }
1362
1383
 
1363
- _initVisibility(tabId, entry) {
1384
+ _initVisibility(tabId, entry, now) {
1364
1385
  if (!entry.visibility) {
1365
1386
  const { visibility, search } = this._checkPageVisibility(entry.url);
1366
1387
  entry.visibility = visibility;
1367
- if (visibility !== 'private') {
1368
- if (search) {
1369
- entry.search = {
1370
- category: search.category,
1371
- query: search.query,
1372
- depth: 0,
1373
- lastUpdatedAt: Date.now(),
1374
- };
1375
- }
1388
+ if (visibility !== 'private' && search) {
1389
+ entry.search = {
1390
+ category: search.category,
1391
+ query: search.query,
1392
+ depth: 0,
1393
+ lastUpdatedAt: now,
1394
+ };
1376
1395
  }
1377
1396
  }
1378
1397
  }
1379
1398
 
1380
- _initAllOptionalFields(tabId, entry) {
1381
- const now = Date.now();
1399
+ _initAllOptionalFields(tabId, entry, now) {
1382
1400
  const { pageId } = entry;
1383
1401
  this._initVisibility(tabId, entry, now);
1384
1402
  this._tryAnalyzePageStructure(tabId, entry, now);
@@ -1791,6 +1809,51 @@ export default class Pages {
1791
1809
  if (pageIdClashes.length > 0) {
1792
1810
  check.warn('Found a pageId clash', Object.fromEntries(pageIdClashes));
1793
1811
  }
1812
+
1813
+ // checks for the active tab
1814
+ if (this.activeTab.tabId !== TAB_ID_NONE && this.activeTab.windowId) {
1815
+ const entry = this.openTabs.get(this.activeTab.tabId);
1816
+ if (entry?.windowId !== this.activeTab.windowId) {
1817
+ check.fail('mismatch between the activeTab and the openTabs', {
1818
+ activeTab: {
1819
+ tabId: this.activeTab.tabId,
1820
+ windowId: this.activeTab.windowId,
1821
+ },
1822
+ entry: entry ? { ...entry } : `<tab not found>`,
1823
+ });
1824
+ }
1825
+ }
1826
+
1827
+ // checks for the "search" attribute
1828
+ for (const [tabId, entry] of this.openTabs.entries()) {
1829
+ if (isNil(entry.search)) {
1830
+ continue;
1831
+ }
1832
+ const fail = (msg) => {
1833
+ check.fail(`inconsistency: ${msg}`, { tabId, entry: { ...entry } });
1834
+ };
1835
+
1836
+ if (isRealPage(entry.ref) && isRealPage(entry.url)) {
1837
+ if (
1838
+ entry.search.depth === 1 &&
1839
+ this.urlAnalyzer.parseSearchLinks(entry.ref).category !==
1840
+ entry.search.category &&
1841
+ sameHostname(entry.ref, entry.url)
1842
+ ) {
1843
+ fail(
1844
+ 'depth=1 search landing must not include internal page navigation',
1845
+ );
1846
+ } else if (
1847
+ entry.search.depth === 2 &&
1848
+ !sameHostname(entry.ref, entry.url)
1849
+ ) {
1850
+ fail('depth=2 search landings must stay on the same domains');
1851
+ }
1852
+ }
1853
+ if (![0, 1, 2].includes(entry.search.depth)) {
1854
+ fail('depth must be in { 0, 1, 2 }');
1855
+ }
1856
+ }
1794
1857
  })();
1795
1858
  await Promise.all([
1796
1859
  myChecks,
@@ -9,8 +9,8 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import logger from './logger';
13
- import SelfCheck from './self-check';
12
+ import logger from './logger.js';
13
+ import SelfCheck from './self-check.js';
14
14
 
15
15
  const SECOND = 1000;
16
16
 
@@ -9,8 +9,8 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import pacemaker from '../utils/pacemaker';
13
- import logger from '../logger';
12
+ import pacemaker from '../utils/pacemaker.js';
13
+ import logger from '../logger.js';
14
14
 
15
15
  const RETRY_TIMEOUT = 30 * 1000;
16
16
 
@@ -11,8 +11,8 @@
11
11
 
12
12
  /* eslint no-param-reassign: 'off' */
13
13
 
14
- import { isIpv4Address } from '../utils/url';
15
- import prob from './resources/prob';
14
+ import { isIpv4Address } from '../utils/url.js';
15
+ import prob from './resources/prob.js';
16
16
 
17
17
  export class HashProb {
18
18
  constructor() {
@@ -10,36 +10,35 @@
10
10
  */
11
11
 
12
12
  /* eslint-disable no-param-reassign */
13
- import Pipeline from '../webrequest-pipeline/pipeline';
14
- import { isPrivateIP } from '../utils/url';
15
- import pacemaker from '../utils/pacemaker';
16
-
17
- import { truncatedHash } from '../md5';
18
- import logger from '../logger';
19
-
20
- import * as datetime from './time';
21
- import QSWhitelist2 from './qs-whitelist2';
22
- import TempSet from './utils/temp-set';
23
- import { HashProb, shouldCheckToken } from './hash';
24
- import { VERSION, COOKIE_MODE } from './config';
25
- import { shuffle } from './utils';
26
- import buildPageLoadObject from './page-telemetry';
27
- import getTrackingStatus from './dnt';
28
- import random from '../random';
29
-
30
- import BlockRules from './steps/block-rules';
31
- import CookieContext from './steps/cookie-context';
32
- import PageLogger from './steps/page-logger';
33
- import RedirectTagger from './steps/redirect-tagger';
34
- import TokenChecker from './steps/token-checker/index';
35
- import TokenExaminer from './steps/token-examiner';
36
- import TokenTelemetry from './steps/token-telemetry/index';
37
- import OAuthDetector from './steps/oauth-detector';
13
+ import Pipeline from '../webrequest-pipeline/pipeline.js';
14
+ import { isLocalIP } from '../network.js';
15
+ import pacemaker from '../utils/pacemaker.js';
16
+
17
+ import { truncatedHash } from '../md5.js';
18
+ import logger from '../logger.js';
19
+
20
+ import * as datetime from './time.js';
21
+ import QSWhitelist2 from './qs-whitelist2.js';
22
+ import TempSet from './utils/temp-set.js';
23
+ import { HashProb, shouldCheckToken } from './hash.js';
24
+ import { VERSION, COOKIE_MODE } from './config.js';
25
+ import { shuffle } from './utils.js';
26
+ import buildPageLoadObject from './page-telemetry.js';
27
+ import random from '../random.js';
28
+
29
+ import BlockRules from './steps/block-rules.js';
30
+ import CookieContext from './steps/cookie-context.js';
31
+ import PageLogger from './steps/page-logger.js';
32
+ import RedirectTagger from './steps/redirect-tagger.js';
33
+ import TokenChecker from './steps/token-checker/index.js';
34
+ import TokenExaminer from './steps/token-examiner.js';
35
+ import TokenTelemetry from './steps/token-telemetry/index.js';
36
+ import OAuthDetector from './steps/oauth-detector.js';
38
37
 
39
38
  import {
40
39
  checkValidContext,
41
40
  checkSameGeneralDomain,
42
- } from './steps/check-context';
41
+ } from './steps/check-context.js';
43
42
 
44
43
  const DAY_CHANGE_INTERVAL = 20 * 1000;
45
44
  const RECENTLY_MODIFIED_TTL = 30 * 1000;
@@ -55,7 +54,7 @@ export default class RequestMonitor {
55
54
  communication,
56
55
  getBrowserInfo,
57
56
  onTrackerInteraction = (event, state) => {
58
- logger.log(`Tracker '${event}' with url: ${state.url}`);
57
+ logger.info('Tracker', event, 'with url:', state.url);
59
58
  },
60
59
  isRequestAllowed = () => false,
61
60
  },
@@ -254,9 +253,9 @@ export default class RequestMonitor {
254
253
  fn: (state) => steps.oAuthDetector.checkMainFrames(state),
255
254
  },
256
255
  {
257
- name: 'redirectTagger.checkRedirect',
256
+ name: 'checkIsMainDocument',
258
257
  spec: 'break',
259
- fn: (state) => steps.redirectTagger.checkRedirect(state),
258
+ fn: (state) => !state.isMainFrame,
260
259
  },
261
260
  {
262
261
  name: 'checkSameGeneralDomain',
@@ -381,11 +380,6 @@ export default class RequestMonitor {
381
380
  spec: 'collect', // TODO - global state
382
381
  fn: (state) => steps.cookieContext.assignCookieTrust(state),
383
382
  },
384
- {
385
- name: 'redirectTagger.confirmRedirect',
386
- spec: 'break',
387
- fn: (state) => steps.redirectTagger.confirmRedirect(state),
388
- },
389
383
  {
390
384
  name: 'checkIsMainDocument',
391
385
  spec: 'break',
@@ -517,20 +511,9 @@ export default class RequestMonitor {
517
511
  fn: checkValidContext,
518
512
  },
519
513
  {
520
- name: 'checkMainDocumentRedirects',
514
+ name: 'checkIsMainDocument',
521
515
  spec: 'break',
522
- fn: (state) => {
523
- if (state.isMainFrame) {
524
- // check for tracking status headers for first party
525
- const trackingStatus = getTrackingStatus(state);
526
- if (trackingStatus) {
527
- state.page.tsv = trackingStatus.value;
528
- state.page.tsvId = trackingStatus.statusId;
529
- }
530
- return false;
531
- }
532
- return true;
533
- },
516
+ fn: (state) => !state.isMainFrame,
534
517
  },
535
518
  {
536
519
  name: 'checkSameGeneralDomain',
@@ -547,28 +530,6 @@ export default class RequestMonitor {
547
530
  spec: 'annotate',
548
531
  fn: (state) => steps.pageLogger.onHeadersReceived(state),
549
532
  },
550
- {
551
- name: 'logResponseStats',
552
- spec: 'collect',
553
- fn: (state) => {
554
- if (state.incrementStat) {
555
- // TSV stats
556
- if (
557
- this.qs_whitelist.isTrackerDomain(
558
- truncatedHash(state.urlParts.generalDomain),
559
- )
560
- ) {
561
- const trackingStatus = getTrackingStatus(state);
562
- if (trackingStatus) {
563
- state.incrementStat(`tsv_${trackingStatus.value}`);
564
- if (trackingStatus.statusId) {
565
- state.incrementStat('tsv_status');
566
- }
567
- }
568
- }
569
- }
570
- },
571
- },
572
533
  {
573
534
  name: 'checkSetCookie',
574
535
  spec: 'break',
@@ -640,7 +601,7 @@ export default class RequestMonitor {
640
601
  spec: 'break',
641
602
  fn: (state) => {
642
603
  if (state.isMainFrame && state.ip) {
643
- if (isPrivateIP(state.ip)) {
604
+ if (isLocalIP(state.ip)) {
644
605
  state.page.isPrivateServer = true;
645
606
  }
646
607
  return false;
@@ -9,8 +9,8 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import { truncatedHash } from '../md5';
13
- import { parse } from '../utils/url';
12
+ import { truncatedHash } from '../md5.js';
13
+ import { parse } from '../utils/url.js';
14
14
 
15
15
  function truncatePath(path) {
16
16
  // extract the first part of the page path
@@ -35,8 +35,8 @@ export default function buildPageLoadObject(page) {
35
35
  redirects: [],
36
36
  redirectsPlaceHolder: [],
37
37
  triggeringTree: {},
38
- tsv: page.tsv,
39
- tsv_id: page.tsvId !== undefined,
38
+ tsv: '',
39
+ tsv_id: false,
40
40
  frames: {},
41
41
  };
42
42
  }
@@ -11,9 +11,9 @@
11
11
 
12
12
  import { differenceInDays, parseISO, getUnixTime, sub } from 'date-fns';
13
13
 
14
- import PackedBloomFilter from './utils/bloom-filter-packed';
15
- import pacemaker from '../utils/pacemaker';
16
- import logger from '../logger';
14
+ import PackedBloomFilter from './utils/bloom-filter-packed.js';
15
+ import pacemaker from '../utils/pacemaker.js';
16
+ import logger from '../logger.js';
17
17
 
18
18
  const STORAGE_CONFIG_KEY = 'qs_config';
19
19
  const STORAGE_BLOOM_FILTER_KEY = 'qs_bloom_filter';
@@ -9,12 +9,12 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import { truncatedHash } from '../../md5';
13
- import pacemaker from '../../utils/pacemaker';
14
- import { parse } from '../../utils/url';
15
- import { sameGeneralDomain, getGeneralDomain } from '../utils/tlds';
16
- import logger from '../../logger';
17
- import ChromeStorageMap from '../utils/chrome-storage-map';
12
+ import { truncatedHash } from '../../md5.js';
13
+ import pacemaker from '../../utils/pacemaker.js';
14
+ import { parse } from '../../utils/url.js';
15
+ import { sameGeneralDomain, getGeneralDomain } from '../utils/tlds.js';
16
+ import logger from '../../logger.js';
17
+ import ChromeStorageMap from '../utils/chrome-storage-map.js';
18
18
 
19
19
  const TIME_AFTER_LINK = 5 * 1000;
20
20
  const TIME_CLEANING_CACHE = 3 * 60 * 1000; // 3 minutes
@@ -9,9 +9,9 @@
9
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0
10
10
  */
11
11
 
12
- import { parse } from '../../utils/url';
13
- import Subject from '../utils/subject';
14
- import ChromeStorageMap from '../utils/chrome-storage-map';
12
+ import { parse } from '../../utils/url.js';
13
+ import Subject from '../utils/subject.js';
14
+ import ChromeStorageMap from '../utils/chrome-storage-map.js';
15
15
 
16
16
  const DEFAULT_OPTIONS = {
17
17
  CLICK_TIMEOUT: 5 * 60 * 1000,
@@ -10,8 +10,8 @@
10
10
  */
11
11
 
12
12
  /* eslint no-param-reassign: 'off' */
13
- import { truncateDomain } from '../utils';
14
- import { getStatsForDomain } from '../../webrequest-pipeline/page.js';
13
+
14
+ import { truncateDomain } from '../utils.js';
15
15
 
16
16
  // maps string (web-ext) to int (FF cpt). Anti-tracking still uses these legacy types.
17
17
  const TYPE_LOOKUP = {
@@ -45,8 +45,7 @@ export default class PageLogger {
45
45
  }
46
46
 
47
47
  _attachCounters(state) {
48
- const stats = getStatsForDomain(
49
- state.page,
48
+ const stats = state.page.getStatsForDomain(
50
49
  truncateDomain(state.urlParts.domainInfo, 2),
51
50
  );
52
51
  state.reqLog = stats;
@@ -99,9 +98,6 @@ export default class PageLogger {
99
98
  const scheme = isHTTP(urlParts.protocol) ? urlParts.scheme : 'other';
100
99
  incrementStat(`scheme_${scheme}`);
101
100
 
102
- // find frame depth
103
- incrementStat(`window_depth_${Math.min(state.frameAncestors.length, 2)}`);
104
-
105
101
  if (state.url.indexOf(this.config.placeHolder) > -1) {
106
102
  incrementStat('hasPlaceHolder');
107
103
  }