Coverage Report

Created: 2026-06-30 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/surrealdb/fuzz/fuzz_targets/fuzz_executor.rs
Line
Count
Source
1
#![no_main]
2
3
use std::time::Duration;
4
5
use libfuzzer_sys::fuzz_target;
6
7
/// Per-command wall-clock bound, so a pathological input that bypasses the
8
/// engine's own deadline still can't stall the fuzzer.
9
const COMMAND_TIMEOUT: Duration = Duration::from_secs(5);
10
11
fuzz_target!(|commands: &str| {
12
  let commands: Vec<&str> = commands.split_inclusive(";").collect();
13
  let blacklisted_command_strings = ["sleep", "SLEEP"];
14
15
  use surrealdb_core::{dbs::Session, kvs::Datastore};
16
  let max_commands = 500;
17
  if commands.len() > max_commands {
18
    return;
19
  }
20
21
164
  tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
22
164
    let dbs = Datastore::new("memory").await.unwrap();
23
164
    let ses = Session::owner().with_ns("test").with_db("test");
24
3.50k
    for command in commands.iter() {
25
7.01k
      for blacklisted_string in blacklisted_command_strings.iter() {
26
7.01k
        if command.contains(blacklisted_string) {
27
0
          return;
28
7.01k
        }
29
      }
30
3.50k
      let _ = tokio::time::timeout(COMMAND_TIMEOUT, dbs.execute(command, &ses, None)).await;
31
    }
32
164
  })
33
});