@whotracksme/reporting 5.1.29 → 5.1.30
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 +25 -0
- package/package.json +1 -1
- package/reporting/example/index.js +2 -12
- package/reporting/example/manifests/chromium.json +1 -0
- package/reporting/snapshots/0001/snapshot.json +1 -1
- package/reporting/snapshots/0002/snapshot.json +2 -2
- package/reporting/snapshots/0003/events.log.br +0 -0
- package/reporting/snapshots/0003/snapshot.json +855 -0
- package/reporting/snapshots/0004/events.log.br +0 -0
- package/reporting/snapshots/0004/snapshot.json +802 -0
- package/reporting/src/hash-detector.js +1 -1
- package/reporting/src/index.js +1 -2
- package/reporting/src/request/config.js +9 -4
- package/reporting/src/request/{hash.js → hash/index.js} +3 -3
- package/reporting/src/request/index.js +445 -494
- package/reporting/src/{webrequest-pipeline → request}/page-store.js +65 -75
- package/reporting/src/request/qs-whitelist2.js +0 -2
- package/reporting/src/request/steps/cookie-context.js +6 -5
- package/reporting/src/request/steps/oauth-detector.js +3 -24
- package/reporting/src/request/steps/page-logger.js +3 -4
- package/reporting/src/request/steps/token-checker/token-domain.js +1 -1
- package/reporting/src/request/steps/token-examiner.js +3 -4
- package/reporting/src/request/steps/token-telemetry/cached-entry-pipeline.js +52 -68
- package/reporting/src/request/steps/token-telemetry/index.js +86 -113
- package/reporting/src/request/steps/token-telemetry/key-pipeline.js +3 -2
- package/reporting/src/request/steps/token-telemetry/token-pipeline.js +3 -2
- package/reporting/src/request/utils/temp-set.js +2 -4
- package/reporting/src/request/{time.js → utils/time.js} +0 -5
- package/reporting/src/request/utils/tlds.js +1 -11
- package/reporting/src/request/{utils.js → utils/utils.js} +9 -0
- package/reporting/src/{webrequest-pipeline/webrequest-context.js → request/utils/webrequest.js} +84 -4
- package/reporting/src/utils/url.js +0 -25
- package/reporting/test/helpers/scenarios.js +1 -1
- package/reporting/test/index.js +3 -8
- package/reporting/test/request/{hash.spec.js → hash/index.spec.js} +2 -2
- package/reporting/test/request/index.spec.js +23 -46
- package/reporting/test/{request-reporter.test.js → request/index.test.js} +13 -17
- package/reporting/test/{webrequest-pipeline → request}/page-store.test.js +1 -1
- package/reporting/test/request/steps/oauth-detector.spec.js +15 -25
- package/reporting/test/request/{utils.spec.js → utils/utils.spec.js} +2 -2
- package/reporting/test/utils/url.spec.js +1 -26
- package/reporting/src/request/page-telemetry.js +0 -42
- package/reporting/src/request/steps/subdomain-check.js +0 -34
- package/reporting/src/request/utils/subject.js +0 -37
- package/reporting/src/request-reporter.js +0 -111
- package/reporting/src/utils/pacemaker.js +0 -279
- package/reporting/src/webrequest-pipeline/cname-uncloak.js +0 -110
- package/reporting/src/webrequest-pipeline/index.js +0 -286
- package/reporting/src/webrequest-pipeline/logger.js +0 -14
- package/reporting/src/webrequest-pipeline/pipeline.js +0 -249
- package/reporting/src/webrequest-pipeline/utils/webrequest.js +0 -119
- package/reporting/test/utils/pacemaker.spec.js +0 -222
- package/reporting/test/webrequest-pipeline/index.test.js +0 -160
- package/reporting/test/webrequest-pipeline/pipeline.spec.js +0 -251
- /package/reporting/src/request/{resources → hash}/prob.js +0 -0
|
@@ -21,10 +21,7 @@ import { createFetchMock } from '../helpers/fetch-mock';
|
|
|
21
21
|
|
|
22
22
|
import { truncatedHash, default as md5 } from '../../src/md5.js';
|
|
23
23
|
|
|
24
|
-
import
|
|
25
|
-
import Database from '../../src/request/database.js';
|
|
26
|
-
import RequestMonitor from '../../src/request/index.js';
|
|
27
|
-
import WebrequestPipeline from '../../src/webrequest-pipeline/index.js';
|
|
24
|
+
import RequestReporter from '../../src/request/index.js';
|
|
28
25
|
|
|
29
26
|
const THIRD_PARTY_HOST1 = '127.0.0.1:60508';
|
|
30
27
|
const THIRD_PARTY_HOST2 = 'cliqztest2.de:60508';
|
|
@@ -57,8 +54,6 @@ describe('request/index', function () {
|
|
|
57
54
|
let oldChromeStorageSession;
|
|
58
55
|
let oldChromeStorage;
|
|
59
56
|
|
|
60
|
-
let pipeline;
|
|
61
|
-
|
|
62
57
|
beforeEach(() => {
|
|
63
58
|
if (!chrome?.storage?.session) {
|
|
64
59
|
monkeyPatchedChromeStorage = true;
|
|
@@ -71,18 +66,14 @@ describe('request/index', function () {
|
|
|
71
66
|
// indicate that there are bugs in the implementation or in the tests.
|
|
72
67
|
chrome.storage.session = chrome.storage.local;
|
|
73
68
|
chrome.storage.session.get.yields({});
|
|
69
|
+
chrome.tabs.query.returns([]);
|
|
74
70
|
|
|
75
71
|
// to test against a real in-memory implementation:
|
|
76
72
|
// chrome.storage.session = new FakeSessionApi();
|
|
77
73
|
}
|
|
78
|
-
|
|
79
|
-
pipeline = new WebrequestPipeline();
|
|
80
|
-
pipeline.init();
|
|
81
74
|
});
|
|
82
75
|
|
|
83
76
|
afterEach(() => {
|
|
84
|
-
pipeline?.unload();
|
|
85
|
-
pipeline = null;
|
|
86
77
|
if (monkeyPatchedChromeStorage) {
|
|
87
78
|
chrome.storage.session = oldChromeStorageSession;
|
|
88
79
|
chrome.storage = oldChromeStorage;
|
|
@@ -90,7 +81,6 @@ describe('request/index', function () {
|
|
|
90
81
|
});
|
|
91
82
|
|
|
92
83
|
let attrack;
|
|
93
|
-
let config;
|
|
94
84
|
let fetchMock = createFetchMock();
|
|
95
85
|
|
|
96
86
|
beforeEach(async function () {
|
|
@@ -101,36 +91,24 @@ describe('request/index', function () {
|
|
|
101
91
|
return '';
|
|
102
92
|
},
|
|
103
93
|
};
|
|
104
|
-
|
|
105
|
-
await db.init();
|
|
106
|
-
config = new Config(
|
|
94
|
+
attrack = new RequestReporter(
|
|
107
95
|
{
|
|
108
96
|
configUrl: 'http://cdn',
|
|
109
97
|
remoteWhitelistUrl: 'http://cdn',
|
|
110
98
|
localWhitelistUrl: '/base/assets/request',
|
|
111
99
|
},
|
|
112
100
|
{
|
|
113
|
-
db,
|
|
114
|
-
trustedClock,
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
await config.init();
|
|
118
|
-
attrack = new RequestMonitor(
|
|
119
|
-
{},
|
|
120
|
-
{
|
|
121
|
-
db,
|
|
122
|
-
webRequestPipeline: pipeline,
|
|
123
101
|
countryProvider: {},
|
|
124
102
|
trustedClock,
|
|
125
103
|
communication: {},
|
|
126
104
|
getBrowserInfo: () => ({ name: 'xx' }),
|
|
127
105
|
},
|
|
128
106
|
);
|
|
129
|
-
await attrack.init(
|
|
107
|
+
await attrack.init();
|
|
130
108
|
await attrack.qs_whitelist.initPromise;
|
|
131
|
-
config.cookieEnabled = false;
|
|
132
|
-
config.qsEnabled = false;
|
|
133
|
-
config.placeHolder = '<removed>';
|
|
109
|
+
attrack.config.cookieEnabled = false;
|
|
110
|
+
attrack.config.qsEnabled = false;
|
|
111
|
+
attrack.config.placeHolder = '<removed>';
|
|
134
112
|
});
|
|
135
113
|
|
|
136
114
|
afterEach(() => {
|
|
@@ -143,18 +121,18 @@ describe('request/index', function () {
|
|
|
143
121
|
chrome.tabs.onCreated.dispatch(pageSpec.tab);
|
|
144
122
|
return {
|
|
145
123
|
onBeforeRequest: pageSpec.onBeforeRequest.map(function (reqData) {
|
|
146
|
-
const response =
|
|
124
|
+
const response = attrack.onBeforeRequest(reqData);
|
|
147
125
|
return { url: reqData.url, response };
|
|
148
126
|
}),
|
|
149
127
|
onBeforeSendHeaders: pageSpec.onBeforeSendHeaders.map(function (reqData) {
|
|
150
128
|
reqData.requestHeaders = mockRequestHeaders;
|
|
151
|
-
const response =
|
|
129
|
+
const response = attrack.onBeforeSendHeaders(reqData);
|
|
152
130
|
return { url: reqData.url, response };
|
|
153
131
|
}),
|
|
154
132
|
onHeadersReceived: pageSpec.onHeadersReceived.map(function (reqData) {
|
|
155
133
|
reqData.requestHeaders = mockRequestHeaders;
|
|
156
134
|
reqData.responseHeaders = mockResponseHeaders;
|
|
157
|
-
const response =
|
|
135
|
+
const response = attrack.onHeadersReceived(reqData);
|
|
158
136
|
return { url: reqData.url, response };
|
|
159
137
|
}),
|
|
160
138
|
};
|
|
@@ -167,7 +145,7 @@ describe('request/index', function () {
|
|
|
167
145
|
describe('cookie blocking', function () {
|
|
168
146
|
describe('cookie blocking disabled', function () {
|
|
169
147
|
beforeEach(function () {
|
|
170
|
-
config.cookieEnabled = false;
|
|
148
|
+
attrack.config.cookieEnabled = false;
|
|
171
149
|
});
|
|
172
150
|
|
|
173
151
|
it('allows all cookies', function () {
|
|
@@ -179,7 +157,7 @@ describe('request/index', function () {
|
|
|
179
157
|
|
|
180
158
|
describe('cookie blocking enabled', function () {
|
|
181
159
|
beforeEach(function () {
|
|
182
|
-
config.cookieEnabled = true;
|
|
160
|
+
attrack.config.cookieEnabled = true;
|
|
183
161
|
});
|
|
184
162
|
|
|
185
163
|
it('blocks third party cookies', function () {
|
|
@@ -199,7 +177,7 @@ describe('request/index', function () {
|
|
|
199
177
|
|
|
200
178
|
context('QS blocking', function () {
|
|
201
179
|
beforeEach(function () {
|
|
202
|
-
config.qsEnabled = true;
|
|
180
|
+
attrack.config.qsEnabled = true;
|
|
203
181
|
});
|
|
204
182
|
|
|
205
183
|
it('allows query strings on domains not in the tracker list', function () {
|
|
@@ -217,8 +195,8 @@ describe('request/index', function () {
|
|
|
217
195
|
key = md5('uid');
|
|
218
196
|
trackerHash = truncatedHash('127.0.0.1');
|
|
219
197
|
attrack.qs_whitelist.addSafeToken(trackerHash, '');
|
|
220
|
-
config.tokenDomainCountThreshold = 2;
|
|
221
|
-
attrack.
|
|
198
|
+
attrack.config.tokenDomainCountThreshold = 2;
|
|
199
|
+
attrack.tokenChecker.tokenDomain.clear();
|
|
222
200
|
});
|
|
223
201
|
|
|
224
202
|
it('allows QS first time on tracker', function () {
|
|
@@ -239,7 +217,7 @@ describe('request/index', function () {
|
|
|
239
217
|
}
|
|
240
218
|
|
|
241
219
|
beforeEach(function () {
|
|
242
|
-
config.tokenDomainCountThreshold = 0;
|
|
220
|
+
attrack.config.tokenDomainCountThreshold = 0;
|
|
243
221
|
});
|
|
244
222
|
|
|
245
223
|
it('blocks long tokens on tracker domain', function () {
|
|
@@ -280,14 +258,13 @@ describe('request/index', function () {
|
|
|
280
258
|
const uid = '04C2EAD03BAB7F5E-2E85855CF4C75134';
|
|
281
259
|
|
|
282
260
|
beforeEach(function () {
|
|
283
|
-
config.qsEnabled = true;
|
|
261
|
+
attrack.config.qsEnabled = true;
|
|
284
262
|
attrack.qs_whitelist.addSafeToken(truncatedHash('tracker.com'), '');
|
|
285
|
-
config.tokenDomainCountThreshold = 0; // block first time
|
|
286
|
-
return attrack.initPipeline();
|
|
263
|
+
attrack.config.tokenDomainCountThreshold = 0; // block first time
|
|
287
264
|
});
|
|
288
265
|
|
|
289
266
|
it('removes all occurances of uid in the request', function () {
|
|
290
|
-
const mainDoc =
|
|
267
|
+
const mainDoc = attrack.onBeforeRequest({
|
|
291
268
|
tabId: 34,
|
|
292
269
|
frameId: 0,
|
|
293
270
|
parentFrameId: -1,
|
|
@@ -299,7 +276,7 @@ describe('request/index', function () {
|
|
|
299
276
|
chai.expect(mainDoc).to.not.have.property('cancel');
|
|
300
277
|
chai.expect(mainDoc).to.not.have.property('redirectUrl');
|
|
301
278
|
chai.expect(mainDoc).to.not.have.property('requestHeaders');
|
|
302
|
-
const response =
|
|
279
|
+
const response = attrack.onBeforeRequest({
|
|
303
280
|
tabId: 34,
|
|
304
281
|
frameId: 0,
|
|
305
282
|
parentFrameId: -1,
|
|
@@ -318,7 +295,7 @@ describe('request/index', function () {
|
|
|
318
295
|
});
|
|
319
296
|
|
|
320
297
|
it('removes also after subsequent redirect with same uid', function () {
|
|
321
|
-
const mainDoc =
|
|
298
|
+
const mainDoc = attrack.onBeforeRequest({
|
|
322
299
|
tabId: 34,
|
|
323
300
|
frameId: 0,
|
|
324
301
|
parentFrameId: -1,
|
|
@@ -332,7 +309,7 @@ describe('request/index', function () {
|
|
|
332
309
|
chai.expect(mainDoc).to.not.have.property('cancel');
|
|
333
310
|
chai.expect(mainDoc).to.not.have.property('redirectUrl');
|
|
334
311
|
chai.expect(mainDoc).to.not.have.property('requestHeaders');
|
|
335
|
-
let response =
|
|
312
|
+
let response = attrack.onBeforeRequest({
|
|
336
313
|
tabId: 34,
|
|
337
314
|
frameId: 0,
|
|
338
315
|
parentFrameId: -1,
|
|
@@ -350,7 +327,7 @@ describe('request/index', function () {
|
|
|
350
327
|
chai.expect(response.redirectUrl).to.not.contain(uid);
|
|
351
328
|
chai.expect(response.redirectUrl).to.not.contain(encodeURIComponent(uid));
|
|
352
329
|
|
|
353
|
-
response =
|
|
330
|
+
response = attrack.onBeforeRequest({
|
|
354
331
|
tabId: 34,
|
|
355
332
|
frameId: 0,
|
|
356
333
|
parentFrameId: -1,
|
|
@@ -21,12 +21,11 @@ import {
|
|
|
21
21
|
playSnapshotScenario,
|
|
22
22
|
recordSnapshot,
|
|
23
23
|
readSnapshot,
|
|
24
|
-
} from '
|
|
25
|
-
import { base64ToArrayBuffer } from '
|
|
24
|
+
} from '../helpers/scenarios.js';
|
|
25
|
+
import { base64ToArrayBuffer } from '../helpers/fetch-mock.js';
|
|
26
26
|
|
|
27
|
-
import { setLogLevel } from '
|
|
28
|
-
import RequestReporter from '
|
|
29
|
-
import WebRequestPipeline from '../src/webrequest-pipeline/index.js';
|
|
27
|
+
import { setLogLevel } from '../../src/logger.js';
|
|
28
|
+
import RequestReporter from '../../src/request/index.js';
|
|
30
29
|
|
|
31
30
|
const config = {
|
|
32
31
|
configUrl: 'config',
|
|
@@ -74,6 +73,7 @@ describe('RequestReporter', function () {
|
|
|
74
73
|
beforeEach(function () {
|
|
75
74
|
chrome.flush();
|
|
76
75
|
chrome.storage.session.get.yields({});
|
|
76
|
+
chrome.tabs.query.returns([]);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
after(function () {
|
|
@@ -109,22 +109,18 @@ describe('RequestReporter', function () {
|
|
|
109
109
|
},
|
|
110
110
|
trustedClock,
|
|
111
111
|
};
|
|
112
|
-
const webRequestPipeline = new WebRequestPipeline();
|
|
113
|
-
await webRequestPipeline.init();
|
|
114
112
|
reporter = new RequestReporter(config, {
|
|
115
113
|
communication,
|
|
116
|
-
webRequestPipeline,
|
|
117
114
|
trustedClock,
|
|
118
115
|
getBrowserInfo: () => ({ name: 'xx' }),
|
|
119
116
|
countryProvider: { getSafeCountryCode: () => 'en' },
|
|
120
117
|
});
|
|
121
118
|
await reporter.init();
|
|
122
|
-
await reporter.
|
|
119
|
+
await reporter.qs_whitelist.initPromise;
|
|
123
120
|
});
|
|
124
121
|
|
|
125
122
|
afterEach(function () {
|
|
126
123
|
reporter.unload();
|
|
127
|
-
reporter.webRequestPipeline.unload();
|
|
128
124
|
reporter = undefined;
|
|
129
125
|
clock.restore();
|
|
130
126
|
delete globalThis.indexedDB;
|
|
@@ -138,11 +134,11 @@ describe('RequestReporter', function () {
|
|
|
138
134
|
});
|
|
139
135
|
await clock.runToLast();
|
|
140
136
|
expect(
|
|
141
|
-
reporter.
|
|
137
|
+
reporter.pageStore.checkIfEmpty(),
|
|
142
138
|
).to.be.false;
|
|
143
139
|
expect(seenTabIds).to.have.property('size', 1);
|
|
144
140
|
const tabId = seenTabIds.values().next().value;
|
|
145
|
-
const tab = reporter.
|
|
141
|
+
const tab = reporter.pageStore.getPageForRequest({
|
|
146
142
|
tabId,
|
|
147
143
|
frameId: 0,
|
|
148
144
|
});
|
|
@@ -158,11 +154,11 @@ describe('RequestReporter', function () {
|
|
|
158
154
|
});
|
|
159
155
|
await clock.runToLast();
|
|
160
156
|
expect(
|
|
161
|
-
reporter.
|
|
157
|
+
reporter.pageStore.checkIfEmpty(),
|
|
162
158
|
).to.be.false;
|
|
163
159
|
expect(seenTabIds).to.have.property('size', 1);
|
|
164
160
|
const tabId = seenTabIds.values().next().value;
|
|
165
|
-
const tab = reporter.
|
|
161
|
+
const tab = reporter.pageStore.getPageForRequest({
|
|
166
162
|
tabId,
|
|
167
163
|
frameId: 0,
|
|
168
164
|
});
|
|
@@ -281,7 +277,7 @@ describe('RequestReporter', function () {
|
|
|
281
277
|
}
|
|
282
278
|
}
|
|
283
279
|
|
|
284
|
-
for (const snapshotName of ['0001', '0002']) {
|
|
280
|
+
for (const snapshotName of ['0001', '0002', '0003', '0004']) {
|
|
285
281
|
it(snapshotName, async function () {
|
|
286
282
|
const messages = [];
|
|
287
283
|
communicationEmiter.addListener('send', (message) =>
|
|
@@ -291,10 +287,10 @@ describe('RequestReporter', function () {
|
|
|
291
287
|
|
|
292
288
|
// run twice to allow token telemetry to trigger
|
|
293
289
|
playSnapshotScenario(chrome, snapshotName, {
|
|
294
|
-
rewriteUrls: { 'onet.pl': 'wp.pl' },
|
|
290
|
+
rewriteUrls: { 'onet.pl': 'wp.pl', 'soundcloud.com': 'google.com' },
|
|
295
291
|
});
|
|
296
292
|
await processRunloopUntil(
|
|
297
|
-
reporter.
|
|
293
|
+
reporter.tokenTelemetry
|
|
298
294
|
.NEW_ENTRY_MIN_AGE,
|
|
299
295
|
);
|
|
300
296
|
|
|
@@ -13,7 +13,7 @@ import chrome from 'sinon-chrome';
|
|
|
13
13
|
import { mock, match } from 'sinon';
|
|
14
14
|
import { expect } from 'chai';
|
|
15
15
|
|
|
16
|
-
import PageStore from '../../src/
|
|
16
|
+
import PageStore from '../../src/request/page-store.js';
|
|
17
17
|
|
|
18
18
|
describe('PageStore', function () {
|
|
19
19
|
before(function () {
|
|
@@ -74,15 +74,11 @@ describe('request/steps/oauth-detector', function () {
|
|
|
74
74
|
await detectorInstance.init();
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
afterEach(function () {
|
|
78
|
-
detectorInstance.unload();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
77
|
it('registers clicks on tabs', (done) => {
|
|
82
78
|
const tab = 5;
|
|
83
79
|
const url = 'https://cliqz.com';
|
|
84
80
|
const sender = mockSender(tab, url);
|
|
85
|
-
detectorInstance.recordClick(
|
|
81
|
+
detectorInstance.recordClick(sender);
|
|
86
82
|
delayedTest(
|
|
87
83
|
() => {
|
|
88
84
|
chai
|
|
@@ -102,8 +98,8 @@ describe('request/steps/oauth-detector', function () {
|
|
|
102
98
|
const tab = 5;
|
|
103
99
|
const url1 = 'https://cliqz.com';
|
|
104
100
|
const url2 = 'https://ghostery.com';
|
|
105
|
-
detectorInstance.recordClick(
|
|
106
|
-
detectorInstance.recordClick(
|
|
101
|
+
detectorInstance.recordClick(mockSender(tab, url1));
|
|
102
|
+
detectorInstance.recordClick(mockSender(tab, url2));
|
|
107
103
|
delayedTest(
|
|
108
104
|
() => {
|
|
109
105
|
chai
|
|
@@ -124,8 +120,8 @@ describe('request/steps/oauth-detector', function () {
|
|
|
124
120
|
const tab2 = 6;
|
|
125
121
|
const url1 = 'https://cliqz.com';
|
|
126
122
|
const url2 = 'https://ghostery.com';
|
|
127
|
-
detectorInstance.recordClick(
|
|
128
|
-
detectorInstance.recordClick(
|
|
123
|
+
detectorInstance.recordClick(mockSender(tab1, url1));
|
|
124
|
+
detectorInstance.recordClick(mockSender(tab2, url2));
|
|
129
125
|
delayedTest(
|
|
130
126
|
() => {
|
|
131
127
|
chai
|
|
@@ -146,7 +142,7 @@ describe('request/steps/oauth-detector', function () {
|
|
|
146
142
|
const tab = 5;
|
|
147
143
|
const url = 'https://cliqz.com';
|
|
148
144
|
const sender = mockSender(tab, url);
|
|
149
|
-
detectorInstance.recordClick(
|
|
145
|
+
detectorInstance.recordClick(sender);
|
|
150
146
|
delayedTest(
|
|
151
147
|
() => {
|
|
152
148
|
chai
|
|
@@ -165,10 +161,9 @@ describe('request/steps/oauth-detector', function () {
|
|
|
165
161
|
const tab2 = 6;
|
|
166
162
|
const url1 = 'https://cliqz.com';
|
|
167
163
|
const url2 = 'https://ghostery.com';
|
|
168
|
-
detectorInstance.recordClick(
|
|
164
|
+
detectorInstance.recordClick(mockSender(tab1, url1));
|
|
169
165
|
setTimeout(
|
|
170
|
-
() =>
|
|
171
|
-
detectorInstance.recordClick(null, '', '', mockSender(tab2, url2)),
|
|
166
|
+
() => detectorInstance.recordClick(mockSender(tab2, url2)),
|
|
172
167
|
10,
|
|
173
168
|
);
|
|
174
169
|
delayedTest(
|
|
@@ -191,11 +186,10 @@ describe('request/steps/oauth-detector', function () {
|
|
|
191
186
|
const tab2 = 6;
|
|
192
187
|
const url1 = 'https://cliqz.com';
|
|
193
188
|
const url2 = 'https://ghostery.com';
|
|
194
|
-
detectorInstance.recordClick(
|
|
195
|
-
detectorInstance.recordClick(
|
|
189
|
+
detectorInstance.recordClick(mockSender(tab1, url1));
|
|
190
|
+
detectorInstance.recordClick(mockSender(tab2, url2));
|
|
196
191
|
setTimeout(
|
|
197
|
-
() =>
|
|
198
|
-
detectorInstance.recordClick(null, '', '', mockSender(tab1, url1)),
|
|
192
|
+
() => detectorInstance.recordClick(mockSender(tab1, url1)),
|
|
199
193
|
10,
|
|
200
194
|
);
|
|
201
195
|
delayedTest(
|
|
@@ -236,10 +230,6 @@ describe('request/steps/oauth-detector', function () {
|
|
|
236
230
|
await detectorInstance.init();
|
|
237
231
|
});
|
|
238
232
|
|
|
239
|
-
afterEach(function () {
|
|
240
|
-
detectorInstance.unload();
|
|
241
|
-
});
|
|
242
|
-
|
|
243
233
|
it('returns true when there has been no activity and the URL contains "/oauth"', () => {
|
|
244
234
|
const state = mockState(
|
|
245
235
|
5,
|
|
@@ -261,7 +251,7 @@ describe('request/steps/oauth-detector', function () {
|
|
|
261
251
|
it('returns true when there is only a click', (done) => {
|
|
262
252
|
const tab = 5;
|
|
263
253
|
const tabUrl = 'https://cliqz.com/';
|
|
264
|
-
detectorInstance.recordClick(
|
|
254
|
+
detectorInstance.recordClick(mockSender(tab, tabUrl));
|
|
265
255
|
const state = mockState(tab, 'https://auth.ghostery.com/oauth', tabUrl);
|
|
266
256
|
delayedTest(
|
|
267
257
|
() => {
|
|
@@ -275,7 +265,7 @@ describe('request/steps/oauth-detector', function () {
|
|
|
275
265
|
it('returns false with click and page', (done) => {
|
|
276
266
|
const tab = 5;
|
|
277
267
|
const tabUrl = 'https://cliqz.com/';
|
|
278
|
-
detectorInstance.recordClick(
|
|
268
|
+
detectorInstance.recordClick(mockSender(tab, tabUrl));
|
|
279
269
|
const fullPageState = mockState(
|
|
280
270
|
tab + 1,
|
|
281
271
|
'https://auth.ghostery.com/',
|
|
@@ -296,7 +286,7 @@ describe('request/steps/oauth-detector', function () {
|
|
|
296
286
|
it('returns true if page domain does not match', (done) => {
|
|
297
287
|
const tab = 5;
|
|
298
288
|
const tabUrl = 'https://cliqz.com/';
|
|
299
|
-
detectorInstance.recordClick(
|
|
289
|
+
detectorInstance.recordClick(mockSender(tab, tabUrl));
|
|
300
290
|
const fullPageState = mockState(
|
|
301
291
|
tab + 1,
|
|
302
292
|
'https://www.ghostery.com/',
|
|
@@ -318,7 +308,7 @@ describe('request/steps/oauth-detector', function () {
|
|
|
318
308
|
const tab = 5;
|
|
319
309
|
const tabUrl = 'https://cliqz.com/';
|
|
320
310
|
const tabUrl2 = 'https://www.cliqz.com/';
|
|
321
|
-
detectorInstance.recordClick(
|
|
311
|
+
detectorInstance.recordClick(mockSender(tab, tabUrl));
|
|
322
312
|
const fullPageState = mockState(
|
|
323
313
|
tab + 1,
|
|
324
314
|
'https://www.ghostery.com/',
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
import * as chai from 'chai';
|
|
13
13
|
|
|
14
|
-
import { truncateDomain } from '
|
|
14
|
+
import { truncateDomain } from '../../../src/request/utils/utils';
|
|
15
15
|
|
|
16
|
-
describe('request/utils', function () {
|
|
16
|
+
describe('request/utils/utils', function () {
|
|
17
17
|
describe('truncateDomain', function () {
|
|
18
18
|
it('does not change domain which is already tld+1', () => {
|
|
19
19
|
chai
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import * as chai from 'chai';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { parse } from '../../src/utils/url';
|
|
15
15
|
|
|
16
16
|
const plainUrls = [
|
|
17
17
|
{
|
|
@@ -521,31 +521,6 @@ function fillInSpec(spec) {
|
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
describe('utils/url', function () {
|
|
524
|
-
describe('#getName', () => {
|
|
525
|
-
it('return "null" for invalid URL', () => {
|
|
526
|
-
chai.expect(getName(parse('foo'))).to.equal(null);
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
it('return "IP" if URL is ipv4', () => {
|
|
530
|
-
chai.expect(getName(parse('https://1.1.1.1/'))).to.equal('IP');
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
// Currently not handled by '@cliqz/url-parser' but will be fixed soon.
|
|
534
|
-
it.skip('return "IP" if URL is ipv6', () => {
|
|
535
|
-
chai.expect(getName(parse('https://[::1]/'))).to.equal('IP');
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
it('handle localhost', () => {
|
|
539
|
-
chai
|
|
540
|
-
.expect(getName(parse('http://localhost/path')))
|
|
541
|
-
.to.equal('localhost');
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
it('return domain without suffix', () => {
|
|
545
|
-
chai.expect(getName(parse('https://sub.foo.co.uk'))).to.equal('foo');
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
|
|
549
524
|
describe('#parse', () => {
|
|
550
525
|
function testSpecArray(name, spec) {
|
|
551
526
|
describe(name, function () {
|
|
@@ -1,42 +0,0 @@
|
|
|
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 { truncatedHash } from '../md5.js';
|
|
13
|
-
import { parse } from '../utils/url.js';
|
|
14
|
-
|
|
15
|
-
function truncatePath(path) {
|
|
16
|
-
// extract the first part of the page path
|
|
17
|
-
const [prefix] = path.substring(1).split('/');
|
|
18
|
-
return `/${prefix}`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default function buildPageLoadObject(page) {
|
|
22
|
-
const urlParts = parse(page.url);
|
|
23
|
-
const tps = { ...page.requestStats };
|
|
24
|
-
return {
|
|
25
|
-
hostname: truncatedHash(urlParts.hostname),
|
|
26
|
-
path: truncatedHash(truncatePath(urlParts.path)),
|
|
27
|
-
scheme: urlParts.scheme,
|
|
28
|
-
c: 1,
|
|
29
|
-
t: Math.round(page.destroyed - page.created),
|
|
30
|
-
active: page.activeTime,
|
|
31
|
-
counter: page.counter,
|
|
32
|
-
ra: 0,
|
|
33
|
-
tps,
|
|
34
|
-
placeHolder: false,
|
|
35
|
-
redirects: [],
|
|
36
|
-
redirectsPlaceHolder: [],
|
|
37
|
-
triggeringTree: {},
|
|
38
|
-
tsv: '',
|
|
39
|
-
tsv_id: false,
|
|
40
|
-
frames: {},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
export default class SubdomainCheck {
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.config = config;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
checkBadSubdomain(state, response) {
|
|
18
|
-
const subdomainRewriteRules = this.config.subdomainRewriteRules || {};
|
|
19
|
-
const requestHost = state.urlParts.hostname;
|
|
20
|
-
const rules = Object.keys(subdomainRewriteRules);
|
|
21
|
-
for (let i = 0; i < rules.length; i += 1) {
|
|
22
|
-
const rule = rules[i];
|
|
23
|
-
if (requestHost.endsWith(rule)) {
|
|
24
|
-
const newUrl = state.url.replace(
|
|
25
|
-
requestHost,
|
|
26
|
-
subdomainRewriteRules[rule],
|
|
27
|
-
);
|
|
28
|
-
response.redirectTo(newUrl);
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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 logger from '../../logger.js';
|
|
13
|
-
|
|
14
|
-
export default class Subject {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.listeners = new Set();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
subscribe(callback) {
|
|
20
|
-
this.listeners.add(callback);
|
|
21
|
-
return {
|
|
22
|
-
unsubscribe: () => {
|
|
23
|
-
this.listeners.delete(callback);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
pub(message) {
|
|
29
|
-
this.listeners.forEach((listener) => {
|
|
30
|
-
try {
|
|
31
|
-
listener(message);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
logger.error('Subject failed to notify listener', e);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|