Fix bug that prevented the fuzzers from using dictionaries properly ()

This commit is contained in:
Nathaniel Brough 2023-05-21 23:40:04 -07:00 committed by GitHub
parent 31af5dd4d3
commit 1de753c3ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 21 deletions
lib/fuzz

5
lib/fuzz/Cargo.lock generated
View file

@ -442,11 +442,10 @@ dependencies = [
[[package]]
name = "dmp"
version = "0.1.3"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1796e147190351ab441586c68b74494b18a70b0e39fb9bf8e84e38635bf4c92a"
checksum = "bfaa1135a34d26e5cc5b4927a8935af887d4f30a5653a797c33b9a4222beb6d9"
dependencies = [
"regex",
"urlencoding",
]

View file

@ -2,7 +2,8 @@
use libfuzzer_sys::fuzz_target;
fuzz_target!(|commands: Vec<&str>| {
fuzz_target!(|commands: &str| {
let commands: Vec<&str> = commands.split_inclusive(";").collect();
let blacklisted_command_strings = ["sleep", "SLEEP"];
use surrealdb::{dbs::Session, kvs::Datastore};
@ -11,23 +12,19 @@ fuzz_target!(|commands: Vec<&str>| {
return;
}
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(async {
let dbs = Datastore::new("memory").await.unwrap();
let ses = Session::for_kv().with_ns("test").with_db("test");
for command in commands.iter() {
for blacklisted_string in blacklisted_command_strings.iter() {
if command.contains(blacklisted_string) {
return;
}
tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
let dbs = Datastore::new("memory").await.unwrap();
let ses = Session::for_kv().with_ns("test").with_db("test");
for command in commands.iter() {
for blacklisted_string in blacklisted_command_strings.iter() {
if command.contains(blacklisted_string) {
return;
}
let _ignore_the_result = dbs.execute(command, &ses, None, false).await;
// TODO: Add some async timeout and `tokio::select!` between it and the query
// Alternatively, wrap future in `tokio::time::Timeout`.
}
})
let _ignore_the_result = dbs.execute(command, &ses, None, false).await;
// TODO: Add some async timeout and `tokio::select!` between it and the query
// Alternatively, wrap future in `tokio::time::Timeout`.
}
})
});