@whotracksme/reporting 12.1.7 → 12.1.9
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 +24 -0
- package/package.json +1 -1
- package/reporting/src/bloom-filters.js +6 -3
- package/reporting/src/new-page-approver.js +1 -1
- package/reporting/test/bloom-filters.spec.js +118 -0
- package/reporting/test/index.js +3 -0
- package/reporting/test/new-page-approver.spec.js +66 -0
- package/reporting/test/quorum-checker.spec.js +85 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# v12.1.9 (Wed Nov 18 2026)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- fix: a page that was marked as private is accepted again (wrong key in the lookup) [#251](https://github.com/whotracksme/webextension-packages/pull/251) ([@philipp-classen](https://github.com/philipp-classen))
|
|
6
|
+
|
|
7
|
+
#### Authors: 1
|
|
8
|
+
|
|
9
|
+
- Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# v12.1.8 (Wed Nov 18 2026)
|
|
14
|
+
|
|
15
|
+
#### 🐛 Bug Fix
|
|
16
|
+
|
|
17
|
+
- fix: bloom filter always returns false [#250](https://github.com/whotracksme/webextension-packages/pull/250) ([@philipp-classen](https://github.com/philipp-classen))
|
|
18
|
+
|
|
19
|
+
#### Authors: 1
|
|
20
|
+
|
|
21
|
+
- Philipp Claßen ([@philipp-classen](https://github.com/philipp-classen))
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
1
25
|
# v12.1.7 (Fri Oct 23 2026)
|
|
2
26
|
|
|
3
27
|
#### 🐛 Bug Fix
|
package/package.json
CHANGED
|
@@ -309,9 +309,12 @@ export class BloomFilter {
|
|
|
309
309
|
for (let i = this.generations.length - 1; i >= 0; i -= 1) {
|
|
310
310
|
const generation = this.generations[i];
|
|
311
311
|
const found = await generation.testMany(bitsToTest);
|
|
312
|
-
if (found
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
if (found) {
|
|
313
|
+
if (updateTTLIfFound && i !== this.generations.length - 1) {
|
|
314
|
+
const latestGeneration =
|
|
315
|
+
this.generations[this.generations.length - 1];
|
|
316
|
+
await latestGeneration.setMany(bitsToTest);
|
|
317
|
+
}
|
|
315
318
|
return true;
|
|
316
319
|
}
|
|
317
320
|
}
|
|
@@ -56,7 +56,7 @@ export default class NewPageApprover {
|
|
|
56
56
|
if (await this.persistedHashes.has(hash)) {
|
|
57
57
|
return reject('end of cooldown not reached yet');
|
|
58
58
|
}
|
|
59
|
-
if (await this.
|
|
59
|
+
if (await this.mightBeMarkedAsPrivate(url)) {
|
|
60
60
|
return reject('page has been (possibly) marked as private before');
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -0,0 +1,118 @@
|
|
|
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 { expect } from 'chai';
|
|
13
|
+
|
|
14
|
+
import { BloomFilter } from '../src/bloom-filters.js';
|
|
15
|
+
import InMemoryDatabase from './helpers/in-memory-database.js';
|
|
16
|
+
|
|
17
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
18
|
+
|
|
19
|
+
describe('#BloomFilter', function () {
|
|
20
|
+
let database;
|
|
21
|
+
|
|
22
|
+
function newBloomFilter(options = {}) {
|
|
23
|
+
return new BloomFilter({
|
|
24
|
+
database,
|
|
25
|
+
name: 'test',
|
|
26
|
+
partitions: [1009, 1013, 1019],
|
|
27
|
+
...options,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// simulates a restart of the extension at the given time
|
|
32
|
+
async function restartBloomFilter(oldBloomFilter, { now, ...options }) {
|
|
33
|
+
await Promise.all(oldBloomFilter.generations.map((gen) => gen.flush()));
|
|
34
|
+
const uut = newBloomFilter(options);
|
|
35
|
+
await uut.ready(now);
|
|
36
|
+
return uut;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
beforeEach(function () {
|
|
40
|
+
database = new InMemoryDatabase();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('#mightContain', function () {
|
|
44
|
+
it('should not find a value in an empty filter', async function () {
|
|
45
|
+
const uut = newBloomFilter();
|
|
46
|
+
expect(await uut.mightContain('foo')).to.eql(false);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should find a value that was added', async function () {
|
|
50
|
+
const uut = newBloomFilter();
|
|
51
|
+
await uut.add('foo');
|
|
52
|
+
|
|
53
|
+
expect(await uut.mightContain('foo')).to.eql(true);
|
|
54
|
+
expect(await uut.mightContain('bar')).to.eql(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should find a value that was added if there is only one generation', async function () {
|
|
58
|
+
const uut = newBloomFilter({
|
|
59
|
+
maxGenerations: 1,
|
|
60
|
+
rotationIntervalInMs: 0,
|
|
61
|
+
});
|
|
62
|
+
await uut.add('foo');
|
|
63
|
+
|
|
64
|
+
expect(await uut.mightContain('foo')).to.eql(true);
|
|
65
|
+
expect(await uut.mightContain('bar')).to.eql(false);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should find a value after a restart', async function () {
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
let uut = newBloomFilter();
|
|
71
|
+
await uut.ready(now);
|
|
72
|
+
await uut.add('foo');
|
|
73
|
+
|
|
74
|
+
uut = await restartBloomFilter(uut, { now: now + DAY });
|
|
75
|
+
expect(uut.generations).to.have.lengthOf(1);
|
|
76
|
+
expect(await uut.mightContain('foo')).to.eql(true);
|
|
77
|
+
expect(await uut.mightContain('bar')).to.eql(false);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('with a value in an older generation', function () {
|
|
81
|
+
const rotationIntervalInMs = 30 * DAY;
|
|
82
|
+
let uut;
|
|
83
|
+
|
|
84
|
+
beforeEach(async function () {
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
uut = newBloomFilter({ rotationIntervalInMs });
|
|
87
|
+
await uut.ready(now);
|
|
88
|
+
await uut.add('foo');
|
|
89
|
+
|
|
90
|
+
uut = await restartBloomFilter(uut, {
|
|
91
|
+
now: now + rotationIntervalInMs + DAY,
|
|
92
|
+
rotationIntervalInMs,
|
|
93
|
+
});
|
|
94
|
+
expect(uut.generations).to.have.lengthOf(2);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should find the value', async function () {
|
|
98
|
+
expect(await uut.mightContain('foo')).to.eql(true);
|
|
99
|
+
expect(await uut.mightContain('bar')).to.eql(false);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should not copy the value to the latest generation by default', async function () {
|
|
103
|
+
expect(await uut.mightContain('foo')).to.eql(true);
|
|
104
|
+
|
|
105
|
+
const bits = uut._computeBits('foo');
|
|
106
|
+
expect(await uut.generations[1].testMany(bits)).to.eql(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should copy the value to the latest generation with "updateTTLIfFound"', async function () {
|
|
110
|
+
const found = await uut.mightContain('foo', { updateTTLIfFound: true });
|
|
111
|
+
expect(found).to.eql(true);
|
|
112
|
+
|
|
113
|
+
const bits = uut._computeBits('foo');
|
|
114
|
+
expect(await uut.generations[1].testMany(bits)).to.eql(true);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
package/reporting/test/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import './http.spec.js';
|
|
|
8
8
|
import './patterns.spec.js';
|
|
9
9
|
import './patterns-updater.spec.js';
|
|
10
10
|
import './job-scheduler.spec.js';
|
|
11
|
+
import './bloom-filters.spec.js';
|
|
11
12
|
import './country-provider.spec.js';
|
|
12
13
|
import './persisted-hashes.spec.js';
|
|
13
14
|
import './doublefetch-unbreak.spec.js';
|
|
@@ -15,6 +16,7 @@ import './url-analyzer.spec.js';
|
|
|
15
16
|
import './alive-check.spec.js';
|
|
16
17
|
import './alive-message-generator.spec.js';
|
|
17
18
|
import './nav-tracking-detector.spec.js';
|
|
19
|
+
import './new-page-approver.spec.js';
|
|
18
20
|
import './network.spec.js';
|
|
19
21
|
import './observable.spec.js';
|
|
20
22
|
import './pagedb.spec.js';
|
|
@@ -24,6 +26,7 @@ import './persisted-counters.spec.js';
|
|
|
24
26
|
import './popularity-estimator.spec.js';
|
|
25
27
|
import './popularity-vote-handler.spec.js';
|
|
26
28
|
import './popularity-vote-sanitizer.spec.js';
|
|
29
|
+
import './quorum-checker.spec.js';
|
|
27
30
|
import './random.spec.js';
|
|
28
31
|
import './sanitizer.spec.js';
|
|
29
32
|
import './search-extractor.spec.js';
|
|
@@ -0,0 +1,66 @@
|
|
|
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 { expect } from 'chai';
|
|
13
|
+
|
|
14
|
+
import { BloomFilter } from '../src/bloom-filters.js';
|
|
15
|
+
import NewPageApprover from '../src/new-page-approver.js';
|
|
16
|
+
import InMemoryDatabase from './helpers/in-memory-database.js';
|
|
17
|
+
import { createInMemoryPersistedHashes } from './helpers/in-memory-persisted-hashes.js';
|
|
18
|
+
|
|
19
|
+
describe('#NewPageApprover', function () {
|
|
20
|
+
const url = 'https://example.test/foo';
|
|
21
|
+
let uut;
|
|
22
|
+
|
|
23
|
+
beforeEach(function () {
|
|
24
|
+
const privatePageBloomFilter = new BloomFilter({
|
|
25
|
+
database: new InMemoryDatabase(),
|
|
26
|
+
name: 'test',
|
|
27
|
+
partitions: [1009, 1013, 1019],
|
|
28
|
+
});
|
|
29
|
+
uut = new NewPageApprover(
|
|
30
|
+
createInMemoryPersistedHashes(),
|
|
31
|
+
privatePageBloomFilter,
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('#allowCreation', function () {
|
|
36
|
+
it('should accept a new page', async function () {
|
|
37
|
+
expect(await uut.allowCreation(url)).to.eql({ ok: true });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should reject a page until the end of its cooldown', async function () {
|
|
41
|
+
expect(await uut.allowCreation(url)).to.eql({ ok: true });
|
|
42
|
+
expect((await uut.allowCreation(url)).ok).to.eql(false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should reject a page that was marked as private', async function () {
|
|
46
|
+
await uut.markAsPrivate(url);
|
|
47
|
+
expect((await uut.allowCreation(url)).ok).to.eql(false);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should not start the cooldown for a page that was marked as private', async function () {
|
|
51
|
+
await uut.markAsPrivate(url);
|
|
52
|
+
await uut.allowCreation(url);
|
|
53
|
+
expect(uut.persistedHashes.entries.size).to.eql(0);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('#mightBeMarkedAsPrivate', function () {
|
|
58
|
+
it('should find only pages that were marked as private', async function () {
|
|
59
|
+
expect(await uut.mightBeMarkedAsPrivate(url)).to.eql(false);
|
|
60
|
+
|
|
61
|
+
await uut.markAsPrivate(url);
|
|
62
|
+
expect(await uut.mightBeMarkedAsPrivate(url)).to.eql(true);
|
|
63
|
+
expect(await uut.mightBeMarkedAsPrivate(`${url}/bar`)).to.eql(false);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { expect } from 'chai';
|
|
13
|
+
import sinon from 'sinon';
|
|
14
|
+
|
|
15
|
+
import QuorumChecker from '../src/quorum-checker.js';
|
|
16
|
+
import { BloomFilter } from '../src/bloom-filters.js';
|
|
17
|
+
import InMemoryDatabase from './helpers/in-memory-database.js';
|
|
18
|
+
|
|
19
|
+
describe('#QuorumChecker', function () {
|
|
20
|
+
let uut;
|
|
21
|
+
let fetchStub;
|
|
22
|
+
let sentIncrements;
|
|
23
|
+
|
|
24
|
+
beforeEach(function () {
|
|
25
|
+
// quorum config endpoint
|
|
26
|
+
fetchStub = sinon.stub(globalThis, 'fetch').callsFake(async () => ({
|
|
27
|
+
ok: true,
|
|
28
|
+
json: async () => ({ oc: 42 }),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
sentIncrements = [];
|
|
32
|
+
const communication = {
|
|
33
|
+
async sendInstant({ path, payload }) {
|
|
34
|
+
if (path === 'incrquorum') {
|
|
35
|
+
sentIncrements.push(payload);
|
|
36
|
+
}
|
|
37
|
+
return { ok: true, json: async () => ({ result: false }) };
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
let persistedConfig;
|
|
42
|
+
const storage = {
|
|
43
|
+
async get() {
|
|
44
|
+
return persistedConfig;
|
|
45
|
+
},
|
|
46
|
+
async set(_, value) {
|
|
47
|
+
persistedConfig = value;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
uut = new QuorumChecker({
|
|
52
|
+
config: { SAFE_QUORUM_CONFIG_ENDPOINT: 'https://quorum.test/config' },
|
|
53
|
+
storage,
|
|
54
|
+
storageKey: 'quorum_check',
|
|
55
|
+
bloomFilter: new BloomFilter({
|
|
56
|
+
database: new InMemoryDatabase(),
|
|
57
|
+
name: 'test',
|
|
58
|
+
partitions: [1009, 1013, 1019],
|
|
59
|
+
}),
|
|
60
|
+
communication,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterEach(function () {
|
|
65
|
+
fetchStub.restore();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('#sendQuorumIncrement', function () {
|
|
69
|
+
it('should vote only once for the same text', async function () {
|
|
70
|
+
const text = 'https://example.test/foo';
|
|
71
|
+
await uut.sendQuorumIncrement({ text });
|
|
72
|
+
await uut.sendQuorumIncrement({ text });
|
|
73
|
+
await uut.sendQuorumIncrement({ text });
|
|
74
|
+
|
|
75
|
+
expect(sentIncrements).to.have.lengthOf(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should vote for each text', async function () {
|
|
79
|
+
await uut.sendQuorumIncrement({ text: 'https://example.test/foo' });
|
|
80
|
+
await uut.sendQuorumIncrement({ text: 'https://example.test/bar' });
|
|
81
|
+
|
|
82
|
+
expect(sentIncrements).to.have.lengthOf(2);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|