From 84beb61c3f951519118441c32933b046519b9603 Mon Sep 17 00:00:00 2001 From: lenawanel <115283664+lenawanel@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:14:37 +0200 Subject: [PATCH] remove `libafl/src/feedbacks/owned.rs` (#1508) fixes #1504 --- libafl/src/feedbacks/owned.rs | 188 ---------------------------------- 1 file changed, 188 deletions(-) delete mode 100644 libafl/src/feedbacks/owned.rs diff --git a/libafl/src/feedbacks/owned.rs b/libafl/src/feedbacks/owned.rs deleted file mode 100644 index c312e3771e..0000000000 --- a/libafl/src/feedbacks/owned.rs +++ /dev/null @@ -1,188 +0,0 @@ -//! A dynamic collection of owned FeedbackStates - -use alloc::{boxed::Box, vec::Vec}; -use libafl_bolts::anymap::AsAny; - -use crate::{ - feedbacks::{FeedbackState, FeedbackStateTuple}, - Error, -}; - -/// Combine `FeedbackState` and `AsAny` -pub trait AnyFeedbackState: FeedbackState + AsAny {} - -/// An owned list of `FeedbackState` trait objects -#[derive(Default)] -#[allow(missing_debug_implementations)] -pub struct FeedbackStatesOwnedList { - /// The named trait objects map - pub list: Vec>, -} - -impl FeedbackStatesTuple for FeedbackStatesOwnedList { - fn perform_all( - &mut self, - fuzzer: &mut Z, - executor: &mut E, - state: &mut S, - manager: &mut EM, - corpus_idx: usize, - ) -> Result<(), Error> { - for s in &mut self.list { - s.perform(fuzzer, executor, state, manager, corpus_idx)?; - } - Ok(()) - } -} - -impl FeedbackStatesOwnedList { - /// Create a new instance - #[must_use] - pub fn new(list: Vec>) -> Self { - Self { list } - } -} - -#[cfg(feature = "python")] -/// `FeedbackStatesOwnedList` Python bindings -pub mod pybind { - use crate::stages::owned::FeedbackStatesOwnedList; - use pyo3::prelude::*; - - macro_rules! define_python_stage_owned_list { - ($struct_name:ident, $py_name:tt, $my_std_state_type_name: ident, $my_std_fuzzer_type_name: ident, $event_manager_name: ident, - $executor_name: ident, $stage_name: ident) => { - use crate::events::pybind::$event_manager_name; - use crate::executors::pybind::$executor_name; - use crate::fuzzer::pybind::$my_std_fuzzer_type_name; - use crate::stages::pybind::$stage_name; - use crate::state::pybind::$my_std_state_type_name; - #[pyclass(unsendable, name = $py_name)] - - /// Python class for FeedbackStatesOwnedList - #[allow(missing_debug_implementations)] - pub struct $struct_name { - /// Rust wrapped FeedbackStatesOwnedList object - pub stages_owned_list: FeedbackStatesOwnedList< - $executor_name, - $event_manager_name, - $my_std_state_type_name, - $my_std_fuzzer_type_name, - >, - } - - #[pymethods] - impl $struct_name { - //TODO: Add new from list - #[new] - fn new(stage: &$stage_name) -> Self { - // TODO: Be safe - unsafe { - Self { - stages_owned_list: FeedbackStatesOwnedList { - list: vec![Box::new(std::mem::transmute_copy::< - $stage_name, - $stage_name, - >(stage))], - }, - } - } - } - } - }; - } - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListI8, - "FeedbackStatesOwnedListI8", - MyStdStateI8, - MyStdFuzzerI8, - PythonEventManagerI8, - PythonExecutorI8, - PythonFeedbackStateI8 - ); - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListI16, - "FeedbackStatesOwnedListI16", - MyStdStateI16, - MyStdFuzzerI16, - PythonEventManagerI16, - PythonExecutorI16, - PythonFeedbackStateI16 - ); - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListI32, - "FeedbackStatesOwnedListI32", - MyStdStateI32, - MyStdFuzzerI32, - PythonEventManagerI32, - PythonExecutorI32, - PythonFeedbackStateI32 - ); - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListI64, - "FeedbackStatesOwnedListI64", - MyStdStateI64, - MyStdFuzzerI64, - PythonEventManagerI64, - PythonExecutorI64, - PythonFeedbackStateI64 - ); - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListU8, - "FeedbackStatesOwnedListU8", - MyStdStateU8, - MyStdFuzzerU8, - PythonEventManagerU8, - PythonExecutorU8, - PythonFeedbackStateU8 - ); - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListU16, - "FeedbackStatesOwnedListU16", - MyStdStateU16, - MyStdFuzzerU16, - PythonEventManagerU16, - PythonExecutorU16, - PythonFeedbackStateU16 - ); - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListU32, - "FeedbackStatesOwnedListU32", - MyStdStateU32, - MyStdFuzzerU32, - PythonEventManagerU32, - PythonExecutorU32, - PythonFeedbackStateU32 - ); - - define_python_stage_owned_list!( - PythonFeedbackStatesOwnedListU64, - "FeedbackStatesOwnedListU64", - MyStdStateU64, - MyStdFuzzerU64, - PythonEventManagerU64, - PythonExecutorU64, - PythonFeedbackStateU64 - ); - - /// Register the classes to the python module - pub fn register(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - Ok(()) - } -}