Skip to content

Commit

Permalink
Add rustfmt.toml (#722)
Browse files Browse the repository at this point in the history
* add `rustfmt.toml`

* format fix

Co-authored-by: syheliel <[email protected]>
  • Loading branch information
syheliel and syheliel authored Aug 12, 2022
1 parent faca7b9 commit 2504b6d
Show file tree
Hide file tree
Showing 165 changed files with 926 additions and 857 deletions.
1 change: 0 additions & 1 deletion fuzzers/baby_fuzzer/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::path::PathBuf;

#[cfg(windows)]
use std::ptr::write_volatile;

Expand Down
8 changes: 3 additions & 5 deletions fuzzers/baby_fuzzer_gramatron/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::io::Read;
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{
fs,
io::BufReader,
io::{BufReader, Read},
path::{Path, PathBuf},
};

#[cfg(windows)]
use std::ptr::write_volatile;

use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
corpus::{InMemoryCorpus, OnDiskCorpus},
Expand Down
4 changes: 1 addition & 3 deletions fuzzers/baby_fuzzer_grimoire/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::io::Read;
use std::{fs, path::PathBuf};

#[cfg(windows)]
use std::ptr::write_volatile;
use std::{fs, io::Read, path::PathBuf};

use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
Expand Down
1 change: 0 additions & 1 deletion fuzzers/baby_fuzzer_nautilus/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::path::PathBuf;

#[cfg(windows)]
use std::ptr::write_volatile;

Expand Down
4 changes: 1 addition & 3 deletions fuzzers/baby_fuzzer_tokens/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::io::Read;
use std::{fs, path::PathBuf};

#[cfg(windows)]
use std::ptr::write_volatile;
use std::{fs, io::Read, path::PathBuf};

use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
Expand Down
1 change: 0 additions & 1 deletion fuzzers/baby_fuzzer_with_forkexecutor/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::path::PathBuf;

#[cfg(windows)]
use std::ptr::write_volatile;

Expand Down
11 changes: 5 additions & 6 deletions fuzzers/baby_no_std/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
// Embedded needs alloc error handlers which only work on nightly right now...
#![cfg_attr(not(any(windows, unix)), feature(default_alloc_error_handler))]

#[cfg(not(any(windows, unix)))]
use core::panic::PanicInfo;

#[cfg(any(windows, unix))]
use cstr_core::CString;
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
corpus::InMemoryCorpus,
Expand All @@ -20,14 +25,8 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};

#[cfg(any(windows, unix))]
use cstr_core::CString;
#[cfg(any(windows, unix))]
use libc::{c_char, printf};

#[cfg(not(any(windows, unix)))]
use core::panic::PanicInfo;
use static_alloc::Bump;

#[global_allocator]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::path::PathBuf;

