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();
|
2023-07-29 18:47:25 +00:00
|
|
|
let ses = Session::owner().with_ns("test").with_db("test");
|
2023-05-22 06:40:04 +00:00
|
|
|
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-07-05 21:26:13 +00:00
|
|
|
let _ignore_the_result = dbs.execute(command, &ses, None).await;
|
2023-05-22 06:40:04 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
});
|