mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-07-26 07:58:14 +00:00
Add fuzing for Key CRDT (#1444)
This has duplicated changes with #1442 that will likely conflict and need rebase. Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1444 Reviewed-by: Alex <lx@deuxfleurs.fr>
This commit is contained in:
@@ -50,3 +50,10 @@ path = "fuzz_targets/admin_api_token_crdt.rs"
|
||||
test = false
|
||||
doc = false
|
||||
bench = false
|
||||
|
||||
[[bin]]
|
||||
name = "key_crdt"
|
||||
path = "fuzz_targets/key_crdt.rs"
|
||||
test = false
|
||||
doc = false
|
||||
bench = false
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#![no_main]
|
||||
|
||||
use garage_fuzz::check_crdt_laws;
|
||||
use garage_model::key_table::{Key, KeyParams};
|
||||
use garage_model::permission::BucketKeyPerm;
|
||||
use garage_util::crdt;
|
||||
use garage_util::data::Uuid;
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
type Input = (
|
||||
bool,
|
||||
crdt::Lww<String>,
|
||||
crdt::Lww<Option<u64>>,
|
||||
crdt::Lww<bool>,
|
||||
crdt::Map<Uuid, BucketKeyPerm>,
|
||||
crdt::LwwMap<String, Option<Uuid>>,
|
||||
);
|
||||
|
||||
fn make(input: Input) -> Key {
|
||||
let (deleted, name, expiration, allow_create_bucket, authorized_buckets, local_aliases) = input;
|
||||
let state = if deleted {
|
||||
crdt::Deletable::Deleted
|
||||
} else {
|
||||
crdt::Deletable::present(KeyParams {
|
||||
created: None,
|
||||
secret_key: String::new(),
|
||||
name,
|
||||
expiration,
|
||||
allow_create_bucket,
|
||||
authorized_buckets,
|
||||
local_aliases,
|
||||
})
|
||||
};
|
||||
Key {
|
||||
key_id: String::new(),
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
fuzz_target!(|inputs: (Input, Input, Input)| {
|
||||
let (a, b, c) = inputs;
|
||||
check_crdt_laws(make(a), make(b), make(c));
|
||||
});
|
||||
Reference in New Issue
Block a user