use libafl::bolts::shmem::ShMemProvider;
use libafl::bolts::AsSlice;
use libafl::observers::ConstMapObserver;
use libafl::{
bolts::{
current_nanos,
rands::StdRand,
shmem::{ShMem, StdShMemProvider},
shmem::{ShMem, ShMemProvider, StdShMemProvider},
tuples::tuple_list,
AsSlice,
},
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
Expand All @@ -20,13 +18,12 @@ use libafl::{
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::BacktraceObserver,
observers::{BacktraceObserver, ConstMapObserver},
schedulers::QueueScheduler,
stages::mutational::StdMutationalStage,
state::StdState,
};
use libc::c_int;
use libc::c_uchar;
use libc::{c_int, c_uchar};
extern crate libc;

extern "C" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use std::path::PathBuf;

use libafl::bolts::AsSlice;
use libafl::executors::InProcessExecutor;
use libafl::observers::ConstMapObserver;
use libafl::{
bolts::{current_nanos, rands::StdRand, tuples::tuple_list},
bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice},
corpus::{InMemoryCorpus, OnDiskCorpus},
events::SimpleEventManager,
executors::InProcessExecutor,
feedback_and,
feedbacks::{CrashFeedback, MaxMapFeedback, NewHashFeedback},
fuzzer::{Fuzzer, StdFuzzer},
generators::RandPrintablesGenerator,
inputs::{BytesInput, HasTargetBytes},
monitors::SimpleMonitor,
mutators::scheduled::{havoc_mutations, StdScheduledMutator},
observers::BacktraceObserver,
observers::{BacktraceObserver, ConstMapObserver},
schedulers::QueueScheduler,
stages::mutational::StdMutationalStage,
state::StdState,
Expand Down
15 changes: 8 additions & 7 deletions fuzzers/backtrace_baby_fuzzers/command_executor/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{
io::Write,
path::PathBuf,
process::{Child, Command, Stdio},
};

use libafl::{
bolts::{
current_nanos,
Expand All @@ -22,13 +30,6 @@ use libafl::{
state::StdState,
Error,
};
#[cfg(windows)]
use std::ptr::write_volatile;
use std::{
io::Write,
path::PathBuf,
process::{Child, Command, Stdio},
};

#[allow(clippy::similar_names)]
pub fn main() {
Expand Down
8 changes: 5 additions & 3 deletions fuzzers/backtrace_baby_fuzzers/forkserver_executor/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::env;
use std::path::Path;
use std::process::{exit, Command};
use std::{
env,
path::Path,
process::{exit, Command},
};

const AFL_URL: &str = "https://github.com/AFLplusplus/AFLplusplus";

Expand Down
12 changes: 6 additions & 6 deletions fuzzers/backtrace_baby_fuzzers/forkserver_executor/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::path::PathBuf;

#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;
#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;
use libafl::{
bolts::{
current_nanos,
Expand All @@ -21,12 +27,6 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::StdState,
};
use std::path::PathBuf;

#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;
#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;

#[allow(clippy::similar_names)]
pub fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::path::PathBuf;

#[cfg(windows)]
use std::ptr::write_volatile;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::path::PathBuf;

#[cfg(windows)]
use std::ptr::write_volatile;

Expand Down
8 changes: 5 additions & 3 deletions fuzzers/forkserver_simple/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::env;
use std::path::Path;
use std::process::{exit, Command};
use std::{
env,
path::Path,
process::{exit, Command},
};

const AFL_URL: &str = "https://github.com/AFLplusplus/AFLplusplus";

Expand Down
15 changes: 7 additions & 8 deletions fuzzers/forkserver_simple/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
use clap::{Arg, Command};
use core::time::Duration;
use std::path::PathBuf;

use clap::{Arg, Command};
#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;
#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;
use libafl::{
bolts::{
current_nanos,
Expand All @@ -23,13 +29,6 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
};
use nix::sys::signal::Signal;
use std::path::PathBuf;

#[cfg(target_vendor = "apple")]
use libafl::bolts::shmem::UnixShMemProvider;

#[cfg(not(target_vendor = "apple"))]
use libafl::bolts::shmem::StdShMemProvider;

#[allow(clippy::similar_names)]
pub fn main() {
Expand Down
21 changes: 9 additions & 12 deletions fuzzers/frida_libpng/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

use frida_gum::Gum;
use std::path::PathBuf;

use frida_gum::Gum;
use libafl::{
bolts::{
cli::{parse_args, FuzzerOptions},
Expand All @@ -27,28 +27,25 @@ use libafl::{
monitors::MultiMonitor,
mutators::{
scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
token_mutations::I2SRandReplace,
token_mutations::Tokens,
token_mutations::{I2SRandReplace, Tokens},
},
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler},
stages::{ShadowTracingStage, StdMutationalStage},
state::{HasCorpus, HasMetadata, StdState},
Error,
};

use libafl_frida::{
coverage_rt::CoverageRuntime, coverage_rt::MAP_SIZE, executor::FridaInProcessExecutor,
helper::FridaInstrumentationHelper,
};

#[cfg(unix)]
use libafl_frida::asan::asan_rt::AsanRuntime;
use libafl_targets::cmplog::{CmpLogObserver, CMPLOG_MAP};

#[cfg(unix)]
use libafl_frida::asan::errors::{AsanErrorsFeedback, AsanErrorsObserver, ASAN_ERRORS};
use libafl_frida::cmplog_rt::CmpLogRuntime;
use libafl_frida::{
cmplog_rt::CmpLogRuntime,
coverage_rt::{CoverageRuntime, MAP_SIZE},
executor::FridaInProcessExecutor,
helper::FridaInstrumentationHelper,
};
use libafl_targets::cmplog::{CmpLogObserver, CMPLOG_MAP};

/// The main fn, usually parsing parameters, and starting the fuzzer
pub fn main() {
Expand Down
3 changes: 2 additions & 1 deletion fuzzers/fuzzbench/src/bin/libafl_cc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};
use std::env;

use libafl_cc::{ClangWrapper, CompilerWrapper, LLVMPasses};

pub fn main() {
let mut args: Vec<String> = env::args().collect();
if args.len() > 1 {
Expand Down
11 changes: 5 additions & 6 deletions fuzzers/fuzzbench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

use clap::{Arg, Command};
use core::{cell::RefCell, time::Duration};
#[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{
env,
Expand All @@ -17,6 +14,7 @@ use std::{
process,
};

use clap::{Arg, Command};
use libafl::{
bolts::{
current_nanos, current_time,
Expand Down Expand Up @@ -49,13 +47,14 @@ use libafl::{
state::{HasCorpus, HasMetadata, StdState},
Error,
};
#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
use libafl_targets::{
libfuzzer_initialize, libfuzzer_test_one_input, CmpLogObserver, CMPLOG_MAP, EDGES_MAP,
MAX_EDGES_NUM,
};

#[cfg(target_os = "linux")]
use libafl_targets::autotokens;
#[cfg(unix)]
use nix::{self, unistd::dup};

/// The fuzzer main (as `no_mangle` C function)
#[no_mangle]
Expand Down
6 changes: 3 additions & 3 deletions fuzzers/fuzzbench_fork_qemu/src/fuzzer.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! A singlethreaded QEMU fuzzer that can auto-restart.
use clap::{Arg, Command};
use core::cell::RefCell;
#[cfg(unix)]
use nix::{self, unistd::dup};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::{
env,
Expand All @@ -14,6 +11,7 @@ use std::{
process,
};

use clap::{Arg, Command};
use libafl::{
bolts::{
current_nanos, current_time,
Expand Down Expand Up @@ -55,6 +53,8 @@ use libafl_qemu::{
hooks::QemuHooks,
MmapPerms, QemuForkExecutor, Regs,
};
#[cfg(unix)]
use nix::{self, unistd::dup};

/// The fuzzer main
pub fn main() {
Expand Down
Loading

0 comments on commit 2504b6d

Please sign in to comment.