@whotracksme/reporting 5.1.17
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/.editorconfig +12 -0
- package/.eslintignore +3 -0
- package/.eslintrc +16 -0
- package/.github/workflows/release.yml +34 -0
- package/.github/workflows/tests.yml +20 -0
- package/.prettierrc +9 -0
- package/.tool-versions +1 -0
- package/CHANGELOG.md +795 -0
- package/LICENSE +373 -0
- package/README.md +1 -0
- package/communication/README.md +11 -0
- package/communication/example/index.js +43 -0
- package/communication/example/manifest.json +16 -0
- package/communication/karma.conf.cjs +19 -0
- package/communication/package.json +52 -0
- package/communication/rollup.common-config.cjs +17 -0
- package/communication/rollup.config.cjs +10 -0
- package/communication/src/encoding.js +54 -0
- package/communication/src/errors.js +84 -0
- package/communication/src/index.js +76 -0
- package/communication/src/logger.js +41 -0
- package/communication/src/padding.js +60 -0
- package/communication/src/proxied-http.js +231 -0
- package/communication/src/server-public-key-accessor.js +123 -0
- package/communication/src/timestamps.js +37 -0
- package/communication/src/trusted-clock.js +58 -0
- package/communication/src/utils.js +28 -0
- package/communication/src/zlib.js +17 -0
- package/communication/test/helpers/in-memory-database.js +43 -0
- package/communication/test/server-public-key-accessor.spec.js +135 -0
- package/communication/test/utils.spec.js +43 -0
- package/package.json +50 -0
- package/reporting/TODO.md +2 -0
- package/reporting/assets/request/bloom_filter.dat +0 -0
- package/reporting/assets/request/update.json +1 -0
- package/reporting/example/content.js +11 -0
- package/reporting/example/index.js +132 -0
- package/reporting/example/inspector/index.html +17 -0
- package/reporting/example/inspector/index.js +27 -0
- package/reporting/example/manifests/chromium.json +37 -0
- package/reporting/example/manifests/firefox.json +35 -0
- package/reporting/example/rules.json +62 -0
- package/reporting/example/setup.js +1 -0
- package/reporting/example/tests/test1.html +10 -0
- package/reporting/karma.conf.cjs +22 -0
- package/reporting/package.json +63 -0
- package/reporting/rollup.common-config.cjs +19 -0
- package/reporting/rollup.config.cjs +20 -0
- package/reporting/src/LRU.js +149 -0
- package/reporting/src/activity-estimator.js +298 -0
- package/reporting/src/alive-check.js +139 -0
- package/reporting/src/alive-message-generator.js +142 -0
- package/reporting/src/bloom-filters.js +345 -0
- package/reporting/src/country-provider.js +295 -0
- package/reporting/src/cyrb53.js +32 -0
- package/reporting/src/digest.js +33 -0
- package/reporting/src/doublefetch-page-handler.js +548 -0
- package/reporting/src/duplicate-detector.js +233 -0
- package/reporting/src/errors.js +84 -0
- package/reporting/src/event-listener-queue.js +121 -0
- package/reporting/src/fixed-size-cache.js +63 -0
- package/reporting/src/hash-detector.js +1526 -0
- package/reporting/src/html-parser.js +17 -0
- package/reporting/src/http.js +265 -0
- package/reporting/src/index.js +14 -0
- package/reporting/src/job-scheduler.js +912 -0
- package/reporting/src/logger.js +121 -0
- package/reporting/src/md5.js +334 -0
- package/reporting/src/message-sender.js +51 -0
- package/reporting/src/network.js +140 -0
- package/reporting/src/new-page-approver.js +119 -0
- package/reporting/src/page-aggregator.js +185 -0
- package/reporting/src/page-quorum-check-handler.js +200 -0
- package/reporting/src/page-structure.js +136 -0
- package/reporting/src/pagedb.js +671 -0
- package/reporting/src/pages.js +1798 -0
- package/reporting/src/patterns-updater.js +310 -0
- package/reporting/src/patterns.js +416 -0
- package/reporting/src/persisted-bitarray.js +265 -0
- package/reporting/src/persisted-hashes.js +189 -0
- package/reporting/src/quorum-checker.js +327 -0
- package/reporting/src/random.js +39 -0
- package/reporting/src/reporting.js +290 -0
- package/reporting/src/request/config.js +116 -0
- package/reporting/src/request/content-script.js +77 -0
- package/reporting/src/request/database.js +147 -0
- package/reporting/src/request/dnt.js +24 -0
- package/reporting/src/request/hash.js +101 -0
- package/reporting/src/request/index.js +874 -0
- package/reporting/src/request/page-telemetry.js +42 -0
- package/reporting/src/request/qs-whitelist2.js +247 -0
- package/reporting/src/request/resources/prob.js +601 -0
- package/reporting/src/request/steps/block-rules.js +40 -0
- package/reporting/src/request/steps/check-context.js +37 -0
- package/reporting/src/request/steps/cookie-context.js +209 -0
- package/reporting/src/request/steps/oauth-detector.js +101 -0
- package/reporting/src/request/steps/page-logger.js +177 -0
- package/reporting/src/request/steps/redirect-tagger.js +75 -0
- package/reporting/src/request/steps/subdomain-check.js +34 -0
- package/reporting/src/request/steps/token-checker/index.js +189 -0
- package/reporting/src/request/steps/token-checker/token-domain.js +129 -0
- package/reporting/src/request/steps/token-examiner.js +182 -0
- package/reporting/src/request/steps/token-telemetry/cached-entry-pipeline.js +210 -0
- package/reporting/src/request/steps/token-telemetry/index.js +234 -0
- package/reporting/src/request/steps/token-telemetry/key-pipeline.js +109 -0
- package/reporting/src/request/steps/token-telemetry/token-pipeline.js +105 -0
- package/reporting/src/request/time.js +73 -0
- package/reporting/src/request/utils/bloom-filter-packed.js +107 -0
- package/reporting/src/request/utils/chrome-storage-map.js +282 -0
- package/reporting/src/request/utils/subject.js +37 -0
- package/reporting/src/request/utils/temp-set.js +56 -0
- package/reporting/src/request/utils/tlds.js +55 -0
- package/reporting/src/request/utils.js +41 -0
- package/reporting/src/request-reporter.js +111 -0
- package/reporting/src/sanitizer.js +519 -0
- package/reporting/src/search-extractor.js +338 -0
- package/reporting/src/self-check.js +105 -0
- package/reporting/src/seq-executor.js +43 -0
- package/reporting/src/session-storage.js +399 -0
- package/reporting/src/url-analyzer.js +161 -0
- package/reporting/src/url-cleaner.js +60 -0
- package/reporting/src/utils/pacemaker.js +279 -0
- package/reporting/src/utils/url.js +114 -0
- package/reporting/src/utils.js +345 -0
- package/reporting/src/webrequest-pipeline/cname-uncloak.js +110 -0
- package/reporting/src/webrequest-pipeline/index.js +287 -0
- package/reporting/src/webrequest-pipeline/logger.js +14 -0
- package/reporting/src/webrequest-pipeline/page-store.js +282 -0
- package/reporting/src/webrequest-pipeline/page.js +140 -0
- package/reporting/src/webrequest-pipeline/pipeline.js +249 -0
- package/reporting/src/webrequest-pipeline/utils/webrequest.js +113 -0
- package/reporting/src/webrequest-pipeline/webrequest-context.js +153 -0
- package/reporting/test/README.md +2 -0
- package/reporting/test/activity-estimator.spec.js +356 -0
- package/reporting/test/alive-check.spec.js +156 -0
- package/reporting/test/alive-message-generator.spec.js +186 -0
- package/reporting/test/country-provider.spec.js +263 -0
- package/reporting/test/doublefetch-page-handler.spec.js +818 -0
- package/reporting/test/duplicate-detector.spec.js +689 -0
- package/reporting/test/helpers/dom-parsers.js +41 -0
- package/reporting/test/helpers/fake-session-storage.js +69 -0
- package/reporting/test/helpers/fast-check-utils.js +28 -0
- package/reporting/test/helpers/fetch-mock.js +57 -0
- package/reporting/test/helpers/in-memory-database.js +14 -0
- package/reporting/test/helpers/memory-map.js +72 -0
- package/reporting/test/helpers/pagedb-mocks.js +41 -0
- package/reporting/test/index.js +47 -0
- package/reporting/test/job-scheduler.spec.js +691 -0
- package/reporting/test/network.spec.js +72 -0
- package/reporting/test/page-aggregator.spec.js +104 -0
- package/reporting/test/page-quorum-check-handler.spec.js +86 -0
- package/reporting/test/pagedb.spec.js +250 -0
- package/reporting/test/pages.spec.js +693 -0
- package/reporting/test/patterns-updater.spec.js +446 -0
- package/reporting/test/patterns.spec.js +751 -0
- package/reporting/test/persisted-hashes.spec.js +169 -0
- package/reporting/test/reporting.spec.js +205 -0
- package/reporting/test/request/database.spec.js +59 -0
- package/reporting/test/request/hash.spec.js +108 -0
- package/reporting/test/request/index.spec.js +378 -0
- package/reporting/test/request/qs-whitelist2.spec.js +189 -0
- package/reporting/test/request/steps/check-context.spec.js +51 -0
- package/reporting/test/request/steps/oauth-detector.spec.js +339 -0
- package/reporting/test/request/test-pages.js +1246 -0
- package/reporting/test/request/utils/bloom-filter-packed.spec.js +37 -0
- package/reporting/test/request/utils/chrome-storage-map.spec.js +28 -0
- package/reporting/test/request/utils/tldts.spec.js +62 -0
- package/reporting/test/request/utils.spec.js +168 -0
- package/reporting/test/sanitizer.spec.js +1087 -0
- package/reporting/test/search-extractor.spec.js +590 -0
- package/reporting/test/seq-executor.spec.js +158 -0
- package/reporting/test/session-storage.spec.js +400 -0
- package/reporting/test/setup.js +24 -0
- package/reporting/test/url-analyzer.spec.js +451 -0
- package/reporting/test/url-cleaner.spec.js +102 -0
- package/reporting/test/utils/pacemaker.spec.js +222 -0
- package/reporting/test/utils/url.spec.js +660 -0
- package/reporting/test/utils.spec.js +299 -0
- package/reporting/test/webrequest-pipeline/pipeline.spec.js +251 -0
|
@@ -0,0 +1,37 @@
|
|
|
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 * as chai from 'chai';
|
|
13
|
+
|
|
14
|
+
import BloomFilter from '../../../src/request/utils/bloom-filter-packed';
|
|
15
|
+
|
|
16
|
+
describe('core/bloom-filter-packed', function () {
|
|
17
|
+
describe('BloomFilterPacked', function () {
|
|
18
|
+
it('should pass simple testSingle tests', function () {
|
|
19
|
+
const buffer = new ArrayBuffer(5 + 101 * 4);
|
|
20
|
+
const view = new DataView(buffer);
|
|
21
|
+
view.setUint32(0, 101, false);
|
|
22
|
+
view.setUint8(4, 7, false);
|
|
23
|
+
const uut = new BloomFilter(view.buffer);
|
|
24
|
+
|
|
25
|
+
chai.expect(uut.testSingle('x')).to.be.false;
|
|
26
|
+
chai.expect(uut.testSingle('y')).to.be.false;
|
|
27
|
+
|
|
28
|
+
uut.addSingle('x');
|
|
29
|
+
chai.expect(uut.testSingle('x')).to.be.true;
|
|
30
|
+
chai.expect(uut.testSingle('y')).to.be.false;
|
|
31
|
+
|
|
32
|
+
uut.addSingle('y');
|
|
33
|
+
chai.expect(uut.testSingle('x')).to.be.true;
|
|
34
|
+
chai.expect(uut.testSingle('y')).to.be.true;
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
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 * as chai from 'chai';
|
|
13
|
+
import FakeSessionApi from '../../helpers/fake-session-storage.js';
|
|
14
|
+
|
|
15
|
+
import ChromeStorageMap from '../../../src/request/utils/chrome-storage-map';
|
|
16
|
+
|
|
17
|
+
describe('utils/chrome-storage-map', function () {
|
|
18
|
+
it('set / get', function () {
|
|
19
|
+
const map = new ChromeStorageMap({
|
|
20
|
+
sessionApi: new FakeSessionApi(),
|
|
21
|
+
storageKey: 'test',
|
|
22
|
+
});
|
|
23
|
+
const key = 1;
|
|
24
|
+
const value = 2;
|
|
25
|
+
map.set(key, value);
|
|
26
|
+
chai.expect(map.get(key)).to.equal(value);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
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 * as chai from 'chai';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
sameGeneralDomain,
|
|
16
|
+
getGeneralDomain,
|
|
17
|
+
} from '../../../src/request/utils/tlds';
|
|
18
|
+
|
|
19
|
+
describe('core/tlds', function () {
|
|
20
|
+
describe('#sameGeneralDomain', () => {
|
|
21
|
+
[
|
|
22
|
+
['a.cliqz.com', 'b.cliqz.com'],
|
|
23
|
+
['x.y.cliqz.com', 'cliqz.com'],
|
|
24
|
+
['domain.with.co.uk', 'other.subdomain.with.co.uk'],
|
|
25
|
+
].forEach((pair) => {
|
|
26
|
+
const [a, b] = pair;
|
|
27
|
+
it(`'${a}' is same general domain as '${b}'`, () => {
|
|
28
|
+
chai.expect(sameGeneralDomain(a, b)).to.be.true;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
[
|
|
33
|
+
['', 'example.com'],
|
|
34
|
+
[undefined, 'example.com'],
|
|
35
|
+
['localhost', '127.0.0.1'],
|
|
36
|
+
['a.cliqz.com', 'b.kliqz.com'],
|
|
37
|
+
['same.registered.co.uk', 'other.registered.com'],
|
|
38
|
+
].forEach((pair) => {
|
|
39
|
+
const [a, b] = pair;
|
|
40
|
+
it(`'${a}' is not same general domain as '${b}'`, () => {
|
|
41
|
+
chai.expect(sameGeneralDomain(a, b)).to.be.false;
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('#getGeneralDomain', () => {
|
|
47
|
+
const spec = {
|
|
48
|
+
'cliqz.com': ['cliqz.com', 'www.cliqz.com', 'a.b.cliqz.com'],
|
|
49
|
+
'example.co.uk': ['example.co.uk', 'test.example.co.uk'],
|
|
50
|
+
'127.0.0.1': ['127.0.0.1'],
|
|
51
|
+
'1.2.3.4': ['1.2.3.4'],
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
Object.keys(spec).forEach((generalDomain) => {
|
|
55
|
+
spec[generalDomain].forEach((subDomain) => {
|
|
56
|
+
it(`${subDomain} has general domain ${generalDomain}`, () => {
|
|
57
|
+
chai.expect(getGeneralDomain(subDomain)).to.equal(generalDomain);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
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 * as chai from 'chai';
|
|
13
|
+
|
|
14
|
+
import { truncateDomain } from '../../src/request/utils';
|
|
15
|
+
|
|
16
|
+
describe('request/utils', function () {
|
|
17
|
+
describe('truncateDomain', function () {
|
|
18
|
+
it('does not change domain which is already tld+1', () => {
|
|
19
|
+
chai
|
|
20
|
+
.expect(
|
|
21
|
+
truncateDomain(
|
|
22
|
+
{
|
|
23
|
+
hostname: 'cliqz.com',
|
|
24
|
+
subdomain: '',
|
|
25
|
+
domain: 'cliqz.com',
|
|
26
|
+
},
|
|
27
|
+
1,
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
.to.equal('cliqz.com');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('shortens subdomain to tld+N (n=1, n < subdomains)', () => {
|
|
34
|
+
chai
|
|
35
|
+
.expect(
|
|
36
|
+
truncateDomain(
|
|
37
|
+
{
|
|
38
|
+
hostname: 'a.b.cliqz.com',
|
|
39
|
+
subdomain: 'a.b',
|
|
40
|
+
domain: 'cliqz.com',
|
|
41
|
+
},
|
|
42
|
+
1,
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
.to.equal('b.cliqz.com');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('shortens subdomain to tld+N (n=1, n == subdomains)', () => {
|
|
49
|
+
chai
|
|
50
|
+
.expect(
|
|
51
|
+
truncateDomain(
|
|
52
|
+
{
|
|
53
|
+
hostname: 'aa.cliqz.com',
|
|
54
|
+
subdomain: 'aa',
|
|
55
|
+
domain: 'cliqz.com',
|
|
56
|
+
},
|
|
57
|
+
1,
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
.to.equal('aa.cliqz.com');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('shortens subdomain to tld+N (n=2, n > subdomains)', () => {
|
|
64
|
+
chai
|
|
65
|
+
.expect(
|
|
66
|
+
truncateDomain(
|
|
67
|
+
{
|
|
68
|
+
hostname: 'aa.cliqz.com',
|
|
69
|
+
subdomain: 'aa',
|
|
70
|
+
domain: 'cliqz.com',
|
|
71
|
+
},
|
|
72
|
+
2,
|
|
73
|
+
),
|
|
74
|
+
)
|
|
75
|
+
.to.equal('aa.cliqz.com');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('shortens subdomain to tld+N (n=3, n < subdomains)', () => {
|
|
79
|
+
chai
|
|
80
|
+
.expect(
|
|
81
|
+
truncateDomain(
|
|
82
|
+
{
|
|
83
|
+
hostname: 'a.b.c.d.e.cliqz.com',
|
|
84
|
+
subdomain: 'a.b.c.d.e',
|
|
85
|
+
domain: 'cliqz.com',
|
|
86
|
+
},
|
|
87
|
+
3,
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
.to.equal('c.d.e.cliqz.com');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('shortens subdomain to tld+N (n=2, n > subdomains)', () => {
|
|
94
|
+
chai
|
|
95
|
+
.expect(
|
|
96
|
+
truncateDomain(
|
|
97
|
+
{
|
|
98
|
+
hostname: 'd.e.cliqz.com',
|
|
99
|
+
subdomain: 'd.e',
|
|
100
|
+
domain: 'cliqz.com',
|
|
101
|
+
},
|
|
102
|
+
3,
|
|
103
|
+
),
|
|
104
|
+
)
|
|
105
|
+
.to.equal('d.e.cliqz.com');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('leading . on domain', () => {
|
|
109
|
+
chai
|
|
110
|
+
.expect(
|
|
111
|
+
truncateDomain(
|
|
112
|
+
{
|
|
113
|
+
hostname: '.d.e.cliqz.com',
|
|
114
|
+
subdomain: '.d.e',
|
|
115
|
+
domain: 'cliqz.com',
|
|
116
|
+
},
|
|
117
|
+
1,
|
|
118
|
+
),
|
|
119
|
+
)
|
|
120
|
+
.to.equal('e.cliqz.com');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('removes double .', () => {
|
|
124
|
+
chai
|
|
125
|
+
.expect(
|
|
126
|
+
truncateDomain(
|
|
127
|
+
{
|
|
128
|
+
hostname: 'a..b..cliqz.com',
|
|
129
|
+
subdomain: 'a..b.',
|
|
130
|
+
domain: 'cliqz.com',
|
|
131
|
+
},
|
|
132
|
+
1,
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
.to.equal('b.cliqz.com');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('no general domain', () => {
|
|
139
|
+
chai
|
|
140
|
+
.expect(
|
|
141
|
+
truncateDomain(
|
|
142
|
+
{
|
|
143
|
+
hostname: 'd.e.cliqz.com',
|
|
144
|
+
subdomain: 'd.e.cliqz.com',
|
|
145
|
+
domain: '',
|
|
146
|
+
},
|
|
147
|
+
1,
|
|
148
|
+
),
|
|
149
|
+
)
|
|
150
|
+
.to.equal('d.e.cliqz.com');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('ip address', () => {
|
|
154
|
+
chai
|
|
155
|
+
.expect(
|
|
156
|
+
truncateDomain(
|
|
157
|
+
{
|
|
158
|
+
hostname: '8.8.4.4',
|
|
159
|
+
isIp: true,
|
|
160
|
+
domain: '',
|
|
161
|
+
},
|
|
162
|
+
1,
|
|
163
|
+
),
|
|
164
|
+
)
|
|
165
|
+
.to.equal('8.8.4.4');
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|