From 6d9763c51f006dd5b2a72a50baf96cc5d757087a Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Tue, 4 Jan 2022 23:53:12 +0100 Subject: [PATCH] Move to clap 3.0 (#447) * move to clap 3.0 * fix cargo.toml * update symcc to use clap3 --- fuzzers/forkserver_simple/Cargo.toml | 2 +- fuzzers/frida_libpng/Cargo.toml | 2 +- fuzzers/frida_libpng/src/fuzzer.rs | 31 +++++++++---------- fuzzers/fuzzbench/Cargo.toml | 2 +- fuzzers/fuzzbench_qemu/Cargo.toml | 2 +- fuzzers/generic_inmemory/Cargo.toml | 2 +- fuzzers/generic_inmemory/src/lib.rs | 28 ++++++++--------- fuzzers/libafl_atheris/Cargo.toml | 2 +- fuzzers/libfuzzer_libpng_ctx/Cargo.toml | 2 +- fuzzers/libfuzzer_libpng_ctx/src/lib.rs | 24 +++++++------- fuzzers/libfuzzer_libpng_launcher/Cargo.toml | 2 +- fuzzers/libfuzzer_libpng_launcher/src/lib.rs | 24 +++++++------- .../fuzzer/Cargo.toml | 2 +- .../fuzzer/src/main.rs | 9 +++--- libafl/src/lib.rs | 3 ++ libafl_concolic/symcc_runtime/symcc | 2 +- .../test/dump_constraints/Cargo.toml | 2 +- .../test/dump_constraints/src/main.rs | 21 ++++++------- utils/gramatron/construct_automata/Cargo.toml | 2 +- .../construct_automata/src/clap-config.yaml | 22 ------------- .../gramatron/construct_automata/src/main.rs | 12 +++---- 21 files changed, 88 insertions(+), 110 deletions(-) delete mode 100644 utils/gramatron/construct_automata/src/clap-config.yaml diff --git a/fuzzers/forkserver_simple/Cargo.toml b/fuzzers/forkserver_simple/Cargo.toml index be189280b8..3840b058da 100644 --- a/fuzzers/forkserver_simple/Cargo.toml +++ b/fuzzers/forkserver_simple/Cargo.toml @@ -17,4 +17,4 @@ opt-level = 3 [dependencies] libafl = { path = "../../libafl/" } -clap = { version = "3.0.0-rc.4", features = ["default"] } \ No newline at end of file +clap = { version = "3.0", features = ["default"] } \ No newline at end of file diff --git a/fuzzers/frida_libpng/Cargo.toml b/fuzzers/frida_libpng/Cargo.toml index 43f56f2b79..829c5434c4 100644 --- a/fuzzers/frida_libpng/Cargo.toml +++ b/fuzzers/frida_libpng/Cargo.toml @@ -38,7 +38,7 @@ libc = "0.2" libloading = "0.7" num-traits = "0.2.14" rangemap = "0.1" -structopt = "0.3.25" +clap = { version = "3.0", features = ["derive"] } serde = "1.0" mimalloc = { version = "*", default-features = false } diff --git a/fuzzers/frida_libpng/src/fuzzer.rs b/fuzzers/frida_libpng/src/fuzzer.rs index af7bbe0334..3b3bda0984 100644 --- a/fuzzers/frida_libpng/src/fuzzer.rs +++ b/fuzzers/frida_libpng/src/fuzzer.rs @@ -4,14 +4,13 @@ use mimalloc::MiMalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; +use clap::{self, StructOpt}; use frida_gum::Gum; use std::{ env, net::SocketAddr, path::{Path, PathBuf}, - time::Duration, }; -use structopt::StructOpt; use libafl::{ bolts::{ @@ -56,7 +55,7 @@ use libafl_targets::cmplog::{CmpLogObserver, CMPLOG_MAP}; use libafl_frida::asan::errors::{AsanErrorsFeedback, AsanErrorsObserver, ASAN_ERRORS}; #[derive(Debug, StructOpt)] -#[structopt( +#[clap( name = "libafl_frida", version = "0.1.0", about = "A frida-based binary-only libfuzzer-style fuzzer for with llmp-multithreading support", @@ -64,7 +63,7 @@ use libafl_frida::asan::errors::{AsanErrorsFeedback, AsanErrorsObserver, ASAN_ER Dongjia Zhang , Andrea Fioraldi , Dominik Maier " )] struct Opt { - #[structopt( + #[clap( short, long, parse(try_from_str = Cores::from_cmdline), @@ -73,8 +72,8 @@ struct Opt { )] cores: Cores, - #[structopt( - short = "p", + #[clap( + short = 'p', long, help = "Choose the broker TCP port, default is 1337", name = "PORT", @@ -82,16 +81,16 @@ struct Opt { )] broker_port: u16, - #[structopt( + #[clap( parse(try_from_str), - short = "a", + short = 'a', long, help = "Specify a remote broker", name = "REMOTE" )] remote_broker_addr: Option, - #[structopt( + #[clap( parse(try_from_str), short, long, @@ -100,7 +99,7 @@ struct Opt { )] input: Vec, - #[structopt( + #[clap( short, long, parse(try_from_str), @@ -110,7 +109,7 @@ struct Opt { )] output: PathBuf, - #[structopt( + #[clap( long, help = "The configuration this fuzzer runs with, for multiprocessing", name = "CONF", @@ -118,19 +117,19 @@ struct Opt { )] configuration: String, - #[structopt( + #[clap( long, help = "The file to redirect stdout input to (/dev/null if unset)" )] stdout_file: Option, - #[structopt(help = "The harness")] + #[clap(help = "The harness")] harness: String, - #[structopt(help = "The symbol name to look up and hook")] + #[clap(help = "The symbol name to look up and hook")] symbol: String, - #[structopt(help = "The modules to instrument, separated by colons")] + #[clap(help = "The modules to instrument, separated by colons")] modules_to_instrument: String, } @@ -140,7 +139,7 @@ pub fn main() { // Needed only on no_std //RegistryBuilder::register::(); - let opt = Opt::from_args(); + let opt = Opt::parse(); color_backtrace::install(); println!( diff --git a/fuzzers/fuzzbench/Cargo.toml b/fuzzers/fuzzbench/Cargo.toml index 45bb98dd5b..0cb876ce3e 100644 --- a/fuzzers/fuzzbench/Cargo.toml +++ b/fuzzers/fuzzbench/Cargo.toml @@ -24,7 +24,7 @@ libafl = { path = "../../libafl/" } libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "sancov_cmplog", "libfuzzer"] } # TODO Include it only when building cc libafl_cc = { path = "../../libafl_cc/" } -clap = { version = "3.0.0-rc.4", features = ["default"] } +clap = { version = "3.0", features = ["default"] } nix = "0.23" mimalloc = { version = "*", default-features = false } diff --git a/fuzzers/fuzzbench_qemu/Cargo.toml b/fuzzers/fuzzbench_qemu/Cargo.toml index b8b5240324..4a7ab455e5 100644 --- a/fuzzers/fuzzbench_qemu/Cargo.toml +++ b/fuzzers/fuzzbench_qemu/Cargo.toml @@ -14,5 +14,5 @@ debug = true [dependencies] libafl = { path = "../../libafl/" } libafl_qemu = { path = "../../libafl_qemu/", features = ["x86_64"] } -clap = { version = "3.0.0-rc.4", features = ["default"] } +clap = { version = "3.0", features = ["default"] } nix = "0.23" diff --git a/fuzzers/generic_inmemory/Cargo.toml b/fuzzers/generic_inmemory/Cargo.toml index e842a56836..6cd0a235f3 100644 --- a/fuzzers/generic_inmemory/Cargo.toml +++ b/fuzzers/generic_inmemory/Cargo.toml @@ -24,7 +24,7 @@ libafl = { path = "../../libafl/" } libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "sancov_cmplog", "libfuzzer"] } # TODO Include it only when building cc libafl_cc = { path = "../../libafl_cc/" } -structopt = "0.3.25" +clap = { version = "3.0", features = ["derive"] } mimalloc = { version = "*", default-features = false } [lib] diff --git a/fuzzers/generic_inmemory/src/lib.rs b/fuzzers/generic_inmemory/src/lib.rs index 60d62ab56a..ac614be4a4 100644 --- a/fuzzers/generic_inmemory/src/lib.rs +++ b/fuzzers/generic_inmemory/src/lib.rs @@ -4,9 +4,9 @@ use mimalloc::MiMalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; +use clap::{self, StructOpt}; use core::time::Duration; use std::{env, net::SocketAddr, path::PathBuf}; -use structopt::StructOpt; use libafl::{ bolts::{ @@ -50,13 +50,13 @@ fn timeout_from_millis_str(time: &str) -> Result { } #[derive(Debug, StructOpt)] -#[structopt( +#[clap( name = "generic_inmemory", about = "A generic libfuzzer-like fuzzer with llmp-multithreading support", author = "Andrea Fioraldi , Dominik Maier " )] struct Opt { - #[structopt( + #[clap( short, long, parse(try_from_str = Cores::from_cmdline), @@ -65,24 +65,24 @@ struct Opt { )] cores: Cores, - #[structopt( - short = "p", + #[clap( + short = 'p', long, help = "Choose the broker TCP port, default is 1337", name = "PORT" )] broker_port: u16, - #[structopt( + #[clap( parse(try_from_str), - short = "a", + short = 'a', long, help = "Specify a remote broker", name = "REMOTE" )] remote_broker_addr: Option, - #[structopt( + #[clap( parse(try_from_str), short, long, @@ -91,7 +91,7 @@ struct Opt { )] input: Vec, - #[structopt( + #[clap( short, long, parse(try_from_str), @@ -101,7 +101,7 @@ struct Opt { )] output: PathBuf, - #[structopt( + #[clap( parse(try_from_str = timeout_from_millis_str), short, long, @@ -111,13 +111,13 @@ struct Opt { )] timeout: Duration, - #[structopt( + #[clap( parse(from_os_str), - short = "x", + short = 'x', long, help = "Feed the fuzzer with an user-specified list of tokens (often called \"dictionary\"", name = "TOKENS", - multiple = true + multiple_occurrences = true )] tokens: Vec, } @@ -131,7 +131,7 @@ pub fn libafl_main() { let workdir = env::current_dir().unwrap(); - let opt = Opt::from_args(); + let opt = Opt::parse(); let cores = opt.cores; let broker_port = opt.broker_port; diff --git a/fuzzers/libafl_atheris/Cargo.toml b/fuzzers/libafl_atheris/Cargo.toml index 6a6f269e25..0c30a9a79e 100644 --- a/fuzzers/libafl_atheris/Cargo.toml +++ b/fuzzers/libafl_atheris/Cargo.toml @@ -22,7 +22,7 @@ num_cpus = "1.0" [dependencies] libafl = { path = "../../libafl/" } libafl_targets = { path = "../../libafl_targets/", features = ["pointer_maps", "sancov_cmplog", "libfuzzer"] } -clap = { version = "3.0.0-beta.4", features = ["default", "yaml"] } +clap = { version = "3.0", features = ["default"] } [lib] name = "afl_atheris" diff --git a/fuzzers/libfuzzer_libpng_ctx/Cargo.toml b/fuzzers/libfuzzer_libpng_ctx/Cargo.toml index ab8ad5a6f0..fe20c9ccda 100644 --- a/fuzzers/libfuzzer_libpng_ctx/Cargo.toml +++ b/fuzzers/libfuzzer_libpng_ctx/Cargo.toml @@ -24,7 +24,7 @@ libafl = { path = "../../libafl/", features = ["std", "derive", "llmp_compressio libafl_targets = { path = "../../libafl_targets/", features = ["libfuzzer"] } # TODO Include it only when building cc libafl_cc = { path = "../../libafl_cc/" } -structopt = "0.3.25" +clap = { version = "3.0", features = ["derive"] } mimalloc = { version = "*", default-features = false } [lib] diff --git a/fuzzers/libfuzzer_libpng_ctx/src/lib.rs b/fuzzers/libfuzzer_libpng_ctx/src/lib.rs index 414b89dcc8..a9119fe1b5 100644 --- a/fuzzers/libfuzzer_libpng_ctx/src/lib.rs +++ b/fuzzers/libfuzzer_libpng_ctx/src/lib.rs @@ -6,9 +6,9 @@ use mimalloc::MiMalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; +use clap::{self, StructOpt}; use core::time::Duration; use std::{env, net::SocketAddr, path::PathBuf}; -use structopt::StructOpt; use libafl::{ bolts::{ @@ -47,13 +47,13 @@ fn timeout_from_millis_str(time: &str) -> Result { } #[derive(Debug, StructOpt)] -#[structopt( +#[clap( name = "libfuzzer_libpng_ctx", about = "A clone of libfuzzer using LibAFL for a libpng harness", author = "Andrea Fioraldi , Dominik Maier " )] struct Opt { - #[structopt( + #[clap( short, long, parse(try_from_str = Cores::from_cmdline), @@ -62,8 +62,8 @@ struct Opt { )] cores: Cores, - #[structopt( - short = "p", + #[clap( + short = 'p', long, help = "Choose the broker TCP port, default is 1337", name = "PORT", @@ -71,16 +71,16 @@ struct Opt { )] broker_port: u16, - #[structopt( + #[clap( parse(try_from_str), - short = "a", + short = 'a', long, help = "Specify a remote broker", name = "REMOTE" )] remote_broker_addr: Option, - #[structopt( + #[clap( parse(try_from_str), short, long, @@ -89,7 +89,7 @@ struct Opt { )] input: Vec, - #[structopt( + #[clap( short, long, parse(try_from_str), @@ -99,7 +99,7 @@ struct Opt { )] output: PathBuf, - #[structopt( + #[clap( short, long, parse(try_from_str = timeout_from_millis_str), @@ -110,7 +110,7 @@ struct Opt { timeout: Duration, /* // The tokens are hardcoded in this example. - #[structopt( + #[clap( parse(from_os_str), short = "x", long, @@ -127,7 +127,7 @@ pub fn libafl_main() { // Registry the metadata types used in this fuzzer // Needed only on no_std //RegistryBuilder::register::(); - let opt = Opt::from_args(); + let opt = Opt::parse(); let broker_port = opt.broker_port; diff --git a/fuzzers/libfuzzer_libpng_launcher/Cargo.toml b/fuzzers/libfuzzer_libpng_launcher/Cargo.toml index f003e64ce9..6b23637ec5 100644 --- a/fuzzers/libfuzzer_libpng_launcher/Cargo.toml +++ b/fuzzers/libfuzzer_libpng_launcher/Cargo.toml @@ -24,7 +24,7 @@ libafl = { path = "../../libafl/", features = ["std", "derive", "llmp_compressio libafl_targets = { path = "../../libafl_targets/", features = ["sancov_pcguard_hitcounts", "libfuzzer"] } # TODO Include it only when building cc libafl_cc = { path = "../../libafl_cc/" } -structopt = "0.3.25" +clap = { version = "3.0", features = ["derive"] } mimalloc = { version = "*", default-features = false } [lib] diff --git a/fuzzers/libfuzzer_libpng_launcher/src/lib.rs b/fuzzers/libfuzzer_libpng_launcher/src/lib.rs index 77daf9c526..3732a17a5e 100644 --- a/fuzzers/libfuzzer_libpng_launcher/src/lib.rs +++ b/fuzzers/libfuzzer_libpng_launcher/src/lib.rs @@ -6,9 +6,9 @@ use mimalloc::MiMalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; +use clap::{self, StructOpt}; use core::time::Duration; use std::{env, net::SocketAddr, path::PathBuf}; -use structopt::StructOpt; use libafl::{ bolts::{ @@ -47,13 +47,13 @@ fn timeout_from_millis_str(time: &str) -> Result { /// The commandline args this fuzzer accepts #[derive(Debug, StructOpt)] -#[structopt( +#[clap( name = "libfuzzer_libpng_launcher", about = "A libfuzzer-like fuzzer for libpng with llmp-multithreading support and a launcher", author = "Andrea Fioraldi , Dominik Maier " )] struct Opt { - #[structopt( + #[clap( short, long, parse(try_from_str = Cores::from_cmdline), @@ -62,8 +62,8 @@ struct Opt { )] cores: Cores, - #[structopt( - short = "p", + #[clap( + short = 'p', long, help = "Choose the broker TCP port, default is 1337", name = "PORT", @@ -71,16 +71,16 @@ struct Opt { )] broker_port: u16, - #[structopt( + #[clap( parse(try_from_str), - short = "a", + short = 'a', long, help = "Specify a remote broker", name = "REMOTE" )] remote_broker_addr: Option, - #[structopt( + #[clap( parse(try_from_str), short, long, @@ -89,7 +89,7 @@ struct Opt { )] input: Vec, - #[structopt( + #[clap( short, long, parse(try_from_str), @@ -99,7 +99,7 @@ struct Opt { )] output: PathBuf, - #[structopt( + #[clap( parse(try_from_str = timeout_from_millis_str), short, long, @@ -110,7 +110,7 @@ struct Opt { timeout: Duration, /* /// This fuzzer has hard-coded tokens - #[structopt( + #[clap( parse(from_os_str), short = "x", long, @@ -128,7 +128,7 @@ pub fn libafl_main() { // Registry the metadata types used in this fuzzer // Needed only on no_std //RegistryBuilder::register::(); - let opt = Opt::from_args(); + let opt = Opt::parse(); let broker_port = opt.broker_port; let cores = opt.cores; diff --git a/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml b/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml index 95adad50f2..d1b1ad8e7a 100644 --- a/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml +++ b/fuzzers/libfuzzer_stb_image_concolic/fuzzer/Cargo.toml @@ -18,7 +18,7 @@ debug = true [dependencies] libafl = { path = "../../../libafl/", features = ["concolic_mutation"] } libafl_targets = { path = "../../../libafl_targets/", features = ["sancov_pcguard_edges", "sancov_cmplog", "libfuzzer"] } -structopt = "0.3.21" +clap = { version = "3.0", features = ["derive"]} mimalloc = { version = "*", default-features = false } [build-dependencies] diff --git a/fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs b/fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs index dc1d642e66..9e8317770a 100644 --- a/fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs +++ b/fuzzers/libfuzzer_stb_image_concolic/fuzzer/src/main.rs @@ -4,6 +4,7 @@ use mimalloc::MiMalloc; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; +use clap::{self, StructOpt}; use std::{env, path::PathBuf}; use libafl::{ @@ -25,6 +26,7 @@ use libafl::{ feedbacks::{CrashFeedback, MapFeedbackState, MaxMapFeedback, TimeFeedback}, fuzzer::{Fuzzer, StdFuzzer}, inputs::{BytesInput, HasTargetBytes, Input}, + monitors::MultiMonitor, mutators::{ scheduled::{havoc_mutations, StdScheduledMutator}, token_mutations::I2SRandReplace, @@ -41,7 +43,6 @@ use libafl::{ StdMutationalStage, TracingStage, }, state::{HasCorpus, StdState}, - monitors::MultiMonitor, Error, }; @@ -50,12 +51,10 @@ use libafl_targets::{ MAX_EDGES_NUM, }; -use structopt::StructOpt; - #[derive(Debug, StructOpt)] struct Opt { /// This node should do concolic tracing + solving instead of traditional fuzzing - #[structopt(short, long)] + #[clap(short, long)] concolic: bool, } @@ -64,7 +63,7 @@ pub fn main() { // Needed only on no_std //RegistryBuilder::register::(); - let opt = Opt::from_args(); + let opt = Opt::parse(); println!( "Workdir: {:?}", diff --git a/libafl/src/lib.rs b/libafl/src/lib.rs index 358b3c8482..8717b14d92 100644 --- a/libafl/src/lib.rs +++ b/libafl/src/lib.rs @@ -237,6 +237,9 @@ impl From for Error { } } +#[cfg(feature = "std")] +impl std::error::Error for Error {} + // TODO: no_std test #[cfg(feature = "std")] #[cfg(test)] diff --git a/libafl_concolic/symcc_runtime/symcc b/libafl_concolic/symcc_runtime/symcc index 45cde0269a..3133c0b37d 160000 --- a/libafl_concolic/symcc_runtime/symcc +++ b/libafl_concolic/symcc_runtime/symcc @@ -1 +1 @@ -Subproject commit 45cde0269ae22aef4cca2e1fb98c3b24f7bb2984 +Subproject commit 3133c0b37d3c498db9addf2331378c7c9cadbf10 diff --git a/libafl_concolic/test/dump_constraints/Cargo.toml b/libafl_concolic/test/dump_constraints/Cargo.toml index d3b7ed985e..876a7c24bc 100644 --- a/libafl_concolic/test/dump_constraints/Cargo.toml +++ b/libafl_concolic/test/dump_constraints/Cargo.toml @@ -8,4 +8,4 @@ authors = ["Julius Hohnerlein "] [dependencies] libafl = {path = "../../../libafl"} -structopt = "0.3.21" +clap = { version = "3.0", features = ["derive"] } diff --git a/libafl_concolic/test/dump_constraints/src/main.rs b/libafl_concolic/test/dump_constraints/src/main.rs index 7963c8b1b5..987d915873 100644 --- a/libafl_concolic/test/dump_constraints/src/main.rs +++ b/libafl_concolic/test/dump_constraints/src/main.rs @@ -2,6 +2,7 @@ //! It achieves this by running an instrumented target program with the necessary environment variables set. //! When the program has finished executing, it dumps the traced constraints to a file. +use clap::{self, StructOpt}; use std::{ ffi::OsString, fs::File, @@ -11,8 +12,6 @@ use std::{ string::ToString, }; -use structopt::StructOpt; - use libafl::{ bolts::shmem::{ShMem, ShMemProvider, StdShMemProvider}, observers::concolic::{ @@ -22,44 +21,44 @@ use libafl::{ }; #[derive(Debug, StructOpt)] -#[structopt( +#[clap( name = "dump_constraints", about = "Dump tool for concolic constraints." )] struct Opt { /// Outputs plain text instead of binary - #[structopt(short, long)] + #[clap(short, long)] plain_text: bool, /// Outputs coverage information to the given file - #[structopt(short, long)] + #[clap(short, long)] coverage_file: Option, /// Symbolizes only the given input file offsets. - #[structopt(short, long)] + #[clap(short, long)] symbolize_offsets: Option>, /// Concretize all floating point operations. - #[structopt(long)] + #[clap(long)] no_float: bool, /// Prune expressions from high-frequency code locations. - #[structopt(long)] + #[clap(long)] prune: bool, /// Trace file path, "trace" by default. - #[structopt(parse(from_os_str), short, long)] + #[clap(parse(from_os_str), short, long)] output: Option, /// Target program and arguments - #[structopt(last = true)] + #[clap(last = true)] program: Vec, } fn main() { const COVERAGE_MAP_SIZE: usize = 65536; - let opt = Opt::from_args(); + let opt = Opt::parse(); let mut shmemprovider = StdShMemProvider::default(); let concolic_shmem = shmemprovider diff --git a/utils/gramatron/construct_automata/Cargo.toml b/utils/gramatron/construct_automata/Cargo.toml index 3b54060e72..fccd5cf076 100644 --- a/utils/gramatron/construct_automata/Cargo.toml +++ b/utils/gramatron/construct_automata/Cargo.toml @@ -11,4 +11,4 @@ regex = "1" postcard = "0.7" lazy_static = "1.4.0" libafl = { path = "../../../libafl" } -structopt = "0.3.25" +clap = { version = "3.0", features = ["derive"] } diff --git a/utils/gramatron/construct_automata/src/clap-config.yaml b/utils/gramatron/construct_automata/src/clap-config.yaml deleted file mode 100644 index 55dc8c0d70..0000000000 --- a/utils/gramatron/construct_automata/src/clap-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: construct_automata -version: "0.1.0" -author: "Andrea Fioraldi " -about: Generate a serialized Automaton using a json GNF grammar -args: - - grammar: - short: g - long: grammar-file - value_name: GRAMMAR - required: true - takes_value: true - - output: - short: o - long: output - value_name: OUTPUT - required: true - takes_value: true - - limit: - short: l - long: limit - value_name: LIMIT - takes_value: true diff --git a/utils/gramatron/construct_automata/src/main.rs b/utils/gramatron/construct_automata/src/main.rs index 985d14fbe2..7744a045d0 100644 --- a/utils/gramatron/construct_automata/src/main.rs +++ b/utils/gramatron/construct_automata/src/main.rs @@ -1,3 +1,4 @@ +use clap::{self, StructOpt}; use lazy_static::lazy_static; use regex::Regex; use serde_json::Value; @@ -9,18 +10,17 @@ use std::{ path::PathBuf, rc::Rc, }; -use structopt::StructOpt; use libafl::generators::gramatron::{Automaton, Trigger}; #[derive(Debug, StructOpt)] -#[structopt( +#[clap( name = "construct_automata", about = "Generate a serialized Automaton using a json GNF grammar", author = "Andrea Fioraldi " )] struct Opt { - #[structopt( + #[clap( parse(try_from_str), short, long = "grammar-file", @@ -29,7 +29,7 @@ struct Opt { )] grammar: PathBuf, - #[structopt( + #[clap( parse(try_from_str), short, long, @@ -39,7 +39,7 @@ struct Opt { )] limit: usize, - #[structopt( + #[clap( parse(try_from_str), short, long, @@ -305,7 +305,7 @@ fn postprocess(pda: &[Transition], stack_limit: usize) -> Automaton { } fn main() { - let opt = Opt::from_args(); + let opt = Opt::parse(); let grammar_file = opt.grammar; let output_file = opt.output;