Update exec counts in objective (#1945)

* fix

* fix

* update exec count
This commit is contained in:
Dongjia "toka" Zhang 2024-03-15 18:52:53 +01:00 committed by GitHub
parent 5cc0180835
commit e30ff57456
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 5 deletions

View File

@ -303,10 +303,15 @@ where
// Correctly handled the event
Ok(BrokerEventResult::Handled)
}
Event::Objective { objective_size } => {
Event::Objective {
objective_size,
executions,
time,
} => {
monitor.client_stats_insert(client_id);
let client = monitor.client_stats_mut_for(client_id);
client.update_objective_size(*objective_size as u64);
client.update_executions(*executions, *time);
monitor.display(event.name(), client_id);
Ok(BrokerEventResult::Handled)
}

View File

@ -338,6 +338,10 @@ where
Objective {
/// Objective corpus size
objective_size: usize,
/// The total number of executions when this objective is found
executions: u64,
/// The time when this event was created
time: Duration,
},
/// Write a new log
Log {

View File

@ -262,11 +262,18 @@ where
monitor.display(event.name(), ClientId(0));
Ok(BrokerEventResult::Handled)
}
Event::Objective { objective_size } => {
Event::Objective {
objective_size,
executions,
time,
} => {
monitor.client_stats_insert(ClientId(0));
monitor
.client_stats_mut_for(ClientId(0))
.update_objective_size(*objective_size as u64);
monitor
.client_stats_mut_for(ClientId(0))
.update_executions(*executions, *time);
monitor.display(event.name(), ClientId(0));
Ok(BrokerEventResult::Handled)
}

View File

@ -386,10 +386,15 @@ where
// Correctly handled the event
Ok(BrokerEventResult::Handled)
}
Event::Objective { objective_size } => {
Event::Objective {
objective_size,
executions,
time,
} => {
monitor.client_stats_insert(client_id);
let client = monitor.client_stats_mut_for(client_id);
client.update_objective_size(*objective_size as u64);
client.update_executions(*executions, *time);
monitor.display(event.name(), client_id);
Ok(BrokerEventResult::Handled)
}

View File

@ -450,7 +450,8 @@ pub fn run_observers_and_save_state<E, EM, OF, Z>(
.expect("In run_observers_and_save_state objective failure.");
if interesting {
let mut new_testcase = Testcase::with_executions(input.clone(), *state.executions());
let executions = *state.executions();
let mut new_testcase = Testcase::with_executions(input.clone(), executions);
new_testcase.add_metadata(exitkind);
new_testcase.set_parent_id_optional(*state.corpus().current());
fuzzer
@ -466,6 +467,8 @@ pub fn run_observers_and_save_state<E, EM, OF, Z>(
state,
Event::Objective {
objective_size: state.solutions().count(),
executions,
time: libafl_bolts::current_time(),
},
)
.expect("Could not save state in run_observers_and_save_state");

View File

@ -415,8 +415,9 @@ where
// Not interesting
self.feedback_mut().discard_metadata(state, &input)?;
let executions = *state.executions();
// The input is a solution, add it to the respective corpus
let mut testcase = Testcase::with_executions(input, *state.executions());
let mut testcase = Testcase::with_executions(input, executions);
testcase.set_parent_id_optional(*state.corpus().current());
self.objective_mut()
.append_metadata(state, manager, observers, &mut testcase)?;
@ -427,6 +428,8 @@ where
state,
Event::Objective {
objective_size: state.solutions().count(),
executions,
time: current_time(),
},
)?;
}
@ -520,10 +523,13 @@ where
.append_metadata(state, manager, observers, &mut testcase)?;
let idx = state.solutions_mut().add(testcase)?;
let executions = *state.executions();
manager.fire(
state,
Event::Objective {
objective_size: state.solutions().count(),
executions,
time: current_time(),
},
)?;
return Ok(idx);