From 4a48ba7c2f797cfa983d48332aa5ae0c69a5a151 Mon Sep 17 00:00:00 2001 From: "Victor M. Alvarez" Date: Tue, 14 Nov 2023 18:28:57 +0100 Subject: [PATCH] chore: use public API in fuzzers. Instead of exposing private APIs so that fuzzers can use them, use the newly introduced `invoke_mod` API. --- yara-x/fuzz/Cargo.toml | 8 +------- yara-x/fuzz/fuzz_targets/elf_parser.rs | 3 +-- yara-x/fuzz/fuzz_targets/lnk_parser.rs | 3 +-- yara-x/fuzz/fuzz_targets/macho_parser.rs | 3 +-- yara-x/src/lib.rs | 3 --- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/yara-x/fuzz/Cargo.toml b/yara-x/fuzz/Cargo.toml index 0b8cd1a6d..0b76e4808 100644 --- a/yara-x/fuzz/Cargo.toml +++ b/yara-x/fuzz/Cargo.toml @@ -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" @@ -39,4 +33,4 @@ doc = false name = "elf_parser" path = "fuzz_targets/elf_parser.rs" test = false -doc = false \ No newline at end of file +doc = false diff --git a/yara-x/fuzz/fuzz_targets/elf_parser.rs b/yara-x/fuzz/fuzz_targets/elf_parser.rs index 64548a00b..c26fc6ee1 100644 --- a/yara-x/fuzz/fuzz_targets/elf_parser.rs +++ b/yara-x/fuzz/fuzz_targets/elf_parser.rs @@ -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::(data); }); diff --git a/yara-x/fuzz/fuzz_targets/lnk_parser.rs b/yara-x/fuzz/fuzz_targets/lnk_parser.rs index bf5729da4..a83dc5a19 100644 --- a/yara-x/fuzz/fuzz_targets/lnk_parser.rs +++ b/yara-x/fuzz/fuzz_targets/lnk_parser.rs @@ -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::(data); }); diff --git a/yara-x/fuzz/fuzz_targets/macho_parser.rs b/yara-x/fuzz/fuzz_targets/macho_parser.rs index 3b24543e3..d2311d386 100644 --- a/yara-x/fuzz/fuzz_targets/macho_parser.rs +++ b/yara-x/fuzz/fuzz_targets/macho_parser.rs @@ -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::(data); }); diff --git a/yara-x/src/lib.rs b/yara-x/src/lib.rs index 021ad2377..1e94ed762 100644 --- a/yara-x/src/lib.rs +++ b/yara-x/src/lib.rs @@ -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;