From a9a1821dd7ad5b7d3383d84318c2d5b5f54c3e62 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Tue, 4 Oct 2022 23:27:50 +0900 Subject: [PATCH] updated clap version 4.x #725 --- Cargo.lock | 40 ++++++++++++++++++++++++++++++--------- Cargo.toml | 2 +- rules | 2 +- src/detections/configs.rs | 18 +++++++++--------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bbb0e316..dcc49875 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,20 +199,33 @@ checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" dependencies = [ "atty", "bitflags", - "clap_derive", - "clap_lex", + "clap_lex 0.2.4", "indexmap", - "once_cell", "strsim", "termcolor", "textwrap", ] [[package]] -name = "clap_derive" -version = "3.2.18" +name = "clap" +version = "4.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "30607dd93c420c6f1f80b544be522a0238a7db35e6a12968d28910983fee0df0" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex 0.3.0", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a307492e1a34939f79d3b6b9650bd2b971513cd775436bf2b78defeb5af00b" dependencies = [ "heck", "proc-macro-error", @@ -230,6 +243,15 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "comfy-table" version = "6.1.0" @@ -552,7 +574,7 @@ dependencies = [ "bitflags", "byteorder", "chrono", - "clap", + "clap 3.2.22", "crc32fast", "dialoguer", "encoding", @@ -751,7 +773,7 @@ dependencies = [ "base64", "bytesize", "chrono", - "clap", + "clap 4.0.9", "comfy-table", "crossbeam-utils", "csv", @@ -1045,7 +1067,7 @@ dependencies = [ "anyhow", "atty", "chrono", - "clap", + "clap 3.2.22", "file-chunker", "memmap2", "num_cpus", diff --git a/Cargo.toml b/Cargo.toml index 0df35519..9a0291d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] itertools = "*" dashmap = "*" -clap = { version = "3.*", features = ["derive", "cargo"]} +clap = { version = "4.*", features = ["derive", "cargo"]} evtx = { git = "https://github.com/Yamato-Security/hayabusa-evtx.git" , features = ["fast-alloc"] , rev = "95b1c6a" } quick-xml = {version = "0.23.*", features = ["serialize"] } serde = { version = "1.*", features = ["derive"] } diff --git a/rules b/rules index 28c1de32..aaf910cd 160000 --- a/rules +++ b/rules @@ -1 +1 @@ -Subproject commit 28c1de3279a62f2bf9ae01327e0df0fe4fba443a +Subproject commit aaf910cdcaca32e89b0f81b0af4e180228d21eb6 diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 5a29b104..c6aacae5 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -2,7 +2,7 @@ use crate::detections::message::AlertMessage; use crate::detections::pivot::{PivotKeyword, PIVOT_KEYWORD}; use crate::detections::utils; use chrono::{DateTime, Utc}; -use clap::{App, CommandFactory, Parser}; +use clap::{Command, CommandFactory, Parser}; use hashbrown::{HashMap, HashSet}; use lazy_static::lazy_static; use regex::Regex; @@ -12,7 +12,7 @@ use std::sync::RwLock; use terminal_size::{terminal_size, Height, Width}; lazy_static! { - pub static ref CONFIG: RwLock> = RwLock::new(ConfigReader::new()); + pub static ref CONFIG: RwLock = RwLock::new(ConfigReader::new()); pub static ref LEVELMAP: HashMap = { let mut levelmap = HashMap::new(); levelmap.insert("INFORMATIONAL".to_owned(), 1); @@ -50,15 +50,15 @@ lazy_static! { convert_option_vecs_to_hs(CONFIG.read().unwrap().args.exclude_status.as_ref()); } -pub struct ConfigReader<'a> { - pub app: App<'a>, +pub struct ConfigReader { + pub app: Command, pub args: Config, pub headless_help: String, pub event_timeline_config: EventInfoConfig, pub target_eventids: TargetEventIds, } -impl Default for ConfigReader<'_> { +impl Default for ConfigReader { fn default() -> Self { Self::new() } @@ -67,12 +67,12 @@ impl Default for ConfigReader<'_> { #[derive(Parser, Clone)] #[clap( name = "Hayabusa", - usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]", author = "Yamato Security (https://github.com/Yamato-Security/hayabusa) @SecurityYamato)", help_template = "\n{name} {version}\n{author}\n\n{usage-heading}\n {usage}\n\n{all-args}\n", version, term_width = 400 )] +#[command(override_usage = "hayabusa.exe [OTHER-ACTIONS] [OPTIONS]")] pub struct Config { /// Directory of multiple .evtx files #[clap(help_heading = Some("INPUT"), short = 'd', long, value_name = "DIRECTORY")] @@ -221,11 +221,11 @@ pub struct Config { pub contributors: bool, /// Specify additional target file extensions (ex: evtx_data) (ex: evtx1 evtx2) - #[clap(help_heading = Some("ADVANCED"), long = "target-file-ext", multiple_values = true)] + #[clap(help_heading = Some("ADVANCED"), long = "target-file-ext")] pub evtx_file_ext: Option>, /// Ignore rules according to status (ex: experimental) (ex: stable test) - #[clap(help_heading = Some("FILTERING"), long = "exclude-status", multiple_values = true, value_name = "STATUS")] + #[clap(help_heading = Some("FILTERING"), long = "exclude-status", value_name = "STATUS")] pub exclude_status: Option>, /// Specify output profile (minimal, standard, verbose, verbose-all-field-info, verbose-details-and-all-field-info) @@ -253,7 +253,7 @@ pub struct Config { pub html_report: Option, } -impl ConfigReader<'_> { +impl ConfigReader { pub fn new() -> Self { let parse = Config::parse(); let help_term_width = if let Some((Width(w), _)) = *TERM_SIZE {