From aced0cc56ed60832db2332f7922d3129e4531630 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Sat, 2 Feb 2019 19:46:59 +0000 Subject: [PATCH] refactor: security meta-schema --- lib/refs/json-schema-secure.json | 40 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/lib/refs/json-schema-secure.json b/lib/refs/json-schema-secure.json index fea4d04..66faf84 100644 --- a/lib/refs/json-schema-secure.json +++ b/lib/refs/json-schema-secure.json @@ -10,25 +10,19 @@ "items": {"$ref": "#"} } }, - "allOf": [ - { + "dependencies": { + "patternProperties": { "description": "prevent slow validation of large property names", - "if": { - "required": ["patternProperties"] - }, - "then": { - "required": ["propertyNames"], - "properties": { - "propertyNames": { - "required": ["maxLength"] - } + "required": ["propertyNames"], + "properties": { + "propertyNames": { + "required": ["maxLength"] } } }, - { + "uniqueItems": { "description": "prevent slow validation of large non-scalar arrays", "if": { - "required": ["uniqueItems"], "properties": { "uniqueItems": {"const": true}, "items": { @@ -52,19 +46,15 @@ "required": ["maxItems"] } }, - { - "description": "prevent slow validation of large strings", - "if": { - "anyOf": [ - {"required": ["pattern"]}, - {"required": ["format"]} - ] - }, - "then": { - "required": ["maxLength"] - } + "pattern": { + "description": "prevent slow pattern matching of large strings", + "required": ["maxLength"] + }, + "format": { + "description": "prevent slow format validation of large strings", + "required": ["maxLength"] } - ], + }, "properties": { "additionalItems": {"$ref": "#"}, "additionalProperties": {"$ref": "#"},