mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
Merge pull request #503 from meilisearch/improve-flatten-fuzzer
Improve the fuzzer of the flatten crate
This commit is contained in:
commit
8d15ae37a1
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flatten_serde_json-fuzz"
|
name = "flatten-serde-json-fuzz"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
authors = ["Automatically generated"]
|
authors = ["Automatically generated"]
|
||||||
publish = false
|
publish = false
|
||||||
@ -11,8 +11,9 @@ cargo-fuzz = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
libfuzzer-sys = "0.4"
|
libfuzzer-sys = "0.4"
|
||||||
arbitrary-json = "0.1.1"
|
arbitrary-json = "0.1.1"
|
||||||
|
json-depth-checker = { path = "../../json-depth-checker" }
|
||||||
|
|
||||||
[dependencies.flatten_serde_json]
|
[dependencies.flatten-serde-json]
|
||||||
path = ".."
|
path = ".."
|
||||||
|
|
||||||
# Prevent this from interfering with workspaces
|
# Prevent this from interfering with workspaces
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#![no_main]
|
#![no_main]
|
||||||
use arbitrary_json::ArbitraryObject;
|
use arbitrary_json::ArbitraryObject;
|
||||||
use flatten_serde_json::flatten;
|
use flatten_serde_json::flatten;
|
||||||
|
use json_depth_checker::should_flatten_from_value;
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
|
|
||||||
fuzz_target!(|object: ArbitraryObject| {
|
fuzz_target!(|object: ArbitraryObject| {
|
||||||
let _ = flatten(&object);
|
let object = flatten(&object);
|
||||||
|
if !object.is_empty() {
|
||||||
|
assert!(object.values().any(|value| !should_flatten_from_value(value)));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user