Skip to content

Commit 2baddc8

Browse files
authored
fix: limit schema compilation depth (#874)
1 parent 82423e7 commit 2baddc8

5 files changed

Lines changed: 479 additions & 59 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,17 @@ const fastJson = require('fast-json-stringify')
121121
const stringify = fastJson(mySchema, {
122122
schema: { ... },
123123
ajv: { ... },
124-
rounding: 'ceil'
124+
rounding: 'ceil',
125+
maxDepth: 100
125126
})
126127
```
127128

128129
- `schema`: external schemas references by $ref property. [More details](#ref)
129130
- `ajv`: [ajv v8 instance's settings](https://ajv.js.org/options.html) for those properties that require `ajv`. [More details](#anyof)
130131
- `rounding`: setup how the `integer` types will be rounded when not integers. [More details](#integer)
132+
- `maxDepth`: maximum number of nested schema levels allowed during compilation.
133+
Defaults to `100` and may be set from `0` to `100`. Schemas that exceed this limit
134+
are rejected before compilation.
131135
- `inlineValidators`: when using standalone mode, embed Ajv-generated validator functions in the output instead of compiling schemas at runtime. [More details](#standalone)
132136
- `largeArrayMechanism`: set the mechanism that should be used to handle large
133137
(by default `20000` or more items) arrays. [More details](#largearrays)

0 commit comments

Comments
 (0)