Still fixing CI (#305)
* clippy * clippy on windows * clippy fixes on windows * clippy, fmt * fixed testcases for windows * fixing workspace.yml * testcase no longer fails without clang * fix github dependencies to specific revisions * fix qemu without python * cleanup HookResult
This commit is contained in:
parent
a1bf21465f
commit
5a722994ac
8
.github/workflows/build_and_test.yml
vendored
8
.github/workflows/build_and_test.yml
vendored
@ -10,7 +10,7 @@ env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
book:
|
||||
common:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
@ -32,6 +32,10 @@ jobs:
|
||||
run: cd docs && mdbook build
|
||||
- name: Test the book
|
||||
run: cd docs && mdbook test -L ../target/debug/deps
|
||||
- name: Run tests
|
||||
run: cargo test
|
||||
- name: Test libafl no_std
|
||||
run: cd libafl && cargo test --no-default-features
|
||||
|
||||
|
||||
ubuntu:
|
||||
@ -115,7 +119,7 @@ jobs:
|
||||
- name: Build aarch64-unknown-none
|
||||
run: cd ./fuzzers/baby_no_std && cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release && cd ../..
|
||||
- name: run x86_64 until panic!
|
||||
run: cd ./fuzzers/baby_no_std && cargo +nightly run || test $? -eq 1 || exit 1
|
||||
run: cd ./fuzzers/baby_no_std && cargo +nightly run || test $? -ne 0 || exit 1
|
||||
- name: no_std tests
|
||||
run: cd ./libafl && cargo test --no-default-features
|
||||
build-docker:
|
||||
|
@ -145,12 +145,7 @@ fn fuzz(corpus_dirs: &[PathBuf], objective_dir: PathBuf, broker_port: u16) -> Re
|
||||
// In case the corpus is empty (on first run), reset
|
||||
if state.corpus().count() < 1 {
|
||||
state
|
||||
.load_initial_inputs(
|
||||
&mut fuzzer,
|
||||
&mut executor,
|
||||
&mut restarting_mgr,
|
||||
corpus_dirs,
|
||||
)
|
||||
.load_initial_inputs(&mut fuzzer, &mut executor, &mut restarting_mgr, corpus_dirs)
|
||||
.unwrap_or_else(|_| panic!("Failed to load initial corpus at {:?}", corpus_dirs));
|
||||
println!("We imported {} inputs from disk.", state.corpus().count());
|
||||
}
|
||||
|
@ -20,4 +20,4 @@ debug = true
|
||||
|
||||
[dependencies]
|
||||
libafl = { path = "../../libafl/" }
|
||||
klo-routines = { version = "0.1.0", git = "https://github.com/andreafioraldi/klo-routines.git" }
|
||||
klo-routines = { version = "0.1.0", git = "https://github.com/andreafioraldi/klo-routines.git", rev = "b8e2fb6" }
|
@ -55,7 +55,7 @@ path = "./examples/llmp_test/main.rs"
|
||||
required-features = ["std"]
|
||||
|
||||
[dependencies]
|
||||
tuple_list = { version = "0.1.2", git = "https://github.com/domenukk/tuple_list", branch = "main" }
|
||||
tuple_list = { version = "0.1.3" }
|
||||
hashbrown = { version = "0.9", features = ["serde", "ahash-compile-time-rng"], default-features=false } # A faster hashmap, nostd compatible
|
||||
num = { version = "0.4.0", default-features = false }
|
||||
xxhash-rust = { version = "0.8.2", features = ["xxh3"] } # xxh3 hashing for rust
|
||||
@ -72,12 +72,12 @@ ahash = { version = "0.7", default-features=false, features=["compile-time-rng"]
|
||||
libafl_derive = { version = "0.6.1", optional = true, path = "../libafl_derive" }
|
||||
serde_json = { version = "1.0", optional = true, default-features = false, features = ["alloc"] } # an easy way to debug print SerdeAnyMap
|
||||
miniz_oxide = { version = "0.4.4", optional = true}
|
||||
core_affinity = { version = "0.5", git = "https://github.com/s1341/core_affinity_rs", optional = true }
|
||||
core_affinity = { version = "0.5", git = "https://github.com/s1341/core_affinity_rs", rev = "6648a7a", optional = true }
|
||||
hostname = { version = "^0.3", optional = true } # Is there really no gethostname in the stdlib?
|
||||
rand_core = { version = "0.5.1", optional = true } # This dependency allows us to export our RomuRand as rand::Rng.
|
||||
nix = { version = "0.20.0", optional = true }
|
||||
regex = { version = "1", optional = true }
|
||||
build_id = { version = "0.2.1", git = "https://github.com/domenukk/build_id", branch = "main", optional = true }
|
||||
build_id = { version = "0.2.1", git = "https://github.com/domenukk/build_id", rev = "6a61943", optional = true }
|
||||
uuid = { version = "0.8.2", optional = true, features = ["serde"] }
|
||||
libm = "0.2.1"
|
||||
|
||||
|
@ -182,7 +182,7 @@ where
|
||||
|
||||
/// Launch the broker and the clients and fuzz
|
||||
#[cfg(all(windows, feature = "std"))]
|
||||
#[allow(unused_mut)]
|
||||
#[allow(unused_mut, clippy::match_wild_err_arm)]
|
||||
pub fn launch(&mut self) -> Result<(), Error> {
|
||||
let is_client = std::env::var(_AFL_LAUNCHER_CLIENT);
|
||||
|
||||
|
@ -1867,6 +1867,7 @@ where
|
||||
/// Always returns true on platforms, where no shutdown signal handlers are supported
|
||||
#[inline]
|
||||
#[cfg(not(unix))]
|
||||
#[allow(clippy::unused_self)]
|
||||
fn is_shutting_down(&self) -> bool {
|
||||
false
|
||||
}
|
||||
@ -2471,7 +2472,7 @@ where
|
||||
id: 0,
|
||||
current_recv_map: initial_broker_map,
|
||||
last_msg_recvd: ptr::null_mut(),
|
||||
shmem_provider: shmem_provider.clone(),
|
||||
shmem_provider,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -325,11 +325,7 @@ unsafe extern "system" fn handle_exception(exception_pointers: *mut EXCEPTION_PO
|
||||
let exception_code = ExceptionCode::try_from(code.0).unwrap();
|
||||
// println!("Received {}", exception_code);
|
||||
let ret = internal_handle_exception(exception_code, exception_pointers);
|
||||
if let Some(prev_handler) = PREVIOUS_HANDLER {
|
||||
prev_handler(exception_pointers)
|
||||
} else {
|
||||
ret
|
||||
}
|
||||
PREVIOUS_HANDLER.map_or(ret, |prev_handler| prev_handler(exception_pointers))
|
||||
}
|
||||
|
||||
type NativeSignalHandlerType = unsafe extern "C" fn(i32);
|
||||
|
@ -67,7 +67,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
impl<EM, I, S, Z, T, OT> HasObservers<I, OT, S> for CommandExecutor<EM, I, S, Z, T, OT>
|
||||
where
|
||||
I: Input,
|
||||
@ -88,8 +88,8 @@ where
|
||||
/// A `CommandConfigurator` takes care of creating and spawning a [`std::process::Command`] for the [`CommandExecutor`].
|
||||
/// # Example
|
||||
/// ```
|
||||
/// # use std::{io::Write, process::{Stdio, Command, Child}};
|
||||
/// # use libafl::{Error, inputs::{Input, HasTargetBytes}, executors::{Executor, command::CommandConfigurator}};
|
||||
/// use std::{io::Write, process::{Stdio, Command, Child}};
|
||||
/// use libafl::{Error, inputs::{Input, HasTargetBytes}, executors::{Executor, command::CommandConfigurator}};
|
||||
/// struct MyExecutor;
|
||||
///
|
||||
/// impl<EM, I: Input + HasTargetBytes, S, Z> CommandConfigurator<EM, I, S, Z> for MyExecutor {
|
||||
@ -117,7 +117,7 @@ where
|
||||
/// MyExecutor.into_executor(())
|
||||
/// }
|
||||
/// ```
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
pub trait CommandConfigurator<EM, I: Input, S, Z>: Sized {
|
||||
fn spawn_child(
|
||||
&mut self,
|
||||
|
@ -752,16 +752,40 @@ mod windows_exception_handler {
|
||||
Z: HasObjective<I, OF, S>,
|
||||
{
|
||||
// Have we set a timer_before?
|
||||
match (data.timer_queue as *mut HANDLE).as_mut() {
|
||||
Some(x) => {
|
||||
if let Some(x) = (data.timer_queue as *mut HANDLE).as_mut() {
|
||||
windows_delete_timer_queue(*x);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
println!("Crashed with {}", code);
|
||||
if !data.current_input_ptr.is_null() {
|
||||
if data.current_input_ptr.is_null() {
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
println!("Double crash\n");
|
||||
let crash_addr = exception_pointers
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.ExceptionRecord
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.ExceptionAddress as usize;
|
||||
|
||||
println!(
|
||||
"We crashed at addr 0x{:x}, but are not in the target... Bug in the fuzzer? Exiting.",
|
||||
crash_addr
|
||||
);
|
||||
}
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
println!("Type QUIT to restart the child");
|
||||
let mut line = String::new();
|
||||
while line.trim() != "QUIT" {
|
||||
std::io::stdin().read_line(&mut line).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO tell the parent to not restart
|
||||
} else {
|
||||
let state = (data.state_ptr as *mut S).as_mut().unwrap();
|
||||
let event_mgr = (data.event_mgr_ptr as *mut EM).as_mut().unwrap();
|
||||
let fuzzer = (data.fuzzer_ptr as *mut Z).as_mut().unwrap();
|
||||
@ -770,7 +794,7 @@ mod windows_exception_handler {
|
||||
#[cfg(feature = "std")]
|
||||
println!("Child crashed!");
|
||||
#[cfg(feature = "std")]
|
||||
let _ = stdout().flush();
|
||||
drop(stdout().flush());
|
||||
|
||||
let input = (data.current_input_ptr as *const I).as_ref().unwrap();
|
||||
// Make sure we don't crash in the crash handler forever.
|
||||
@ -810,46 +834,17 @@ mod windows_exception_handler {
|
||||
event_mgr.await_restart_safe();
|
||||
#[cfg(feature = "std")]
|
||||
println!("Bye!");
|
||||
|
||||
}
|
||||
ExitProcess(1);
|
||||
} else {
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
println!("Double crash\n");
|
||||
let crash_addr = exception_pointers
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.ExceptionRecord
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.ExceptionAddress as usize;
|
||||
|
||||
println!(
|
||||
"We crashed at addr 0x{:x}, but are not in the target... Bug in the fuzzer? Exiting.",
|
||||
crash_addr
|
||||
);
|
||||
}
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
println!("Type QUIT to restart the child");
|
||||
let mut line = String::new();
|
||||
while line.trim() != "QUIT" {
|
||||
std::io::stdin().read_line(&mut line).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO tell the parent to not restart
|
||||
ExitProcess(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
type WAITORTIMERCALLBACK = unsafe extern "system" fn(param0: *mut c_void, param1: u8);
|
||||
type WaitOrTimerCallback = unsafe extern "system" fn(param0: *mut c_void, param1: u8);
|
||||
|
||||
#[cfg(windows)]
|
||||
pub trait HasTimeoutHandler {
|
||||
unsafe fn timeout_handler(&self) -> WAITORTIMERCALLBACK;
|
||||
fn timeout_handler(&self) -> WaitOrTimerCallback;
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
@ -859,9 +854,10 @@ where
|
||||
I: Input,
|
||||
OT: ObserversTuple<I, S>,
|
||||
{
|
||||
/// the timeout handler
|
||||
#[inline]
|
||||
unsafe fn timeout_handler(&self) -> WAITORTIMERCALLBACK {
|
||||
let func: WAITORTIMERCALLBACK = transmute(self.timeout_handler);
|
||||
fn timeout_handler(&self) -> WaitOrTimerCallback {
|
||||
let func: WaitOrTimerCallback = unsafe { transmute(self.timeout_handler) };
|
||||
func
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,11 @@ pub use inprocess::InProcessExecutor;
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
pub use inprocess::InProcessForkExecutor;
|
||||
|
||||
/// Timeout executor.
|
||||
/// Not possible on `no-std` Windows or `no-std`, but works for unix
|
||||
#[cfg(any(unix, feature = "std"))]
|
||||
pub mod timeout;
|
||||
#[cfg(any(unix, feature = "std"))]
|
||||
pub use timeout::TimeoutExecutor;
|
||||
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
@ -22,9 +26,9 @@ pub use shadow::ShadowExecutor;
|
||||
pub mod with_observers;
|
||||
pub use with_observers::WithObservers;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
pub mod command;
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
pub use command::CommandExecutor;
|
||||
|
||||
use crate::{
|
||||
|
@ -10,7 +10,7 @@ use crate::{
|
||||
Error,
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, feature = "std"))]
|
||||
use crate::executors::inprocess::{HasTimeoutHandler, GLOBAL_STATE};
|
||||
|
||||
#[cfg(unix)]
|
||||
@ -18,7 +18,7 @@ use core::{mem::zeroed, ptr::null_mut};
|
||||
#[cfg(unix)]
|
||||
use libc::c_int;
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, feature = "std"))]
|
||||
use crate::bolts::bindings::Windows::Win32::{
|
||||
Foundation::HANDLE,
|
||||
System::Threading::{
|
||||
@ -27,7 +27,7 @@ use crate::bolts::bindings::Windows::Win32::{
|
||||
},
|
||||
};
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, feature = "std"))]
|
||||
use core::{ffi::c_void, ptr::write_volatile};
|
||||
|
||||
#[repr(C)]
|
||||
@ -61,7 +61,7 @@ pub fn unix_remove_timeout() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, feature = "std"))]
|
||||
pub fn windows_delete_timer_queue(timer_queue: HANDLE) {
|
||||
unsafe {
|
||||
DeleteTimerQueueEx(timer_queue, HANDLE::NULL);
|
||||
@ -128,7 +128,7 @@ impl<E> TimeoutExecutor<E> {
|
||||
unsafe {
|
||||
let code = DeleteTimerQueueTimer(self.timer_queue, self.ph_new_timer, HANDLE::NULL);
|
||||
if !code.as_bool() {
|
||||
return Err(Error::Unknown(format!("DeleteTimerQueueTimer failed.")));
|
||||
return Err(Error::Unknown("DeleteTimerQueueTimer failed.".to_string()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -296,10 +296,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_clang_version() {
|
||||
ClangWrapper::new()
|
||||
if let Err(res) = ClangWrapper::new()
|
||||
.from_args(&["my-clang", "-v"])
|
||||
.unwrap()
|
||||
.run()
|
||||
.unwrap();
|
||||
{
|
||||
println!("Ignored error {:?} - clang is probably not installed.", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ libloading = "0.7.0"
|
||||
rangemap = "0.1.10"
|
||||
frida-gum-sys = { version = "0.3", features = [ "auto-download", "event-sink", "invocation-listener"] }
|
||||
frida-gum = { version = "0.5.2", features = [ "auto-download", "backtrace", "event-sink", "invocation-listener"] }
|
||||
core_affinity = { version = "0.5", git = "https://github.com/s1341/core_affinity_rs" }
|
||||
core_affinity = { version = "0.5", git = "https://github.com/s1341/core_affinity_rs", rev = "6648a7a" }
|
||||
regex = "1.4"
|
||||
dynasmrt = "1.0.1"
|
||||
capstone = "0.8.0"
|
||||
|
@ -38,6 +38,7 @@ impl IntoPy<PyObject> for MmapPerms {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[cfg(feature = "python")]
|
||||
#[cfg_attr(feature = "python", pyclass)]
|
||||
#[cfg_attr(feature = "python", derive(FromPyObject))]
|
||||
pub struct SyscallHookResult {
|
||||
@ -45,27 +46,9 @@ pub struct SyscallHookResult {
|
||||
pub skip_syscall: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "python")]
|
||||
#[pymethods]
|
||||
impl SyscallHookResult {
|
||||
#[new]
|
||||
#[must_use]
|
||||
pub fn new(value: Option<u64>) -> Self {
|
||||
value.map_or(
|
||||
Self {
|
||||
retval: 0,
|
||||
skip_syscall: false,
|
||||
},
|
||||
|v| Self {
|
||||
retval: v,
|
||||
skip_syscall: true,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "python"))]
|
||||
#[cfg_attr(feature = "python", pymethods)]
|
||||
impl SyscallHookResult {
|
||||
#[cfg_attr(feature = "python", new)]
|
||||
#[must_use]
|
||||
pub fn new(value: Option<u64>) -> Self {
|
||||
value.map_or(
|
||||
|
13
scripts/clippy.ps1
Normal file
13
scripts/clippy.ps1
Normal file
@ -0,0 +1,13 @@
|
||||
cargo clippy --all --all-features --tests -- `
|
||||
-D clippy::pedantic `
|
||||
-W clippy::similar_names `
|
||||
-A clippy::type_repetition_in_bounds `
|
||||
-A clippy::missing-errors-doc `
|
||||
-A clippy::cast-possible-truncation `
|
||||
-A clippy::used-underscore-binding `
|
||||
-A clippy::ptr-as-ptr `
|
||||
-A clippy::missing-panics-doc `
|
||||
-A clippy::missing-docs-in-private-items `
|
||||
-A clippy::unseparated-literal-suffix `
|
||||
-A clippy::module-name-repetitions `
|
||||
-A clippy::unreadable-literal
|
Loading…
x
Reference in New Issue
Block a user