@whotracksme/reporting 12.1.4 β 12.1.5
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 +18 -0
- package/communication/karma.conf.cjs +1 -1
- package/communication/package.json +8 -9
- package/communication/rollup.common-config.cjs +19 -3
- package/communication/src/zlib.js +1 -1
- package/package.json +11 -11
- package/reporting/karma.conf.cjs +1 -1
- package/reporting/package.json +18 -19
- package/reporting/rollup.common-config.cjs +19 -3
- package/reporting/src/message-sender.js +2 -3
- package/reporting/src/request/qs-whitelist2.js +4 -5
- package/reporting/src/request/utils/bloom-filter-packed.js +2 -2
- package/reporting/src/request/utils/chrome-storage-map.js +7 -4
- package/reporting/test/activity-estimator.spec.js +9 -6
- package/reporting/test/helpers/fast-check-utils.js +11 -0
- package/reporting/test/job-scheduler.spec.js +7 -1
- package/reporting/test/pagedb.spec.js +3 -1
- package/reporting/test/patterns.spec.js +27 -25
- package/reporting/test/persisted-counters.spec.js +2 -3
- package/reporting/test/sanitizer.spec.js +4 -2
- package/reporting/test/url-analyzer.spec.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# v12.1.5 (Mon Oct 12 2026)
|
|
2
|
+
|
|
3
|
+
#### π Bug Fix
|
|
4
|
+
|
|
5
|
+
- Upgrade to prettier: 2.5.1 to 3.9.9 [#242](https://github.com/whotracksme/webextension-packages/pull/242) ([@philipp-classen](https://github.com/philipp-classen))
|
|
6
|
+
|
|
7
|
+
#### π Internal
|
|
8
|
+
|
|
9
|
+
- Update rollup from 2 to 4 [#237](https://github.com/whotracksme/webextension-packages/pull/237) ([@philipp-classen](https://github.com/philipp-classen))
|
|
10
|
+
- Update test dependencies [#236](https://github.com/whotracksme/webextension-packages/pull/236) ([@philipp-classen](https://github.com/philipp-classen))
|
|
11
|
+
- Upgrade dependencies [#235](https://github.com/whotracksme/webextension-packages/pull/235) ([@philipp-classen](https://github.com/philipp-classen))
|
|
12
|
+
|
|
13
|
+
#### Authors: 1
|
|
14
|
+
|
|
15
|
+
- Philipp ClaΓen ([@philipp-classen](https://github.com/philipp-classen))
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
1
19
|
# v12.1.4 (Fri Oct 02 2026)
|
|
2
20
|
|
|
3
21
|
#### π Bug Fix
|
|
@@ -2,7 +2,7 @@ const rollupPreprocessor = require('./rollup.common-config.cjs');
|
|
|
2
2
|
|
|
3
3
|
module.exports = function (config) {
|
|
4
4
|
config.set({
|
|
5
|
-
frameworks: ['mocha', '
|
|
5
|
+
frameworks: ['mocha', 'sinon'],
|
|
6
6
|
files: [{ pattern: 'test/**/*.spec.js', watched: false }],
|
|
7
7
|
preprocessors: {
|
|
8
8
|
'test/**/*.spec.js': ['rollup'],
|
|
@@ -11,25 +11,24 @@
|
|
|
11
11
|
"author": "Ghostery GmbH",
|
|
12
12
|
"license": "MPL-2.0",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@rollup/plugin-node-resolve": "^
|
|
15
|
-
"chai": "^
|
|
16
|
-
"fast-check": "^4.
|
|
14
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
15
|
+
"chai": "^6.3.0",
|
|
16
|
+
"fast-check": "^4.10.2",
|
|
17
17
|
"karma": "^6.4.4",
|
|
18
|
-
"karma-chai": "^0.1.0",
|
|
19
18
|
"karma-chrome-launcher": "^3.2.0",
|
|
20
19
|
"karma-mocha": "^2.0.1",
|
|
21
20
|
"karma-mocha-reporter": "^2.2.5",
|
|
22
21
|
"karma-rollup-preprocessor": "^7.0.8",
|
|
23
22
|
"karma-sinon": "^1.0.5",
|
|
24
|
-
"mocha": "^
|
|
25
|
-
"rollup": "^
|
|
26
|
-
"rollup-plugin-polyfill-node": "^0.
|
|
23
|
+
"mocha": "^12.0.3",
|
|
24
|
+
"rollup": "^4.64.2",
|
|
25
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
27
26
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
28
|
-
"sinon": "^
|
|
27
|
+
"sinon": "^22.1.0",
|
|
29
28
|
"web-ext": "^8.10.0"
|
|
30
29
|
},
|
|
31
30
|
"dependencies": {
|
|
32
|
-
"pako": "^
|
|
31
|
+
"pako": "^3.0.2"
|
|
33
32
|
},
|
|
34
33
|
"exports": {
|
|
35
34
|
".": "./src/index.js"
|
|
@@ -2,12 +2,28 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve');
|
|
|
2
2
|
const sourcemaps = require('rollup-plugin-sourcemaps');
|
|
3
3
|
const nodePolyfills = require('rollup-plugin-polyfill-node');
|
|
4
4
|
|
|
5
|
+
// rollup-plugin-sourcemaps reads every file itself; since rollup 3, plugin-loaded
|
|
6
|
+
// files are only watched when the plugin registers them, so without this wrapper
|
|
7
|
+
// `npm run watch` never rebuilds. Register every file the plugin loads.
|
|
8
|
+
function sourcemapsWithWatch() {
|
|
9
|
+
const plugin = sourcemaps();
|
|
10
|
+
return {
|
|
11
|
+
...plugin,
|
|
12
|
+
async load(id) {
|
|
13
|
+
const result = await plugin.load.call(this, id);
|
|
14
|
+
if (result != null) {
|
|
15
|
+
this.addWatchFile(id);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
5
22
|
module.exports = {
|
|
6
|
-
plugins: [nodePolyfills(), nodeResolve(),
|
|
7
|
-
external: ['
|
|
23
|
+
plugins: [nodePolyfills(), nodeResolve(), sourcemapsWithWatch()],
|
|
24
|
+
external: ['sinon'],
|
|
8
25
|
output: {
|
|
9
26
|
globals: {
|
|
10
|
-
chai: 'chai',
|
|
11
27
|
sinon: 'sinon',
|
|
12
28
|
},
|
|
13
29
|
format: 'iife',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whotracksme/reporting",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./sanitizer": "./reporting/src/sanitizer.js",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"auto": "^11.3.0",
|
|
42
42
|
"eslint": "^8.8.0",
|
|
43
|
-
"eslint-config-prettier": "^
|
|
44
|
-
"eslint-plugin-prettier": "^
|
|
45
|
-
"prettier": "
|
|
43
|
+
"eslint-config-prettier": "^10.1.8",
|
|
44
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
45
|
+
"prettier": "3.9.9"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@ghostery/url-parser": "^1.3.
|
|
49
|
-
"date-fns": "^
|
|
50
|
-
"idb": "^8.0.
|
|
51
|
-
"linkedom": "^0.18.
|
|
52
|
-
"pako": "^
|
|
53
|
-
"tldts-experimental": "^7.
|
|
54
|
-
"bowser": "^2.
|
|
48
|
+
"@ghostery/url-parser": "^1.3.1",
|
|
49
|
+
"date-fns": "^4.4.0",
|
|
50
|
+
"idb": "^8.0.4",
|
|
51
|
+
"linkedom": "^0.18.13",
|
|
52
|
+
"pako": "^3.0.2",
|
|
53
|
+
"tldts-experimental": "^7.4.16",
|
|
54
|
+
"bowser": "^2.14.1"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/reporting/karma.conf.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const rollupPreprocessor = require('./rollup.common-config.cjs');
|
|
|
3
3
|
module.exports = function (config) {
|
|
4
4
|
const entry = process.env.KARMA_TEST_ENTRY || 'test/index.js';
|
|
5
5
|
config.set({
|
|
6
|
-
frameworks: ['mocha', '
|
|
6
|
+
frameworks: ['mocha', 'sinon'],
|
|
7
7
|
files: [{ pattern: entry, watched: false }],
|
|
8
8
|
preprocessors: {
|
|
9
9
|
[entry]: ['rollup'],
|
package/reporting/package.json
CHANGED
|
@@ -21,39 +21,38 @@
|
|
|
21
21
|
"author": "Ghostery GmbH",
|
|
22
22
|
"license": "MPL-2.0",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@rollup/plugin-commonjs": "^
|
|
25
|
-
"@rollup/plugin-json": "^
|
|
26
|
-
"@rollup/plugin-node-resolve": "^
|
|
27
|
-
"chai": "^
|
|
24
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
25
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
26
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
27
|
+
"chai": "^6.3.0",
|
|
28
28
|
"chai-as-promised": "^8.0.2",
|
|
29
|
-
"fake-indexeddb": "^6.2.
|
|
30
|
-
"fast-check": "^
|
|
31
|
-
"karma": "^6.4.
|
|
32
|
-
"karma-
|
|
33
|
-
"karma-chrome-launcher": "^3.1.1",
|
|
29
|
+
"fake-indexeddb": "^6.2.5",
|
|
30
|
+
"fast-check": "^4.10.2",
|
|
31
|
+
"karma": "^6.4.4",
|
|
32
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
34
33
|
"karma-mocha": "^2.0.1",
|
|
35
34
|
"karma-mocha-reporter": "^2.2.5",
|
|
36
35
|
"karma-rollup-preprocessor": "^7.0.8",
|
|
37
36
|
"karma-sinon": "^1.0.5",
|
|
38
|
-
"mocha": "^
|
|
37
|
+
"mocha": "^12.0.3",
|
|
39
38
|
"puppeteer-core": "^24.42.0",
|
|
40
|
-
"rollup": "^
|
|
39
|
+
"rollup": "^4.64.2",
|
|
41
40
|
"rollup-plugin-copy": "^3.5.0",
|
|
42
|
-
"rollup-plugin-polyfill-node": "^0.
|
|
41
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
43
42
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
44
|
-
"sinon": "^
|
|
43
|
+
"sinon": "^22.1.0",
|
|
45
44
|
"sinon-chai": "^4.0.1",
|
|
46
45
|
"sinon-chrome": "^3.0.1",
|
|
47
46
|
"web-ext": "^8.2.0",
|
|
48
47
|
"webdriverio": "^9.27.0",
|
|
49
|
-
"ws": "^8.
|
|
48
|
+
"ws": "^8.22.0"
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
52
|
-
"@ghostery/url-parser": "^1.3.
|
|
53
|
-
"date-fns": "^
|
|
54
|
-
"idb": "^8.0.
|
|
55
|
-
"linkedom": "^0.18.
|
|
56
|
-
"tldts-experimental": "^7.
|
|
51
|
+
"@ghostery/url-parser": "^1.3.1",
|
|
52
|
+
"date-fns": "^4.4.0",
|
|
53
|
+
"idb": "^8.0.4",
|
|
54
|
+
"linkedom": "^0.18.13",
|
|
55
|
+
"tldts-experimental": "^7.4.16"
|
|
57
56
|
},
|
|
58
57
|
"exports": {
|
|
59
58
|
".": "./src/index.js",
|
|
@@ -4,18 +4,34 @@ const nodePolyfills = require('rollup-plugin-polyfill-node');
|
|
|
4
4
|
const commonjs = require('@rollup/plugin-commonjs');
|
|
5
5
|
const json = require('@rollup/plugin-json');
|
|
6
6
|
|
|
7
|
+
// rollup-plugin-sourcemaps reads every file itself; since rollup 3, plugin-loaded
|
|
8
|
+
// files are only watched when the plugin registers them, so without this wrapper
|
|
9
|
+
// `npm run watch` never rebuilds. Register every file the plugin loads.
|
|
10
|
+
function sourcemapsWithWatch() {
|
|
11
|
+
const plugin = sourcemaps();
|
|
12
|
+
return {
|
|
13
|
+
...plugin,
|
|
14
|
+
async load(id) {
|
|
15
|
+
const result = await plugin.load.call(this, id);
|
|
16
|
+
if (result != null) {
|
|
17
|
+
this.addWatchFile(id);
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
7
24
|
module.exports = {
|
|
8
25
|
plugins: [
|
|
9
26
|
nodePolyfills(),
|
|
10
27
|
nodeResolve(),
|
|
11
|
-
|
|
28
|
+
sourcemapsWithWatch(),
|
|
12
29
|
commonjs({ strictRequires: ['**/cssom/**'] }),
|
|
13
30
|
json(),
|
|
14
31
|
],
|
|
15
|
-
external: ['
|
|
32
|
+
external: ['sinon'],
|
|
16
33
|
output: {
|
|
17
34
|
globals: {
|
|
18
|
-
chai: 'chai',
|
|
19
35
|
sinon: 'sinon',
|
|
20
36
|
},
|
|
21
37
|
format: 'iife',
|
|
@@ -31,9 +31,8 @@ export default class MessageSender {
|
|
|
31
31
|
|
|
32
32
|
async send(message) {
|
|
33
33
|
logger.debug('Preparing to send message:', message);
|
|
34
|
-
const { ok, rollback, rejectReason } =
|
|
35
|
-
message
|
|
36
|
-
);
|
|
34
|
+
const { ok, rollback, rejectReason } =
|
|
35
|
+
await this.duplicateDetector.trySend(message);
|
|
37
36
|
if (!ok) {
|
|
38
37
|
logger.info('Rejected by duplicate detector:', rejectReason, message);
|
|
39
38
|
return;
|
|
@@ -41,16 +41,15 @@ export default class QSWhitelist2 {
|
|
|
41
41
|
|
|
42
42
|
async init() {
|
|
43
43
|
try {
|
|
44
|
-
const { version, localSafeKey } =
|
|
45
|
-
STORAGE_CONFIG_KEY
|
|
46
|
-
);
|
|
44
|
+
const { version, localSafeKey } =
|
|
45
|
+
await this.storage.get(STORAGE_CONFIG_KEY);
|
|
47
46
|
|
|
48
47
|
const buffer = await this.storage.get(STORAGE_BLOOM_FILTER_KEY);
|
|
49
48
|
this.bloomFilter = new PackedBloomFilter(buffer);
|
|
50
49
|
this.version = version;
|
|
51
50
|
this.localSafeKey = localSafeKey || {};
|
|
52
51
|
logger.debug(`[QSWhitelist2] Bloom filter loaded version ${version}`);
|
|
53
|
-
} catch
|
|
52
|
+
} catch {
|
|
54
53
|
logger.info('[QSWhitelist2] Failed loading filter from local');
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -67,7 +66,7 @@ export default class QSWhitelist2 {
|
|
|
67
66
|
this.networkFetchEnabled = false;
|
|
68
67
|
try {
|
|
69
68
|
await this._fullUpdate((await this._fetchUpdateURL()).version);
|
|
70
|
-
} catch
|
|
69
|
+
} catch {
|
|
71
70
|
logger.info('[QSWhitelist2] failed to load bloom filter');
|
|
72
71
|
// local fetch also failed
|
|
73
72
|
// create empty bloom filter
|
|
@@ -59,7 +59,7 @@ export default class PackedBloomFilter {
|
|
|
59
59
|
const l = this.locations(a, b);
|
|
60
60
|
for (let i = 0; i < this.k; i += 1) {
|
|
61
61
|
const bk = l[i];
|
|
62
|
-
if ((this.getBucket(Math.floor(bk / 32)) & (1 << bk % 32)) === 0) {
|
|
62
|
+
if ((this.getBucket(Math.floor(bk / 32)) & (1 << (bk % 32))) === 0) {
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -78,7 +78,7 @@ export default class PackedBloomFilter {
|
|
|
78
78
|
for (let i = 0; i < this.k; i += 1) {
|
|
79
79
|
const bk = Math.floor(l[i] / 32);
|
|
80
80
|
const offset = 5 + bk * 4;
|
|
81
|
-
const newValue = this.data.getUint32(offset, false) | (1 << l[i] % 32);
|
|
81
|
+
const newValue = this.data.getUint32(offset, false) | (1 << (l[i] % 32));
|
|
82
82
|
this.data.setUint32(offset, newValue, false);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -250,10 +250,13 @@ export default class ChromeStorageMap {
|
|
|
250
250
|
this._flush();
|
|
251
251
|
this._scheduledFlush = null;
|
|
252
252
|
} else {
|
|
253
|
-
this._scheduledFlush = setTimeout(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
this._scheduledFlush = setTimeout(
|
|
254
|
+
() => {
|
|
255
|
+
this._flush();
|
|
256
|
+
this._scheduledFlush = null;
|
|
257
|
+
},
|
|
258
|
+
Math.min(this.softFlushIntervalInMs, nextForcedFlush - now),
|
|
259
|
+
);
|
|
257
260
|
}
|
|
258
261
|
}
|
|
259
262
|
|
|
@@ -255,12 +255,15 @@ describe('#ActivityEstimator', function () {
|
|
|
255
255
|
],
|
|
256
256
|
} = {}) {
|
|
257
257
|
return fc.array(
|
|
258
|
-
fc.record(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
258
|
+
fc.record(
|
|
259
|
+
{
|
|
260
|
+
url: fc.option(...urls.map((url) => fc.constant(url))),
|
|
261
|
+
isDynamicLoad: fc.boolean(),
|
|
262
|
+
delay: fc.nat(1 * WEEK),
|
|
263
|
+
jump: fc.nat(1 * WEEK),
|
|
264
|
+
},
|
|
265
|
+
{ noNullPrototype: true },
|
|
266
|
+
),
|
|
264
267
|
);
|
|
265
268
|
}
|
|
266
269
|
|
|
@@ -22,6 +22,17 @@ export const arbitraryUrlWithDomain = fc
|
|
|
22
22
|
.webUrl()
|
|
23
23
|
.filter((url) => tldts.getDomain(url) !== null);
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Simulates the removed fc.fullUnicodeString() with binary string.
|
|
27
|
+
*/
|
|
28
|
+
export const fullUnicodeString = () => fc.string({ unit: 'binary' });
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Simulates the removed fc.hexaString() with hex characters.
|
|
32
|
+
*/
|
|
33
|
+
export const hexaString = () =>
|
|
34
|
+
fc.string({ unit: fc.constantFrom(...'0123456789abcdef') });
|
|
35
|
+
|
|
25
36
|
/**
|
|
26
37
|
* fast-check will find edge cases for keys like "__proto__".
|
|
27
38
|
* Yet in most use cases, the keys will be simple enough to work
|
|
@@ -1002,6 +1002,7 @@ describe('#JobScheduler', function () {
|
|
|
1002
1002
|
},
|
|
1003
1003
|
{
|
|
1004
1004
|
requiredKeys: ['min'],
|
|
1005
|
+
noNullPrototype: true,
|
|
1005
1006
|
},
|
|
1006
1007
|
),
|
|
1007
1008
|
expireIn: fc.record(
|
|
@@ -1011,6 +1012,7 @@ describe('#JobScheduler', function () {
|
|
|
1011
1012
|
},
|
|
1012
1013
|
{
|
|
1013
1014
|
requiredKeys: ['min'],
|
|
1015
|
+
noNullPrototype: true,
|
|
1014
1016
|
},
|
|
1015
1017
|
),
|
|
1016
1018
|
});
|
|
@@ -1019,7 +1021,10 @@ describe('#JobScheduler', function () {
|
|
|
1019
1021
|
const arbitraryJobType = () => fc.nat(maxJobTypes - 1).map(numToJobType);
|
|
1020
1022
|
const arbitraryJobArgs = () => fc.array(fc.nat());
|
|
1021
1023
|
const arbitraryJobConfig = () =>
|
|
1022
|
-
fc.record(commonJobConfigFields(), {
|
|
1024
|
+
fc.record(commonJobConfigFields(), {
|
|
1025
|
+
requiredKeys: [],
|
|
1026
|
+
noNullPrototype: true,
|
|
1027
|
+
});
|
|
1023
1028
|
const arbitraryJob = () => {
|
|
1024
1029
|
return fc
|
|
1025
1030
|
.tuple(
|
|
@@ -1033,6 +1038,7 @@ describe('#JobScheduler', function () {
|
|
|
1033
1038
|
},
|
|
1034
1039
|
{
|
|
1035
1040
|
requiredKeys: [],
|
|
1041
|
+
noNullPrototype: true,
|
|
1036
1042
|
},
|
|
1037
1043
|
),
|
|
1038
1044
|
),
|
|
@@ -13,6 +13,8 @@ import { expect } from 'chai';
|
|
|
13
13
|
import sinon from 'sinon';
|
|
14
14
|
import * as fc from 'fast-check';
|
|
15
15
|
|
|
16
|
+
import { fullUnicodeString } from './helpers/fast-check-utils.js';
|
|
17
|
+
|
|
16
18
|
import PageDB, { toPersistedKey, parsePersistedKey } from '../src/pagedb.js';
|
|
17
19
|
import InMemoryDatabase from './helpers/in-memory-database.js';
|
|
18
20
|
import { InMemoryNewPageApprover } from './helpers/pagedb-mocks.js';
|
|
@@ -26,7 +28,7 @@ const YEAR = 365 * DAY;
|
|
|
26
28
|
describe('#toPersistedKey and #parsePersistedKey', function () {
|
|
27
29
|
it('should be invertable', function () {
|
|
28
30
|
fc.assert(
|
|
29
|
-
fc.property(
|
|
31
|
+
fc.property(fullUnicodeString(), fc.integer(), (url, createdAt) => {
|
|
30
32
|
const result = parsePersistedKey(toPersistedKey(url, createdAt));
|
|
31
33
|
expect(result.url).to.eql(url);
|
|
32
34
|
expect(result.createdAt).to.eql(createdAt);
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
import { expect } from 'chai';
|
|
13
13
|
import fc from 'fast-check';
|
|
14
14
|
|
|
15
|
+
import { fullUnicodeString, hexaString } from './helpers/fast-check-utils.js';
|
|
16
|
+
|
|
15
17
|
import Patterns, { lookupBuiltinTransform } from '../src/patterns.js';
|
|
16
18
|
import { isSubSequence } from '../src/utils.js';
|
|
17
19
|
|
|
@@ -54,7 +56,7 @@ describe('Test builtin primitives', function () {
|
|
|
54
56
|
|
|
55
57
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
56
58
|
fc.assert(
|
|
57
|
-
fc.property(
|
|
59
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
58
60
|
// should not throw
|
|
59
61
|
queryParam(untrustedText, 'someTrustedParam');
|
|
60
62
|
}),
|
|
@@ -201,8 +203,8 @@ describe('Test builtin primitives', function () {
|
|
|
201
203
|
fc.assert(
|
|
202
204
|
fc.property(
|
|
203
205
|
fc.webUrl({ withQueryParameters: true, withFragments: true }),
|
|
204
|
-
fc.array(fc.tuple(
|
|
205
|
-
fc.array(
|
|
206
|
+
fc.array(fc.tuple(hexaString(), hexaString())),
|
|
207
|
+
fc.array(hexaString()),
|
|
206
208
|
(url, paramsToAdd, paramsToRemove) => {
|
|
207
209
|
const tmp1 = new URL(url);
|
|
208
210
|
tmp1.search = new URLSearchParams(paramsToAdd);
|
|
@@ -288,7 +290,7 @@ describe('Test builtin primitives', function () {
|
|
|
288
290
|
|
|
289
291
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
290
292
|
fc.assert(
|
|
291
|
-
fc.property(
|
|
293
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
292
294
|
const result = removeParams(untrustedText, ['someTrustedParam']);
|
|
293
295
|
if (result !== null) {
|
|
294
296
|
expect(result).to.be.a('string');
|
|
@@ -344,7 +346,7 @@ describe('Test builtin primitives', function () {
|
|
|
344
346
|
|
|
345
347
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
346
348
|
fc.assert(
|
|
347
|
-
fc.property(
|
|
349
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
348
350
|
const result = requireURL(untrustedText);
|
|
349
351
|
if (result !== null) {
|
|
350
352
|
expect(result).to.eql(untrustedText);
|
|
@@ -401,7 +403,7 @@ describe('Test builtin primitives', function () {
|
|
|
401
403
|
|
|
402
404
|
it('should drop all non-matching untrustedTexts', function () {
|
|
403
405
|
fc.assert(
|
|
404
|
-
fc.property(
|
|
406
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
405
407
|
expect(filterExact(untrustedText, [])).to.eql(null);
|
|
406
408
|
expect(
|
|
407
409
|
filterExact(untrustedText, [untrustedText + 'force_mismatch']),
|
|
@@ -429,7 +431,7 @@ describe('Test builtin primitives', function () {
|
|
|
429
431
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
430
432
|
fc.assert(
|
|
431
433
|
fc.property(
|
|
432
|
-
|
|
434
|
+
fullUnicodeString(),
|
|
433
435
|
fc.array(fc.string()),
|
|
434
436
|
(untrustedText, allowedValues) => {
|
|
435
437
|
expect(filterExact(untrustedText, allowedValues)).to.be.oneOf([
|
|
@@ -470,7 +472,7 @@ describe('Test builtin primitives', function () {
|
|
|
470
472
|
|
|
471
473
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
472
474
|
fc.assert(
|
|
473
|
-
fc.property(
|
|
475
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
474
476
|
// should not throw
|
|
475
477
|
maskU(untrustedText);
|
|
476
478
|
}),
|
|
@@ -535,7 +537,7 @@ describe('Test builtin primitives', function () {
|
|
|
535
537
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
536
538
|
fc.assert(
|
|
537
539
|
fc.property(
|
|
538
|
-
|
|
540
|
+
fullUnicodeString(),
|
|
539
541
|
fc.string(),
|
|
540
542
|
(untrustedText, splitOn) => {
|
|
541
543
|
fc.pre(splitOn.length > 0);
|
|
@@ -600,7 +602,7 @@ describe('Test builtin primitives', function () {
|
|
|
600
602
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
601
603
|
fc.assert(
|
|
602
604
|
fc.property(
|
|
603
|
-
|
|
605
|
+
fullUnicodeString(),
|
|
604
606
|
fc.string(),
|
|
605
607
|
(untrustedText, trySplitOn) => {
|
|
606
608
|
fc.pre(trySplitOn.length > 0);
|
|
@@ -648,7 +650,7 @@ describe('Test builtin primitives', function () {
|
|
|
648
650
|
|
|
649
651
|
it('should behave like decodeURIComponent for any properly encodeded string', function () {
|
|
650
652
|
fc.assert(
|
|
651
|
-
fc.property(
|
|
653
|
+
fc.property(fullUnicodeString(), (text) => {
|
|
652
654
|
const input = encodeURIComponent(text);
|
|
653
655
|
expect(uut(input)).to.eql(text);
|
|
654
656
|
}),
|
|
@@ -672,7 +674,7 @@ describe('Test builtin primitives', function () {
|
|
|
672
674
|
|
|
673
675
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
674
676
|
fc.assert(
|
|
675
|
-
fc.property(
|
|
677
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
676
678
|
const result = uut(untrustedText);
|
|
677
679
|
if (result !== null) {
|
|
678
680
|
expect(result).to.be.a('string');
|
|
@@ -713,7 +715,7 @@ describe('Test builtin primitives', function () {
|
|
|
713
715
|
|
|
714
716
|
it('should behave like decodeURIComponent for any properly encodeded string', function () {
|
|
715
717
|
fc.assert(
|
|
716
|
-
fc.property(
|
|
718
|
+
fc.property(fullUnicodeString(), (text) => {
|
|
717
719
|
const input = encodeURIComponent(text);
|
|
718
720
|
expect(uut(input)).to.eql(text);
|
|
719
721
|
}),
|
|
@@ -737,7 +739,7 @@ describe('Test builtin primitives', function () {
|
|
|
737
739
|
|
|
738
740
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
739
741
|
fc.assert(
|
|
740
|
-
fc.property(
|
|
742
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
741
743
|
expect(uut(untrustedText)).to.be.a('string');
|
|
742
744
|
}),
|
|
743
745
|
);
|
|
@@ -860,7 +862,7 @@ describe('Test builtin primitives', function () {
|
|
|
860
862
|
it('should not fail on well-formed but arbitrary text', function () {
|
|
861
863
|
fc.assert(
|
|
862
864
|
fc.property(
|
|
863
|
-
|
|
865
|
+
fullUnicodeString(),
|
|
864
866
|
fc.string(),
|
|
865
867
|
fc.boolean(),
|
|
866
868
|
(untrustedText, path, extractObjects) => {
|
|
@@ -908,7 +910,7 @@ describe('Test builtin primitives', function () {
|
|
|
908
910
|
|
|
909
911
|
it('should work on arbitrary strings and behave like String.trim', function () {
|
|
910
912
|
fc.assert(
|
|
911
|
-
fc.property(
|
|
913
|
+
fc.property(fullUnicodeString(), (untrustedText) => {
|
|
912
914
|
const result = trim(untrustedText);
|
|
913
915
|
expect(result).to.be.a('string').and.to.eql(untrustedText.trim());
|
|
914
916
|
}),
|
|
@@ -943,7 +945,7 @@ describe('Test builtin primitives', function () {
|
|
|
943
945
|
|
|
944
946
|
it('should not fail on arbitrary text and patterns', function () {
|
|
945
947
|
fc.assert(
|
|
946
|
-
fc.property(
|
|
948
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
947
949
|
expect(uut(text, pattern)).to.be.a('string');
|
|
948
950
|
}),
|
|
949
951
|
);
|
|
@@ -951,7 +953,7 @@ describe('Test builtin primitives', function () {
|
|
|
951
953
|
|
|
952
954
|
it('should only remove characters from the text (the result never grows)', function () {
|
|
953
955
|
fc.assert(
|
|
954
|
-
fc.property(
|
|
956
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
955
957
|
const subsequence = uut(text, pattern);
|
|
956
958
|
expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
|
|
957
959
|
}),
|
|
@@ -986,7 +988,7 @@ describe('Test builtin primitives', function () {
|
|
|
986
988
|
|
|
987
989
|
it('should not fail on arbitrary text and patterns', function () {
|
|
988
990
|
fc.assert(
|
|
989
|
-
fc.property(
|
|
991
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
990
992
|
expect(uut(text, pattern)).to.be.a('string');
|
|
991
993
|
}),
|
|
992
994
|
);
|
|
@@ -994,7 +996,7 @@ describe('Test builtin primitives', function () {
|
|
|
994
996
|
|
|
995
997
|
it('should only remove characters from the text (the result never grows)', function () {
|
|
996
998
|
fc.assert(
|
|
997
|
-
fc.property(
|
|
999
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
998
1000
|
const subsequence = uut(text, pattern);
|
|
999
1001
|
expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
|
|
1000
1002
|
}),
|
|
@@ -1029,7 +1031,7 @@ describe('Test builtin primitives', function () {
|
|
|
1029
1031
|
|
|
1030
1032
|
it('should not fail on arbitrary text and patterns', function () {
|
|
1031
1033
|
fc.assert(
|
|
1032
|
-
fc.property(
|
|
1034
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
1033
1035
|
expect(uut(text, pattern)).to.be.a('string');
|
|
1034
1036
|
}),
|
|
1035
1037
|
);
|
|
@@ -1037,7 +1039,7 @@ describe('Test builtin primitives', function () {
|
|
|
1037
1039
|
|
|
1038
1040
|
it('should only remove characters from the text (the result never grows)', function () {
|
|
1039
1041
|
fc.assert(
|
|
1040
|
-
fc.property(
|
|
1042
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
1041
1043
|
const subsequence = uut(text, pattern);
|
|
1042
1044
|
expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
|
|
1043
1045
|
}),
|
|
@@ -1068,7 +1070,7 @@ describe('Test builtin primitives', function () {
|
|
|
1068
1070
|
|
|
1069
1071
|
it('should behave like a naive match(...).join("") implementation', function () {
|
|
1070
1072
|
fc.assert(
|
|
1071
|
-
fc.property(
|
|
1073
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
1072
1074
|
let expected = '';
|
|
1073
1075
|
try {
|
|
1074
1076
|
expected = (text.match(new RegExp(pattern, 'g')) || []).join('');
|
|
@@ -1090,7 +1092,7 @@ describe('Test builtin primitives', function () {
|
|
|
1090
1092
|
|
|
1091
1093
|
it('should not fail on arbitrary text and patterns', function () {
|
|
1092
1094
|
fc.assert(
|
|
1093
|
-
fc.property(
|
|
1095
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
1094
1096
|
expect(uut(text, pattern)).to.be.a('string');
|
|
1095
1097
|
}),
|
|
1096
1098
|
);
|
|
@@ -1098,7 +1100,7 @@ describe('Test builtin primitives', function () {
|
|
|
1098
1100
|
|
|
1099
1101
|
it('should only remove characters from the text (the result never grows)', function () {
|
|
1100
1102
|
fc.assert(
|
|
1101
|
-
fc.property(
|
|
1103
|
+
fc.property(fullUnicodeString(), fc.string(), (text, pattern) => {
|
|
1102
1104
|
const subsequence = uut(text, pattern);
|
|
1103
1105
|
expect(isSubSequence({ sequence: text, subsequence })).to.be.true;
|
|
1104
1106
|
}),
|
|
@@ -81,9 +81,8 @@ describe('#PersistedCounters', function () {
|
|
|
81
81
|
fc.nat(100),
|
|
82
82
|
async (keys, numSamples) => {
|
|
83
83
|
keys.forEach((key) => uut.count(key));
|
|
84
|
-
const { samples, populationSize } =
|
|
85
|
-
numSamples
|
|
86
|
-
);
|
|
84
|
+
const { samples, populationSize } =
|
|
85
|
+
await uut.sample(numSamples);
|
|
87
86
|
expect(populationSize).to.eql(keys.length);
|
|
88
87
|
|
|
89
88
|
if (keys.length === 0) {
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
import { expect } from 'chai';
|
|
13
13
|
import fc from 'fast-check';
|
|
14
14
|
|
|
15
|
+
import { fullUnicodeString } from './helpers/fast-check-utils.js';
|
|
16
|
+
|
|
15
17
|
import {
|
|
16
18
|
sanitizeUrl,
|
|
17
19
|
checkSuspiciousQuery,
|
|
@@ -1031,7 +1033,7 @@ describe('#isValidEAN13', function () {
|
|
|
1031
1033
|
|
|
1032
1034
|
it('with unicode input', function () {
|
|
1033
1035
|
fc.assert(
|
|
1034
|
-
fc.property(
|
|
1036
|
+
fc.property(fullUnicodeString(), (text) => {
|
|
1035
1037
|
expect(isValidEAN13(text)).to.be.oneOf([true, false]);
|
|
1036
1038
|
}),
|
|
1037
1039
|
);
|
|
@@ -1094,7 +1096,7 @@ describe('#isValidISSN', function () {
|
|
|
1094
1096
|
|
|
1095
1097
|
it('with unicode input', function () {
|
|
1096
1098
|
fc.assert(
|
|
1097
|
-
fc.property(
|
|
1099
|
+
fc.property(fullUnicodeString(), (text) => {
|
|
1098
1100
|
expect(isValidISSN(text)).to.be.oneOf([true, false]);
|
|
1099
1101
|
}),
|
|
1100
1102
|
);
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
import { expect } from 'chai';
|
|
13
13
|
import fc from 'fast-check';
|
|
14
14
|
|
|
15
|
+
import { fullUnicodeString } from './helpers/fast-check-utils.js';
|
|
16
|
+
|
|
15
17
|
import UrlAnalyzer from '../src/url-analyzer.js';
|
|
16
18
|
|
|
17
19
|
describe('#UrlAnalyzer', function () {
|
|
@@ -475,7 +477,7 @@ describe('#UrlAnalyzer', function () {
|
|
|
475
477
|
|
|
476
478
|
it('should support special characters (unicode)', function () {
|
|
477
479
|
fc.assert(
|
|
478
|
-
fc.property(
|
|
480
|
+
fc.property(fullUnicodeString(), (text) => {
|
|
479
481
|
fc.pre(text.length > 0 && text === text.trim());
|
|
480
482
|
const encodedText = encodeURIComponent(text);
|
|
481
483
|
const url = `https://www.google.com/search?q=${encodedText}`;
|