Skip to content

Commit

Permalink
add MapFeedbackMetadata for interesting testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Bounti committed Jun 10, 2024
1 parent f8cbd55 commit 87e70ef
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions libpresifuzz_feedbacks/src/verdi_feedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ use std::process::Command;
use std::path::Path;
use libafl::inputs::Input;

use libafl::prelude::MapNoveltiesMetadata;

Check warning

Code scanning / clippy

unused import: libafl::prelude::MapNoveltiesMetadata Warning

unused import: libafl::prelude::MapNoveltiesMetadata

Check warning

Code scanning / clippy

unused import: libafl::prelude::MapNoveltiesMetadata Warning

unused import: libafl::prelude::MapNoveltiesMetadata
use libafl::prelude::MapFeedbackMetadata;
use libafl::state::HasMetadata;
use libafl::prelude::HasNamedMetadata;

use libpresifuzz_observers::verdi_observer::VerdiShMapObserver as VerdiObserver;

/// Nop feedback that annotates execution time in the new testcase, if any
Expand All @@ -47,8 +52,14 @@ pub struct VerdiFeedback<const N: usize>

impl<S, const N: usize> Feedback<S> for VerdiFeedback<N>
where
S: UsesInput + State,
S: UsesInput + State + HasNamedMetadata,
{
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
// Initialize `MapFeedbackMetadata` with an empty vector and add it to the state.
// The `MapFeedbackMetadata` would be resized on-demand in `is_interesting`
state.add_named_metadata(MapFeedbackMetadata::<u32>::default(), &self.name);
Ok(())
}

#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
Expand Down Expand Up @@ -207,13 +218,16 @@ where
#[inline]
fn append_metadata<OT>(
&mut self,
_state: &mut S,
_observers: &OT,
_testcase: &mut Testcase<S::Input>,
state: &mut S,

Check warning

Code scanning / clippy

unused variable: state Warning

unused variable: state

Check warning

Code scanning / clippy

unused variable: state Warning

unused variable: state
observers: &OT,

Check warning

Code scanning / clippy

unused variable: observers Warning

unused variable: observers

Check warning

Code scanning / clippy

unused variable: observers Warning

unused variable: observers
testcase: &mut Testcase<S::Input>,
) -> Result<(), Error>
where
OT: ObserversTuple<S>,
{
let metadata = MapFeedbackMetadata::<u32>::with_history_map(self.history.clone());
testcase.metadata_map_mut().insert(metadata);

Ok(())
}

Expand Down

0 comments on commit 87e70ef

Please sign in to comment.