Skip to content

Commit 3483bc8

Browse files
committed
limit keys for ajv
1 parent e434d43 commit 3483bc8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/management/identities/validations/identities.validation.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {additionalFieldsPartDto} from '../_dto/_parts/additionalFields.dto';
1616
*/
1717
@Injectable()
1818
export class IdentitiesValidationService implements OnApplicationBootstrap {
19-
private ajv: Ajv = new Ajv({allErrors: true});
19+
private ajv: Ajv = new Ajv({allErrors: true });
2020
private validateSchema;
2121
private logger: Logger;
2222

@@ -332,6 +332,12 @@ export class IdentitiesValidationService implements OnApplicationBootstrap {
332332
}
333333

334334
this.logger.debug(`Additionalfields object validation: ${JSON.stringify(data[key])}`);
335+
//limitation de la taille du data pour le pb de deny of service de ajv
336+
//voir (https://ajv.js.org/security.html)
337+
if (Object.keys(data[key]).length >500){
338+
this.logger.error('Request too large');
339+
throw new BadRequestException('Request too large');
340+
}
335341
const ok= await this.ajv.validate(schema,data[key]);
336342
if (ok === false) {
337343
const retErrors = {};

0 commit comments

Comments
 (0)