Skip to content

Commit fef129e

Browse files
authored
Conform AFL struct casing to codebase/rust (#3221)
* Conform AFL struct casing to codebase/rust * Actually, Aflpp looks better
1 parent c606ac1 commit fef129e

File tree

11 files changed

+117
-117
lines changed

11 files changed

+117
-117
lines changed

fuzzers/forkserver/fuzzbench_forkserver/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use libafl_bolts::{
4343
tuples::{tuple_list, Merge},
4444
AsSliceMut, StdTargetArgs,
4545
};
46-
use libafl_targets::cmps::AFLppCmpLogMap;
46+
use libafl_targets::cmps::AflppCmpLogMap;
4747
use nix::sys::signal::Signal;
4848

4949
pub fn main() {
@@ -351,12 +351,12 @@ fn fuzz(
351351

352352
if let Some(exec) = &cmplog_exec {
353353
// The cmplog map shared between observer and executor
354-
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AFLppCmpLogMap>().unwrap();
354+
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AflppCmpLogMap>().unwrap();
355355
// let the forkserver know the shmid
356356
unsafe {
357357
cmplog_shmem.write_to_env(SHM_CMPLOG_ENV_VAR).unwrap();
358358
}
359-
let cmpmap = unsafe { OwnedRefMut::<AFLppCmpLogMap>::from_shmem(&mut cmplog_shmem) };
359+
let cmpmap = unsafe { OwnedRefMut::<AflppCmpLogMap>::from_shmem(&mut cmplog_shmem) };
360360

361361
let cmplog_observer = StdCmpObserver::new("cmplog", cmpmap, true);
362362

fuzzers/forkserver/fuzzbench_forkserver_cmplog/src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use libafl::{
2121
inputs::BytesInput,
2222
monitors::SimpleMonitor,
2323
mutators::{
24-
havoc_mutations, token_mutations::AFLppRedQueen, tokens_mutations, StdMOptMutator, Tokens,
24+
havoc_mutations, token_mutations::AflppRedQueen, tokens_mutations, StdMOptMutator, Tokens,
2525
},
2626
observers::{CanTrack, HitcountsMapObserver, StdMapObserver, TimeObserver},
2727
schedulers::{
@@ -43,8 +43,8 @@ use libafl_bolts::{
4343
AsSliceMut, StdTargetArgs,
4444
};
4545
use libafl_targets::{
46-
cmps::{observers::AFLppCmpLogObserver, stages::AFLppCmplogTracingStage},
47-
AFLppCmpLogMap,
46+
cmps::{observers::AflppCmpLogObserver, stages::AflppCmplogTracingStage},
47+
AflppCmpLogMap,
4848
};
4949
use nix::sys::signal::Signal;
5050

@@ -354,14 +354,14 @@ fn fuzz(
354354

355355
if let Some(exec) = &cmplog_exec {
356356
// The cmplog map shared between observer and executor
357-
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AFLppCmpLogMap>().unwrap();
357+
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AflppCmpLogMap>().unwrap();
358358
// let the forkserver know the shmid
359359
unsafe {
360360
cmplog_shmem.write_to_env(SHM_CMPLOG_ENV_VAR).unwrap();
361361
}
362362
let cmpmap = unsafe { OwnedRefMut::from_shmem(&mut cmplog_shmem) };
363363

364-
let cmplog_observer = AFLppCmpLogObserver::new("cmplog", cmpmap, true);
364+
let cmplog_observer = AflppCmpLogObserver::new("cmplog", cmpmap, true);
365365
let cmplog_ref = cmplog_observer.handle();
366366

367367
let cmplog_executor = ForkserverExecutor::builder()
@@ -376,11 +376,11 @@ fn fuzz(
376376
.build(tuple_list!(cmplog_observer))
377377
.unwrap();
378378

379-
let tracing = AFLppCmplogTracingStage::new(cmplog_executor, cmplog_ref);
379+
let tracing = AflppCmplogTracingStage::new(cmplog_executor, cmplog_ref);
380380

381381
// Setup a randomic Input2State stage
382382
let rq: MultiMutationalStage<_, _, BytesInput, _, _, _> =
383-
MultiMutationalStage::new(AFLppRedQueen::with_cmplog_options(true, true));
383+
MultiMutationalStage::new(AflppRedQueen::with_cmplog_options(true, true));
384384

385385
let cb = |_fuzzer: &mut _,
386386
_executor: &mut _,

fuzzers/forkserver/fuzzbench_forkserver_sand/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use libafl_bolts::{
4444
tuples::{tuple_list, Handled, Merge},
4545
AsSliceMut, StdTargetArgs,
4646
};
47-
use libafl_targets::cmps::AFLppCmpLogMap;
47+
use libafl_targets::cmps::AflppCmpLogMap;
4848
use nix::sys::signal::Signal;
4949

5050
pub fn main() {
@@ -399,12 +399,12 @@ fn fuzz(
399399

400400
if let Some(exec) = &cmplog_exec {
401401
// The cmplog map shared between observer and executor
402-
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AFLppCmpLogMap>().unwrap();
402+
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AflppCmpLogMap>().unwrap();
403403
// let the forkserver know the shmid
404404
unsafe {
405405
cmplog_shmem.write_to_env(SHM_CMPLOG_ENV_VAR).unwrap();
406406
}
407-
let cmpmap = unsafe { OwnedRefMut::<AFLppCmpLogMap>::from_shmem(&mut cmplog_shmem) };
407+
let cmpmap = unsafe { OwnedRefMut::<AflppCmpLogMap>::from_shmem(&mut cmplog_shmem) };
408408

409409
let cmplog_observer = StdCmpObserver::new("cmplog", cmpmap, true);
410410

fuzzers/forkserver/libafl-fuzz/src/fuzzer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use libafl::{
2626
},
2727
fuzzer::StdFuzzer,
2828
inputs::BytesInput,
29-
mutators::{havoc_mutations, tokens_mutations, AFLppRedQueen, HavocScheduledMutator, Tokens},
29+
mutators::{havoc_mutations, tokens_mutations, AflppRedQueen, HavocScheduledMutator, Tokens},
3030
observers::{CanTrack, HitcountsMapObserver, StdMapObserver, TimeObserver},
3131
schedulers::{
3232
powersched::{BaseSchedule, PowerSchedule},
@@ -58,7 +58,7 @@ use libafl_bolts::{
5858
};
5959
#[cfg(feature = "nyx")]
6060
use libafl_nyx::{executor::NyxExecutor, helper::NyxHelper, settings::NyxSettings};
61-
use libafl_targets::{cmps::AFLppCmpLogMap, AFLppCmpLogObserver, AFLppCmplogTracingStage};
61+
use libafl_targets::{cmps::AflppCmpLogMap, AflppCmpLogObserver, AflppCmplogTracingStage};
6262
use serde::{Deserialize, Serialize};
6363

6464
use crate::{
@@ -475,7 +475,7 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
475475

476476
if run_cmplog {
477477
// The CmpLog map shared between the CmpLog observer and CmpLog executor
478-
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AFLppCmpLogMap>().unwrap();
478+
let mut cmplog_shmem = shmem_provider.uninit_on_shmem::<AflppCmpLogMap>().unwrap();
479479

480480
// Let the Forkserver know the CmpLog shared memory map ID.
481481
unsafe {
@@ -484,7 +484,7 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
484484
let cmpmap = unsafe { OwnedRefMut::from_shmem(&mut cmplog_shmem) };
485485

486486
// Create the CmpLog observer.
487-
let cmplog_observer = AFLppCmpLogObserver::new("cmplog", cmpmap, true);
487+
let cmplog_observer = AflppCmpLogObserver::new("cmplog", cmpmap, true);
488488
let cmplog_ref = cmplog_observer.handle();
489489

490490
// Create the CmpLog executor.
@@ -496,11 +496,11 @@ define_run_client!(state, mgr, fuzzer_dir, core_id, opt, is_main_node, {
496496
.unwrap();
497497

498498
// Create the CmpLog tracing stage.
499-
let tracing = AFLppCmplogTracingStage::new(cmplog_executor, cmplog_ref);
499+
let tracing = AflppCmplogTracingStage::new(cmplog_executor, cmplog_ref);
500500

501501
// Create a randomic Input2State stage
502502
let rq = MultiMutationalStage::<_, _, BytesInput, _, _, _>::new(
503-
AFLppRedQueen::with_cmplog_options(true, true),
503+
AflppRedQueen::with_cmplog_options(true, true),
504504
);
505505

506506
// Create an IfStage and wrap the CmpLog stages in it.

libafl/src/mutators/token_mutations.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::{
3030
mutators::{
3131
MultiMutator, MutationResult, Mutator, Named, buffer_self_copy, mutations::buffer_copy,
3232
},
33-
observers::cmp::{AFLppCmpValuesMetadata, CmpValues, CmpValuesMetadata},
33+
observers::cmp::{AflppCmpValuesMetadata, CmpValues, CmpValuesMetadata},
3434
stages::TaintMetadata,
3535
state::{HasCorpus, HasMaxSize, HasRand},
3636
};
@@ -849,7 +849,7 @@ const CMP_ATTRIBUTE_IS_TRANSFORM: u8 = 64;
849849

850850
/// AFL++ redqueen mutation
851851
#[derive(Debug, Default)]
852-
pub struct AFLppRedQueen {
852+
pub struct AflppRedQueen {
853853
enable_transform: bool,
854854
enable_arith: bool,
855855
text_type: TextType,
@@ -858,7 +858,7 @@ pub struct AFLppRedQueen {
858858
last_corpus_id: Option<CorpusId>,
859859
}
860860

861-
impl AFLppRedQueen {
861+
impl AflppRedQueen {
862862
#[inline]
863863
fn swapa(x: u8) -> u8 {
864864
(x & 0xf8) + ((x & 7) ^ 0x07)
@@ -1321,7 +1321,7 @@ impl AFLppRedQueen {
13211321
}
13221322
}
13231323

1324-
impl<I, S> MultiMutator<I, S> for AFLppRedQueen
1324+
impl<I, S> MultiMutator<I, S> for AflppRedQueen
13251325
where
13261326
S: HasMetadata + HasRand + HasMaxSize + HasCorpus<I> + HasCurrentCorpusId,
13271327
I: ResizableMutator<u8> + From<Vec<u8>> + HasMutatorBytes,
@@ -1342,7 +1342,7 @@ where
13421342

13431343
let (cmp_len, cmp_meta, taint_meta) = {
13441344
let (Some(cmp_meta), Some(taint_meta)) = (
1345-
state.metadata_map().get::<AFLppCmpValuesMetadata>(),
1345+
state.metadata_map().get::<AflppCmpValuesMetadata>(),
13461346
state.metadata_map().get::<TaintMetadata>(),
13471347
) else {
13481348
return Ok(vec![]);
@@ -1370,7 +1370,7 @@ where
13701370
// println!("orig: {:#?} new: {:#?}", orig_cmpvals, new_cmpvals);
13711371

13721372
// Compute when mutating it for the 1st time.
1373-
let current_corpus_id = state.current_corpus_id()?.ok_or_else(|| Error::key_not_found("No corpus-id is currently being fuzzed, but called AFLppRedQueen::multi_mutated()."))?;
1373+
let current_corpus_id = state.current_corpus_id()?.ok_or_else(|| Error::key_not_found("No corpus-id is currently being fuzzed, but called AflppRedQueen::multi_mutated()."))?;
13741374
if self.last_corpus_id.is_none() || self.last_corpus_id.unwrap() != current_corpus_id {
13751375
self.text_type = check_if_text(orig_bytes, orig_bytes.len());
13761376
self.last_corpus_id = Some(current_corpus_id);
@@ -1920,15 +1920,15 @@ where
19201920
}
19211921
}
19221922

1923-
impl Named for AFLppRedQueen {
1923+
impl Named for AflppRedQueen {
19241924
fn name(&self) -> &Cow<'static, str> {
1925-
static NAME: Cow<'static, str> = Cow::Borrowed("AFLppRedQueen");
1925+
static NAME: Cow<'static, str> = Cow::Borrowed("AflppRedQueen");
19261926
&NAME
19271927
}
19281928
}
19291929

1930-
impl AFLppRedQueen {
1931-
/// Create a new `AFLppRedQueen` Mutator
1930+
impl AflppRedQueen {
1931+
/// Create a new `AflppRedQueen` Mutator
19321932
#[must_use]
19331933
pub fn new() -> Self {
19341934
Self {
@@ -2111,7 +2111,7 @@ mod tests {
21112111
use std::fs;
21122112

21132113
#[cfg(feature = "std")]
2114-
use super::{AFLppRedQueen, Tokens};
2114+
use super::{AflppRedQueen, Tokens};
21152115

21162116
#[cfg(feature = "std")]
21172117
#[test]
@@ -2134,7 +2134,7 @@ token2="B"
21342134
#[cfg(feature = "std")]
21352135
#[test]
21362136
fn test_token_mutations() {
2137-
let rq = AFLppRedQueen::with_cmplog_options(true, true);
2137+
let rq = AflppRedQueen::with_cmplog_options(true, true);
21382138
let pattern = 0;
21392139
let repl = 0;
21402140
let another_pattern = 0;

libafl/src/observers/cmp.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl CmpValuesMetadata {
120120

121121
/// Add comparisons to a metadata from a `CmpObserver`. `cmp_map` is mutable in case
122122
/// it is needed for a custom map, but this is not utilized for `CmpObserver` or
123-
/// `AFLppCmpLogObserver`.
123+
/// `AflppCmpLogObserver`.
124124
pub fn add_from<CM>(&mut self, usable_count: usize, cmp_map: &mut CM)
125125
where
126126
CM: CmpMap,
@@ -360,22 +360,22 @@ struct cmp_map {
360360
any(not(feature = "serdeany_autoreg"), miri),
361361
expect(clippy::unsafe_derive_deserialize)
362362
)] // for SerdeAny
363-
pub struct AFLppCmpValuesMetadata {
364-
/// The first map of `AFLppCmpLogVals` retrieved by running the un-mutated input
363+
pub struct AflppCmpValuesMetadata {
364+
/// The first map of `AflppCmpLogVals` retrieved by running the un-mutated input
365365
#[serde(skip)]
366366
pub orig_cmpvals: HashMap<usize, Vec<CmpValues>>,
367-
/// The second map of `AFLppCmpLogVals` retrieved by runnning the mutated input
367+
/// The second map of `AflppCmpLogVals` retrieved by runnning the mutated input
368368
#[serde(skip)]
369369
pub new_cmpvals: HashMap<usize, Vec<CmpValues>>,
370370
/// The list of logged idx and headers retrieved by runnning the mutated input
371371
#[serde(skip)]
372-
pub headers: Vec<(usize, AFLppCmpLogHeader)>,
372+
pub headers: Vec<(usize, AflppCmpLogHeader)>,
373373
}
374374

375-
libafl_bolts::impl_serdeany!(AFLppCmpValuesMetadata);
375+
libafl_bolts::impl_serdeany!(AflppCmpValuesMetadata);
376376

377-
impl AFLppCmpValuesMetadata {
378-
/// Constructor for `AFLppCmpValuesMetadata`
377+
impl AflppCmpValuesMetadata {
378+
/// Constructor for `AflppCmpValuesMetadata`
379379
#[must_use]
380380
pub fn new() -> Self {
381381
Self {
@@ -399,7 +399,7 @@ impl AFLppCmpValuesMetadata {
399399

400400
/// Getter for `headers`
401401
#[must_use]
402-
pub fn headers(&self) -> &Vec<(usize, AFLppCmpLogHeader)> {
402+
pub fn headers(&self) -> &Vec<(usize, AflppCmpLogHeader)> {
403403
&self.headers
404404
}
405405
}
@@ -418,7 +418,7 @@ impl AFLppCmpValuesMetadata {
418418
/// - reserved: Reserved for future use
419419
#[bitfield(u16)]
420420
#[derive(Debug)]
421-
pub struct AFLppCmpLogHeader {
421+
pub struct AflppCmpLogHeader {
422422
/// The number of hits of a particular comparison
423423
///
424424
/// 6 bits up to 63 entries, we have CMP_MAP_H = 32 (so using half of it)

libafl/src/stages/afl_stats.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub struct AflStatsStage<C, E, EM, I, O, S, Z> {
117117

118118
/// AFL++'s `fuzzer_stats`
119119
#[derive(Debug, Clone)]
120-
pub struct AFLFuzzerStats<'a> {
120+
pub struct AflFuzzerStats<'a> {
121121
/// unix time indicating the start time of afl-fuzz
122122
start_time: u64,
123123
/// unix time corresponding to the last interval
@@ -320,7 +320,7 @@ where
320320
} else {
321321
0
322322
};
323-
let stats = AFLFuzzerStats {
323+
let stats = AflFuzzerStats {
324324
start_time: self.start_time,
325325
last_update: self.last_report_time.as_secs(),
326326
run_time: self.last_report_time.as_secs() - self.start_time,
@@ -460,7 +460,7 @@ where
460460
}
461461

462462
/// Writes a stats file, if a `stats_file_path` is set.
463-
fn maybe_write_fuzzer_stats(&self, stats: &AFLFuzzerStats) -> Result<(), Error> {
463+
fn maybe_write_fuzzer_stats(&self, stats: &AflFuzzerStats) -> Result<(), Error> {
464464
if let Some(stats_file_path) = &self.stats_file_path {
465465
let tmp_file = stats_file_path
466466
.parent()
@@ -586,7 +586,7 @@ impl AFLPlotData<'_> {
586586
"# relative_time, cycles_done, cur_item, corpus_count, pending_total, pending_favs, total_edges, saved_crashes, saved_hangs, max_depth, execs_per_sec, execs_done, edges_found"
587587
}
588588
}
589-
impl Display for AFLFuzzerStats<'_> {
589+
impl Display for AflFuzzerStats<'_> {
590590
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
591591
writeln!(f, "start_time : {}", &self.start_time)?;
592592
writeln!(f, "start_time : {}", &self.start_time)?;

libafl_sugar/src/forkserver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use libafl_bolts::{
3939
shmem::{ShMem, ShMemProvider, UnixShMemProvider},
4040
tuples::{Merge, tuple_list},
4141
};
42-
use libafl_targets::AFLppCmpLogMap;
42+
use libafl_targets::AflppCmpLogMap;
4343
use typed_builder::TypedBuilder;
4444

4545
use crate::{CORPUS_CACHE_SIZE, DEFAULT_TIMEOUT_SECS};
@@ -265,14 +265,14 @@ impl ForkserverBytesCoverageSugar<'_> {
265265
if let Some(exec) = &self.cmplog_binary {
266266
// The cmplog map shared between observer and executor
267267
let mut cmplog_shmem = shmem_provider_client
268-
.uninit_on_shmem::<AFLppCmpLogMap>()
268+
.uninit_on_shmem::<AflppCmpLogMap>()
269269
.unwrap();
270270
// let the forkserver know the shmid
271271
unsafe {
272272
cmplog_shmem.write_to_env(SHM_CMPLOG_ENV_VAR).unwrap();
273273
}
274274
let cmpmap =
275-
unsafe { OwnedRefMut::<AFLppCmpLogMap>::from_shmem(&mut cmplog_shmem) };
275+
unsafe { OwnedRefMut::<AflppCmpLogMap>::from_shmem(&mut cmplog_shmem) };
276276

277277
let cmplog_observer = StdCmpObserver::new("cmplog", cmpmap, true);
278278

0 commit comments

Comments
 (0)