-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dmitry Dygalo <[email protected]>
- Loading branch information
1 parent
90f2b11
commit 1d48eaf
Showing
14 changed files
with
342 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
corpus | ||
artifacts | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "benchmark-fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
jsonschema = { path = "../crates/jsonschema/" } | ||
serde_json = "1" | ||
|
||
[workspace] | ||
members = ["."] | ||
|
||
[profile.release] | ||
debug = true | ||
|
||
[[bin]] | ||
name = "compile" | ||
path = "fuzz_targets/compile.rs" | ||
test = false | ||
doc = false | ||
bench = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# JSON Schema keywords | ||
"$schema" | ||
"$id" | ||
"type" | ||
"properties" | ||
"required" | ||
"additionalProperties" | ||
"items" | ||
"allOf" | ||
"anyOf" | ||
"oneOf" | ||
"not" | ||
"definitions" | ||
"$ref" | ||
"enum" | ||
"const" | ||
"multipleOf" | ||
"maximum" | ||
"exclusiveMaximum" | ||
"minimum" | ||
"exclusiveMinimum" | ||
"maxLength" | ||
"minLength" | ||
"pattern" | ||
"maxItems" | ||
"minItems" | ||
"uniqueItems" | ||
"maxProperties" | ||
"minProperties" | ||
"dependencies" | ||
"propertyNames" | ||
"if" | ||
"then" | ||
"else" | ||
"format" | ||
|
||
# Data types | ||
"object" | ||
"array" | ||
"string" | ||
"number" | ||
"integer" | ||
"boolean" | ||
"null" | ||
|
||
# Common patterns | ||
"^[a-zA-Z0-9_]+$" | ||
"^[0-9]{4}-[0-9]{2}-[0-9]{2}$" | ||
|
||
# Special characters | ||
"{" | ||
"}" | ||
"[" | ||
"]" | ||
":" | ||
"," | ||
|
||
# Common values | ||
"true" | ||
"false" | ||
"null" | ||
"0" | ||
"1" | ||
"-1" | ||
"3.14" | ||
|
||
# URI references | ||
"#" | ||
"#/definitions/" | ||
"#/properties/" | ||
|
||
# Format specifiers | ||
"date-time" | ||
"date" | ||
"time" | ||
"email" | ||
"idn-email" | ||
"hostname" | ||
"idn-hostname" | ||
"ipv4" | ||
"ipv6" | ||
"uri" | ||
"uri-reference" | ||
"iri" | ||
"iri-reference" | ||
"uuid" | ||
|
||
# Common property names | ||
"id" | ||
"name" | ||
"title" | ||
"description" | ||
"default" | ||
"examples" | ||
"$comment" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
let Ok(schema) = serde_json::from_slice(data) else { | ||
return; | ||
}; | ||
let _ = jsonschema::compile(&schema); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"id": { "type": "integer" }, | ||
"value": { "type": "string" } | ||
}, | ||
"required": ["id", "value"] | ||
}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"allOf": [ | ||
{ "properties": { "name": { "type": "string" } } }, | ||
{ "properties": { "age": { "type": "integer", "minimum": 0 } } } | ||
], | ||
"anyOf": [ | ||
{ "properties": { "email": { "type": "string", "format": "email" } } }, | ||
{ "properties": { "phone": { "type": "string", "pattern": "^\\+?[0-9]{10,14}$" } } } | ||
], | ||
"oneOf": [ | ||
{ "properties": { "type": { "const": "user" } } }, | ||
{ "properties": { "type": { "const": "admin" } } } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"color": { "enum": ["red", "green", "blue"] }, | ||
"version": { "const": "1.0" }, | ||
"features": { | ||
"type": "array", | ||
"items": { "type": "string" } | ||
} | ||
}, | ||
"required": ["color", "version"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"user": { | ||
"type": "object", | ||
"properties": { | ||
"id": { "type": "integer" }, | ||
"username": { "type": "string", "pattern": "^[a-z0-9_]{3,16}$" } | ||
}, | ||
"required": ["id", "username"] | ||
} | ||
}, | ||
"patternProperties": { | ||
"^data_": { "type": "string" } | ||
}, | ||
"additionalProperties": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"name": { "type": "string" }, | ||
"age": { "type": "integer", "minimum": 0 }, | ||
"email": { "type": "string", "format": "email" } | ||
}, | ||
"required": ["name", "age"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"definitions": { | ||
"positiveInteger": { | ||
"type": "integer", | ||
"minimum": 1 | ||
}, | ||
"nonEmptyString": { | ||
"type": "string", | ||
"minLength": 1 | ||
} | ||
}, | ||
"properties": { | ||
"id": { "$ref": "#/definitions/positiveInteger" }, | ||
"name": { "$ref": "#/definitions/nonEmptyString" }, | ||
"tags": { | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/nonEmptyString" }, | ||
"uniqueItems": true | ||
}, | ||
"metadata": { | ||
"type": "object", | ||
"propertyNames": { "$ref": "#/definitions/nonEmptyString" }, | ||
"additionalProperties": { | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/positiveInteger" }, | ||
{ "$ref": "#/definitions/nonEmptyString" } | ||
] | ||
} | ||
} | ||
}, | ||
"required": ["id", "name"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"user": { "$ref": "https://example.com/schemas/user.json" }, | ||
"order": { | ||
"type": "object", | ||
"properties": { | ||
"id": { "type": "string" }, | ||
"items": { "$ref": "https://example.com/schemas/order-items.json" } | ||
}, | ||
"required": ["id", "items"] | ||
} | ||
}, | ||
"required": ["user", "order"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"definitions": { | ||
"address": { | ||
"type": "object", | ||
"properties": { | ||
"street": { "type": "string" }, | ||
"city": { "type": "string" }, | ||
"country": { "type": "string" } | ||
}, | ||
"required": ["street", "city", "country"] | ||
}, | ||
"person": { | ||
"type": "object", | ||
"properties": { | ||
"name": { "type": "string" }, | ||
"age": { "type": "integer", "minimum": 0 }, | ||
"address": { "$ref": "#/definitions/address" } | ||
}, | ||
"required": ["name", "age", "address"] | ||
} | ||
}, | ||
"properties": { | ||
"user": { "$ref": "#/definitions/person" }, | ||
"emergencyContact": { "$ref": "#/definitions/person" } | ||
}, | ||
"required": ["user", "emergencyContact"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"definitions": { | ||
"dimension": { | ||
"type": "number", | ||
"minimum": 0 | ||
}, | ||
"rectangle": { | ||
"type": "object", | ||
"properties": { | ||
"width": { "$ref": "#/definitions/dimension" }, | ||
"height": { "$ref": "#/definitions/dimension" } | ||
}, | ||
"required": ["width", "height"] | ||
}, | ||
"circle": { | ||
"type": "object", | ||
"properties": { | ||
"radius": { "$ref": "#/definitions/dimension" } | ||
}, | ||
"required": ["radius"] | ||
} | ||
}, | ||
"properties": { | ||
"shapes": { | ||
"type": "array", | ||
"items": { | ||
"oneOf": [ | ||
{ "$ref": "#/definitions/rectangle" }, | ||
{ "$ref": "#/definitions/circle" } | ||
] | ||
} | ||
} | ||
}, | ||
"required": ["shapes"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"definitions": { | ||
"person": { | ||
"type": "object", | ||
"properties": { | ||
"name": { "type": "string" }, | ||
"children": { | ||
"type": "array", | ||
"items": { "$ref": "#/definitions/person" } | ||
} | ||
}, | ||
"required": ["name"] | ||
} | ||
}, | ||
"properties": { | ||
"familyTree": { "$ref": "#/definitions/person" } | ||
}, | ||
"required": ["familyTree"] | ||
} |