2023-04-30 07:49:03 +00:00
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
use libfuzzer_sys::fuzz_target;
|
|
|
|
|
2023-05-22 06:40:04 +00:00
|
|
|
fuzz_target!(|commands: &str| {
|
|
|
|
let commands: Vec<&str> = commands.split_inclusive(";").collect();
|
2023-05-19 21:34:27 +00:00
|
|
|
let blacklisted_command_strings = ["sleep", "SLEEP"];
|
2023-04-30 07:49:03 +00:00
|
|
|
|
|
|
|
use surrealdb::{dbs::Session, kvs::Datastore};
|
|
|
|
let max_commands = 500;
|
|
|
|
if commands.len() > max_commands {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-22 06:40:04 +00:00
|
|
|
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;
|
2023-04-30 07:49:03 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-22 06:40:04 +00:00
|
|
|
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`.
|
|
|
|
}
|
|
|
|
})
|
2023-04-30 07:49:03 +00:00
|
|
|
});
|