@whotracksme/reporting 5.1.28 → 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 +37 -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/events.log.br +0 -0
- package/reporting/snapshots/0001/snapshot.json +4173 -0
- package/reporting/snapshots/0002/events.log.br +0 -0
- package/reporting/snapshots/0002/snapshot.json +2539 -0
- 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 +447 -496
- 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 +55 -75
- package/reporting/src/request/steps/token-telemetry/index.js +86 -115
- 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 +76 -17
- package/reporting/test/index.js +3 -8
- package/reporting/test/request/database.test.js +96 -0
- package/reporting/test/request/{hash.spec.js → hash/index.spec.js} +2 -2
- package/reporting/test/request/index.spec.js +24 -46
- package/reporting/test/{request-reporter.test.js → request/index.test.js} +102 -46
- 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/setup.unit.js +1 -0
- 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
|
@@ -1,251 +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
|
-
/* eslint no-param-reassign: off */
|
|
13
|
-
|
|
14
|
-
import * as chai from 'chai';
|
|
15
|
-
import chrome from 'sinon-chrome';
|
|
16
|
-
|
|
17
|
-
import Pipeline from '../../src/webrequest-pipeline/pipeline';
|
|
18
|
-
|
|
19
|
-
describe('webrequest-pipeline/pipeline', function () {
|
|
20
|
-
let oldWindowChrome;
|
|
21
|
-
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
oldWindowChrome = window.chrome;
|
|
24
|
-
window.chrome = chrome;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
window.chrome = oldWindowChrome;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('constructor', () => {
|
|
32
|
-
it('creates an empty pipeline', () => {
|
|
33
|
-
const p = new Pipeline('name');
|
|
34
|
-
chai.expect(p.pipeline).to.have.length(0);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('#addPipelineStep', () => {
|
|
39
|
-
let p;
|
|
40
|
-
|
|
41
|
-
beforeEach(function () {
|
|
42
|
-
p = new Pipeline('name');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('adds a step to the pipeline', () => {
|
|
46
|
-
const step = { name: 'test', spec: 'blocking', fn: () => true };
|
|
47
|
-
p.addPipelineStep(step);
|
|
48
|
-
chai.expect(p.pipeline).to.eql([step]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('adds to stage to the end of the pipeline', () => {
|
|
52
|
-
const step1 = { name: 'part1', spec: 'blocking', fn: () => true };
|
|
53
|
-
const step2 = { name: 'part2', spec: 'blocking', fn: () => true };
|
|
54
|
-
p.addAll([step1, step2]);
|
|
55
|
-
chai.expect(p.pipeline).to.eql([step1, step2]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('throws an Error if function with the same name as already been added', () => {
|
|
59
|
-
p.addPipelineStep({ name: 'part1', spec: 'blocking', fn: () => true });
|
|
60
|
-
chai
|
|
61
|
-
.expect(
|
|
62
|
-
p.addPipelineStep.bind(p, {
|
|
63
|
-
name: 'part1',
|
|
64
|
-
spec: 'blocking',
|
|
65
|
-
fn: () => false,
|
|
66
|
-
}),
|
|
67
|
-
)
|
|
68
|
-
.to.throw(Error);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
context('before option', () => {
|
|
72
|
-
it('inserts the step before the named steps', () => {
|
|
73
|
-
const step1 = { name: 'part1', spec: 'blocking', fn: () => true };
|
|
74
|
-
const step2 = {
|
|
75
|
-
name: 'part2',
|
|
76
|
-
spec: 'blocking',
|
|
77
|
-
fn: () => true,
|
|
78
|
-
before: ['part3'],
|
|
79
|
-
};
|
|
80
|
-
const step3 = { name: 'part3', spec: 'blocking', fn: () => true };
|
|
81
|
-
p.addAll([step1, step3, step2]);
|
|
82
|
-
chai.expect(p.pipeline).to.eql([step1, step2, step3]);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('does not an Error if before dependencies do not exist', () => {
|
|
86
|
-
const step1 = { name: 'part1', spec: 'blocking', fn: () => true };
|
|
87
|
-
const step2 = {
|
|
88
|
-
name: 'part2',
|
|
89
|
-
spec: 'blocking',
|
|
90
|
-
fn: () => true,
|
|
91
|
-
before: ['part3'],
|
|
92
|
-
};
|
|
93
|
-
p.addAll([step1, step2]);
|
|
94
|
-
chai.expect(p.pipeline).to.eql([step1, step2]);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
context('after option', () => {
|
|
99
|
-
it('inserts the step after the named steps', () => {
|
|
100
|
-
const step1 = { name: 'part1', spec: 'blocking', fn: () => true };
|
|
101
|
-
const step2 = {
|
|
102
|
-
name: 'part2',
|
|
103
|
-
spec: 'blocking',
|
|
104
|
-
fn: () => true,
|
|
105
|
-
after: ['part1'],
|
|
106
|
-
};
|
|
107
|
-
const step3 = { name: 'part3', spec: 'blocking', fn: () => true };
|
|
108
|
-
const step4 = { name: 'part4', spec: 'blocking', fn: () => true };
|
|
109
|
-
p.addAll([step1, step3, step4, step2]);
|
|
110
|
-
|
|
111
|
-
chai.expect(p.pipeline).to.eql([step1, step2, step3, step4]);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('inserts the step in last position', () => {
|
|
115
|
-
const step1 = { name: 'part1', spec: 'blocking', fn: () => true };
|
|
116
|
-
const step2 = { name: 'part2', spec: 'blocking', fn: () => true };
|
|
117
|
-
const step3 = {
|
|
118
|
-
name: 'part3',
|
|
119
|
-
spec: 'blocking',
|
|
120
|
-
fn: () => true,
|
|
121
|
-
after: ['part2'],
|
|
122
|
-
};
|
|
123
|
-
p.addAll([step1, step2, step3]);
|
|
124
|
-
|
|
125
|
-
chai.expect(p.pipeline).to.eql([step1, step2, step3]);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('throws an Error if after dependencies do not exist', () => {
|
|
129
|
-
p.addPipelineStep({ name: 'part1', spec: 'blocking', fn: () => true });
|
|
130
|
-
chai
|
|
131
|
-
.expect(
|
|
132
|
-
p.addPipelineStep.bind(p, {
|
|
133
|
-
name: 'part2',
|
|
134
|
-
spec: 'blocking',
|
|
135
|
-
fn: () => true,
|
|
136
|
-
after: ['part3'],
|
|
137
|
-
}),
|
|
138
|
-
)
|
|
139
|
-
.to.throw(Error);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
context('before and after options', () => {
|
|
144
|
-
it('throws an Error if both are specified', () => {
|
|
145
|
-
p.addPipelineStep({ name: 'part1', spec: 'blocking', fn: () => true });
|
|
146
|
-
p.addPipelineStep({ name: 'part3', spec: 'blocking', fn: () => true });
|
|
147
|
-
|
|
148
|
-
chai
|
|
149
|
-
.expect(
|
|
150
|
-
p.addPipelineStep.bind(p, {
|
|
151
|
-
name: 'part2',
|
|
152
|
-
spec: 'blocking',
|
|
153
|
-
fn: () => true,
|
|
154
|
-
after: ['part1'],
|
|
155
|
-
before: ['part3'],
|
|
156
|
-
}),
|
|
157
|
-
)
|
|
158
|
-
.to.throw(Error);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('#execute', () => {
|
|
164
|
-
let p;
|
|
165
|
-
|
|
166
|
-
const expectedKeys = new Set(['redirectTo', 'block', 'modifyHeader']);
|
|
167
|
-
|
|
168
|
-
function expectEmptyResponse(resp) {
|
|
169
|
-
const keys = Object.keys(resp).filter((k) => !expectedKeys.has(k));
|
|
170
|
-
chai.expect(keys).to.eql([]);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
beforeEach(function () {
|
|
174
|
-
p = new Pipeline('name');
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('returns object for empty pipeline', () => {
|
|
178
|
-
const response = {};
|
|
179
|
-
p.execute({}, response);
|
|
180
|
-
chai.expect(response).to.not.be.null;
|
|
181
|
-
expectEmptyResponse(response);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('calls functions in pipeline one with mutible state argument', () => {
|
|
185
|
-
let fn1Called = 0;
|
|
186
|
-
let fn2Called = 0;
|
|
187
|
-
|
|
188
|
-
function fn1(state) {
|
|
189
|
-
state.fn1 = true;
|
|
190
|
-
fn1Called += 1;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function fn2(state) {
|
|
194
|
-
chai.expect(state.fn1).to.be.true;
|
|
195
|
-
fn2Called += 1;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
p.addPipelineStep({ fn: fn1, name: 'fn1', spec: 'blocking' });
|
|
199
|
-
p.addPipelineStep({ fn: fn2, name: 'fn2', spec: 'blocking' });
|
|
200
|
-
|
|
201
|
-
const response = {};
|
|
202
|
-
p.execute({}, response);
|
|
203
|
-
chai.expect(fn1Called).to.eql(1);
|
|
204
|
-
chai.expect(fn2Called).to.eql(1);
|
|
205
|
-
expectEmptyResponse(response);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('stops when a function returns false', () => {
|
|
209
|
-
let fn1Called = 0;
|
|
210
|
-
let fn2Called = 0;
|
|
211
|
-
|
|
212
|
-
function fn1() {
|
|
213
|
-
fn1Called += 1;
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function fn2() {
|
|
218
|
-
fn2Called += 1;
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
p.addPipelineStep({ fn: fn1, name: 'fn1', spec: 'blocking' });
|
|
222
|
-
p.addPipelineStep({ fn: fn2, name: 'fn2', spec: 'blocking' });
|
|
223
|
-
|
|
224
|
-
const response = {};
|
|
225
|
-
p.execute({}, response);
|
|
226
|
-
chai.expect(fn1Called).to.eql(1);
|
|
227
|
-
chai.expect(fn2Called).to.eql(0);
|
|
228
|
-
expectEmptyResponse(response);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it('returns the final value of the result', () => {
|
|
232
|
-
function fn1(state, res) {
|
|
233
|
-
res.fn1 = 4;
|
|
234
|
-
return true;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function fn2(state, res) {
|
|
238
|
-
res.fn1 += 1;
|
|
239
|
-
res.fn2 = -4;
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
p.addPipelineStep({ fn: fn1, name: 'fn1', spec: 'blocking' });
|
|
243
|
-
p.addPipelineStep({ fn: fn2, name: 'fn2', spec: 'blocking' });
|
|
244
|
-
|
|
245
|
-
const response = {};
|
|
246
|
-
p.execute({}, response);
|
|
247
|
-
chai.expect(response.fn1).to.eql(5);
|
|
248
|
-
chai.expect(response.fn2).to.eql(-4);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
});
|
|
File without changes
|