Skip to content

Commit

Permalink
chore: use public API in fuzzers.
Browse files Browse the repository at this point in the history
Instead of exposing private APIs so that fuzzers can use them, use the newly introduced `invoke_mod` API.
  • Loading branch information
plusvic committed Nov 14, 2023
1 parent 8c0a57b commit 4a48ba7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 16 deletions.
8 changes: 1 addition & 7 deletions yara-x/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ path = "fuzz_targets/macho_parser.rs"
test = false
doc = false

[[bin]]
name = "macho_fat_parser"
path = "fuzz_targets/macho_fat_parser.rs"
test = false
doc = false

[[bin]]
name = "lnk_parser"
path = "fuzz_targets/lnk_parser.rs"
Expand All @@ -39,4 +33,4 @@ doc = false
name = "elf_parser"
path = "fuzz_targets/elf_parser.rs"
test = false
doc = false
doc = false
3 changes: 1 addition & 2 deletions yara-x/fuzz/fuzz_targets/elf_parser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use yara_x::modules::elf::parser::ElfParser;

fuzz_target!(|data: &[u8]| {
let _ = ElfParser::new().parse(data);
let _ = yara_x::mods::invoke_mod::<yara_x::mods::ELF>(data);
});
3 changes: 1 addition & 2 deletions yara-x/fuzz/fuzz_targets/lnk_parser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use yara_x::modules::lnk::parser::LnkParser;

fuzz_target!(|data: &[u8]| {
let _ = LnkParser::new().parse(data);
let _ = yara_x::mods::invoke_mod::<yara_x::mods::Lnk>(data);
});
3 changes: 1 addition & 2 deletions yara-x/fuzz/fuzz_targets/macho_parser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use yara_x::modules::macho::parse_macho_file;

fuzz_target!(|data: &[u8]| {
let _ = parse_macho_file(data);
let _ = yara_x::mods::invoke_mod::<yara_x::mods::Macho>(data);
});
3 changes: 0 additions & 3 deletions yara-x/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ pub use variables::Variable;
pub use variables::VariableError;

mod compiler;
#[cfg(fuzzing)]
pub mod modules;
#[cfg(not(fuzzing))]
mod modules;
mod re;
mod scanner;
Expand Down

0 comments on commit 4a48ba7

Please # to comment.