From 916da7fb264911e58bb903b23345c96d8de05316 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Sun, 4 Sep 2022 23:42:20 +0900 Subject: [PATCH] added eventkey_alias.txt to custom config directory check --- src/detections/configs.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index 13cd7a4c..a0c50461 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -23,10 +23,23 @@ lazy_static! { levelmap.insert("CRITICAL".to_owned(), 5); levelmap }; - pub static ref EVENTKEY_ALIAS: EventKeyAliasConfig = load_eventkey_alias(&format!( - "{}/eventkey_alias.txt", - CONFIG.read().unwrap().args.config.as_path().display() - )); + pub static ref EVENTKEY_ALIAS: EventKeyAliasConfig = load_eventkey_alias( + utils::check_setting_path( + &CONFIG.read().unwrap().args.config, + "eventkey_alias.txt", + false + ) + .unwrap_or_else(|| { + utils::check_setting_path( + &CURRENT_EXE_PATH.to_path_buf(), + "rules/config/eventkey_alias.txt", + true, + ) + .unwrap() + }) + .to_str() + .unwrap() + ); pub static ref IDS_REGEX: Regex = Regex::new(r"^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$").unwrap(); pub static ref TERM_SIZE: Option<(Width, Height)> = terminal_size();