Trait libafl::observers::map::CanTrack

source ·
pub trait CanTrack {
    type WithIndexTracking: CanTrack;
    type WithNoveltiesTracking: CanTrack;

    const INDICES: bool;
    const NOVELTIES: bool;

    // Required methods
    fn track_indices(self) -> Self::WithIndexTracking;
    fn track_novelties(self) -> Self::WithNoveltiesTracking;
}
Expand description

Trait marker which indicates that this MapObserver is tracked for indices or novelties. Implementors of feedbacks similar to crate::feedbacks::MapFeedback may wish to use this to ensure that edge metadata is recorded as is appropriate for the provided observer.

If you get a type constraint failure for your map due to this type being unfulfilled, you must call CanTrack::track_indices or CanTrack::track_novelties at the initialisation site of your map.

This trait allows various components which interact with map metadata to ensure that the information they need is actually recorded by the map feedback. For example, if you are using crate::schedulers::MinimizerScheduler:

use libafl::feedbacks::MaxMapFeedback;
use libafl::observers::{StdMapObserver, CanTrack};
use libafl::schedulers::{IndexesLenTimeMinimizerScheduler, QueueScheduler};

use libafl_bolts::ownedref::OwnedMutSlice;

// initialise your map as necessary
let edges_observer = StdMapObserver::from_ownedref("edges", OwnedMutSlice::from(vec![0u8; 16]));
// inform the feedback to track indices (required by IndexesLenTimeMinimizerScheduler), but not novelties
// this *MUST* be done before it is passed to MaxMapFeedback!
let edges_observer = edges_observer.track_indices();

// init the feedback
let mut feedback = MaxMapFeedback::new(&edges_observer);

let scheduler = IndexesLenTimeMinimizerScheduler::new(&edges_observer, QueueScheduler::new());

MapObserver implementors: see StdMapObserver for an example implementation.

Required Associated Types§

source

type WithIndexTracking: CanTrack

The resulting type of enabling index tracking.

source

type WithNoveltiesTracking: CanTrack

The resulting type of enabling novelty tracking.

Required Associated Constants§

source

const INDICES: bool

Whether indices should be tracked for this MapObserver.

source

const NOVELTIES: bool

Whether novelties should be tracked for this MapObserver.

Required Methods§

source

fn track_indices(self) -> Self::WithIndexTracking

Convert this map observer into one that tracks indices.

source

fn track_novelties(self) -> Self::WithNoveltiesTracking

Convert this map observer into one that tracks novelties.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<M> CanTrack for M
where M: MapObserver,

§

type WithIndexTracking = ExplicitTracking<M, true, false>

§

type WithNoveltiesTracking = ExplicitTracking<M, false, true>

source§

const INDICES: bool = false

source§

const NOVELTIES: bool = false

source§

impl<T, const ITH: bool, const NTH: bool> CanTrack for ExplicitTracking<T, ITH, NTH>