Add: --level-tuning option's outline

This commit is contained in:
itiB
2022-02-28 21:58:35 +09:00
parent 545119bdfe
commit 276889338d
3 changed files with 28 additions and 1 deletions

0
config/rule_level.txt Normal file
View File

View File

@@ -1,7 +1,7 @@
use crate::detections::print::AlertMessage;
use crate::detections::utils;
use chrono::{DateTime, Utc};
use clap::{App, AppSettings, ArgMatches};
use clap::{App, Arg, AppSettings, ArgMatches};
use hashbrown::HashMap;
use hashbrown::HashSet;
use lazy_static::lazy_static;
@@ -92,6 +92,10 @@ fn build_app<'a>() -> ArgMatches<'a> {
.version("1.1.0")
.author("Yamato Security (https://github.com/Yamato-Security/hayabusa)")
.setting(AppSettings::VersionlessSubcommands)
.arg( // TODO: When update claps to 3.x, these can write in usage texts...
Arg::from_usage("--level-tuning=[RULE_LEVEL_FILE] 'Fix rule file's level'")
.default_value("./config/rule_level.txt")
)
.usage(usages)
.args_from_usage(usages)
.get_matches()

View File

@@ -104,6 +104,29 @@ impl App {
println!();
return;
}
if configs::CONFIG
.read()
.unwrap()
.args.is_present("level-tuning")
{
if let Some(level_tuning_path) = configs::CONFIG.read().unwrap().args.value_of("level-tuning") {
if Path::new(level_tuning_path).exists() {
println!("level-tuning file exist: {}", level_tuning_path);
println!("WIP: level-tuning....");
} else {
AlertMessage::alert(
&mut BufWriter::new(std::io::stderr().lock()),
&format!(
"Need rule_levels.txt file to use --level-tuning option"
),
)
.ok();
return;
}
}
}
if !Path::new("./config").exists() {
AlertMessage::alert(
&mut BufWriter::new(std::io::stderr().lock()),