@lowdefy/ajv 7.0.0 → 7.2.0
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/dist/ajvInstance.js +12 -1
- package/package.json +5 -6
package/dist/ajvInstance.js
CHANGED
|
@@ -33,8 +33,19 @@ const MAX_VALIDATION_ERRORS = 20;
|
|
|
33
33
|
// handful of entries whatever it held, since the earlier branches alone spent
|
|
34
34
|
// the budget. Counting is left alone, so `errors === 0` still decides validity
|
|
35
35
|
// and only the retained objects are bounded.
|
|
36
|
+
//
|
|
37
|
+
// Past the cap the count runs ahead of the array, so the two places generated
|
|
38
|
+
// code reads the array by the count are rewritten to read it by its length:
|
|
39
|
+
// - A branch that passes resets the errors to the count it began at
|
|
40
|
+
// (resetErrorsCount: `vErrors.length = _errsN;`). Past the cap that count is
|
|
41
|
+
// beyond the array, and setting it grew the array with holes, which ajv-errors
|
|
42
|
+
// then read (`err.keyword` of undefined) and callers received. The reset now
|
|
43
|
+
// only shrinks the array.
|
|
44
|
+
// - ajv-errors sets the path of the property error it just reported
|
|
45
|
+
// (`vErrors[errors-1].instancePath = …;`). Past the cap that error was not
|
|
46
|
+
// kept, so there is nothing to set.
|
|
36
47
|
function capErrors(code) {
|
|
37
|
-
return code.replace(/errors\+\+;/g, `errors++;if(vErrors!==null&&vErrors.length>${MAX_VALIDATION_ERRORS}){vErrors.length=${MAX_VALIDATION_ERRORS};}`);
|
|
48
|
+
return code.replace(/errors\+\+;/g, `errors++;if(vErrors!==null&&vErrors.length>${MAX_VALIDATION_ERRORS}){vErrors.length=${MAX_VALIDATION_ERRORS};}`).replace(/vErrors\.length = (_errs\d+);/g, 'if(vErrors.length>$1){vErrors.length = $1;}').replace(/vErrors\[errors-1\]\.instancePath = ([^;]+);/g, 'if(errors<=vErrors.length){vErrors[errors-1].instancePath = $1;}');
|
|
38
49
|
}
|
|
39
50
|
const ajv = new Ajv({
|
|
40
51
|
// codeql[js/resource-exhaustion-from-deep-object-traversal] -- bounded by capErrors() above
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/ajv",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"dist/*"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@lowdefy/helpers": "7.
|
|
37
|
-
"@lowdefy/nunjucks": "7.
|
|
36
|
+
"@lowdefy/helpers": "7.2.0",
|
|
37
|
+
"@lowdefy/nunjucks": "7.2.0",
|
|
38
38
|
"ajv": "8.20.0",
|
|
39
39
|
"ajv-errors": "3.0.0",
|
|
40
40
|
"ajv-formats": "2.1.1",
|
|
@@ -43,8 +43,7 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@swc/cli": "0.8.1",
|
|
45
45
|
"@swc/core": "1.15.32",
|
|
46
|
-
"
|
|
47
|
-
"jest": "28.1.3"
|
|
46
|
+
"vitest": "4.1.12"
|
|
48
47
|
},
|
|
49
48
|
"publishConfig": {
|
|
50
49
|
"access": "public"
|
|
@@ -52,6 +51,6 @@
|
|
|
52
51
|
"scripts": {
|
|
53
52
|
"build": "swc src --out-dir dist --config-file ../../../.swcrc --cli-config-file ../../../.swc-cli.json",
|
|
54
53
|
"clean": "rm -rf dist",
|
|
55
|
-
"test": "
|
|
54
|
+
"test": "vitest run"
|
|
56
55
|
}
|
|
57
56
|
}
|