json-schema-secure.json 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {
  2. "$schema": "http://json-schema.org/draft-07/schema#",
  3. "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/json-schema-secure.json#",
  4. "title": "Meta-schema for the security assessment of JSON Schemas",
  5. "description": "If a JSON Schema fails validation against this meta-schema, it may be unsafe to validate untrusted data",
  6. "definitions": {
  7. "schemaArray": {
  8. "type": "array",
  9. "minItems": 1,
  10. "items": {"$ref": "#"}
  11. }
  12. },
  13. "dependencies": {
  14. "patternProperties": {
  15. "description": "prevent slow validation of large property names",
  16. "required": ["propertyNames"],
  17. "properties": {
  18. "propertyNames": {
  19. "required": ["maxLength"]
  20. }
  21. }
  22. },
  23. "uniqueItems": {
  24. "description": "prevent slow validation of large non-scalar arrays",
  25. "if": {
  26. "properties": {
  27. "uniqueItems": {"const": true},
  28. "items": {
  29. "properties": {
  30. "type": {
  31. "anyOf": [
  32. {
  33. "enum": ["object", "array"]
  34. },
  35. {
  36. "type": "array",
  37. "contains": {"enum": ["object", "array"]}
  38. }
  39. ]
  40. }
  41. }
  42. }
  43. }
  44. },
  45. "then": {
  46. "required": ["maxItems"]
  47. }
  48. },
  49. "pattern": {
  50. "description": "prevent slow pattern matching of large strings",
  51. "required": ["maxLength"]
  52. },
  53. "format": {
  54. "description": "prevent slow format validation of large strings",
  55. "required": ["maxLength"]
  56. }
  57. },
  58. "properties": {
  59. "additionalItems": {"$ref": "#"},
  60. "additionalProperties": {"$ref": "#"},
  61. "dependencies": {
  62. "additionalProperties": {
  63. "anyOf": [
  64. {"type": "array"},
  65. {"$ref": "#"}
  66. ]
  67. }
  68. },
  69. "items": {
  70. "anyOf": [
  71. {"$ref": "#"},
  72. {"$ref": "#/definitions/schemaArray"}
  73. ]
  74. },
  75. "definitions": {
  76. "additionalProperties": {"$ref": "#"}
  77. },
  78. "patternProperties": {
  79. "additionalProperties": {"$ref": "#"}
  80. },
  81. "properties": {
  82. "additionalProperties": {"$ref": "#"}
  83. },
  84. "if": {"$ref": "#"},
  85. "then": {"$ref": "#"},
  86. "else": {"$ref": "#"},
  87. "allOf": {"$ref": "#/definitions/schemaArray"},
  88. "anyOf": {"$ref": "#/definitions/schemaArray"},
  89. "oneOf": {"$ref": "#/definitions/schemaArray"},
  90. "not": {"$ref": "#"},
  91. "contains": {"$ref": "#"},
  92. "propertyNames": {"$ref": "#"}
  93. }
  94. }