diff --git a/whitelist.txt b/allowlist.txt similarity index 100% rename from whitelist.txt rename to allowlist.txt diff --git a/doc/AboutRuleCreation-English.md b/doc/AboutRuleCreation-English.md index 0f74e04e..84d8fe82 100644 --- a/doc/AboutRuleCreation-English.md +++ b/doc/AboutRuleCreation-English.md @@ -236,12 +236,12 @@ detection: * value: 文字列による一致(ワイルドカードやパイプを指定することもできます) * min_length: 指定した文字数以上である場合、条件に一致したものとして処理されます。 * regexes: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致した`ものとして処理されます。 -* whitelist: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致していない`ものとして処理されます。 +* allowlist: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致していない`ものとして処理されます。 -### regexes.txtとwhitelist.txt -hayabusaではregexesやwhitelistを使用した組み込みのルールを用意しており、それらのルールはregexes.txtとwhitelist.txtを参照しています。regexes.txtとwhitelist.txtを書き換えることで、参照する全てのルールの挙動を一度に変更することが可能です。 +### regexes.txtとallowlist.txt +hayabusaではregexesやallowlistを使用した組み込みのルールを用意しており、それらのルールはregexes.txtとallowlist.txtを参照しています。regexes.txtとallowlist.txtを書き換えることで、参照する全てのルールの挙動を一度に変更することが可能です。 -また、regexesやwhitelistに指定するファイルは、ユーザーが独自に作成することも可能です。作成する場合、regexes.txtとwhitelist.txtを参考にしてください。 +また、regexesやallowlistに指定するファイルは、ユーザーが独自に作成することも可能です。作成する場合、regexes.txtとallowlist.txtを参考にしてください。 ## condition これまでの記法を用いると、AND条件やOR条件を表現することができますが、ANDやOR等が複雑に入り組んだ条件を定義することは難しい場合があります。その場合、conditionというキーワードを使用することで、複雑な条件式を定義することができます。 diff --git a/doc/AboutRuleCreation-Japanese.md b/doc/AboutRuleCreation-Japanese.md index 8edf925b..0b5023fe 100644 --- a/doc/AboutRuleCreation-Japanese.md +++ b/doc/AboutRuleCreation-Japanese.md @@ -236,12 +236,12 @@ detection: * value: 文字列による一致(ワイルドカードやパイプを指定することもできます) * min_length: 指定した文字数以上である場合、条件に一致したものとして処理されます。 * regexes: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致した`ものとして処理されます。 -* whitelist: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致していない`ものとして処理されます。 +* allowlist: 指定したファイルに記載された正規表現のリストにひとつでも一致すれば、`条件に一致していない`ものとして処理されます。 -### regexes.txtとwhitelist.txt -hayabusaではregexesやwhitelistを使用した組み込みのルールを用意しており、それらのルールはregexes.txtとwhitelist.txtを参照しています。regexes.txtとwhitelist.txtを書き換えることで、参照する全てのルールの挙動を一度に変更することが可能です。 +### regexes.txtとallowlist.txt +hayabusaではregexesやallowlistを使用した組み込みのルールを用意しており、それらのルールはregexes.txtとallowlist.txtを参照しています。regexes.txtとallowlist.txtを書き換えることで、参照する全てのルールの挙動を一度に変更することが可能です。 -また、regexesやwhitelistに指定するファイルは、ユーザーが独自に作成することも可能です。作成する場合、regexes.txtとwhitelist.txtを参考にしてください。 +また、regexesやallowlistに指定するファイルは、ユーザーが独自に作成することも可能です。作成する場合、regexes.txtとallowlist.txtを参考にしてください。 ## condition これまでの記法を用いると、AND条件やOR条件を表現することができますが、ANDやOR等が複雑に入り組んだ条件を定義することは難しい場合があります。その場合、conditionというキーワードを使用することで、複雑な条件式を定義することができます。 diff --git a/rules/System/7045.yml b/rules/System/7045.yml index 00c25384..e0a9fe8a 100644 --- a/rules/System/7045.yml +++ b/rules/System/7045.yml @@ -9,7 +9,7 @@ detection: regexes: ./regexes.txt ImagePath: min_length: 1000 - whitelist: ./whitelist.txt + allowlist: ./allowlist.txt condition: selection falsepositives: - unknown diff --git a/src/detections/rule/matchers.rs b/src/detections/rule/matchers.rs index 81597167..c3c267ce 100644 --- a/src/detections/rule/matchers.rs +++ b/src/detections/rule/matchers.rs @@ -128,25 +128,25 @@ impl LeafMatcher for RegexesFileMatcher { /// ファイルに列挙された文字列に一致する場合に検知するロジックを表す /// DeepBlueCLIのcheck_cmdメソッドの一部に同様の処理が実装されていた。 -pub struct WhitelistFileMatcher { - whitelist_csv_content: Vec, +pub struct AllowlistFileMatcher { + allowlist_csv_content: Vec, } -impl WhitelistFileMatcher { - pub fn new() -> WhitelistFileMatcher { - return WhitelistFileMatcher { - whitelist_csv_content: vec![], +impl AllowlistFileMatcher { + pub fn new() -> AllowlistFileMatcher { + return AllowlistFileMatcher { + allowlist_csv_content: vec![], }; } } -impl LeafMatcher for WhitelistFileMatcher { +impl LeafMatcher for AllowlistFileMatcher { fn is_target_key(&self, key_list: &Vec) -> bool { if key_list.len() != 2 { return false; } - return key_list.get(1).unwrap() == "whitelist"; + return key_list.get(1).unwrap() == "allowlist"; } fn init(&mut self, key_list: &Vec, select_value: &Yaml) -> Result<(), Vec> { @@ -158,28 +158,28 @@ impl LeafMatcher for WhitelistFileMatcher { }; if value.is_none() { let errmsg = format!( - "whitelist value should be String. [key:{}]", + "allowlist value should be String. [key:{}]", utils::concat_selection_key(key_list) ); return Result::Err(vec![errmsg]); } - let whitelist_content = utils::read_txt(&value.unwrap()); - if whitelist_content.is_err() { - return Result::Err(vec![whitelist_content.unwrap_err()]); + let allowlist_content = utils::read_txt(&value.unwrap()); + if allowlist_content.is_err() { + return Result::Err(vec![allowlist_content.unwrap_err()]); } - self.whitelist_csv_content = whitelist_content.unwrap(); + self.allowlist_csv_content = allowlist_content.unwrap(); return Result::Ok(()); } fn is_match(&self, event_value: Option<&Value>) -> bool { return match event_value.unwrap_or(&Value::Null) { - Value::String(s) => !utils::check_whitelist(s, &self.whitelist_csv_content), + Value::String(s) => !utils::check_allowlist(s, &self.allowlist_csv_content), Value::Number(n) => { - !utils::check_whitelist(&n.to_string(), &self.whitelist_csv_content) + !utils::check_allowlist(&n.to_string(), &self.allowlist_csv_content) } - Value::Bool(b) => !utils::check_whitelist(&b.to_string(), &self.whitelist_csv_content), + Value::Bool(b) => !utils::check_allowlist(&b.to_string(), &self.allowlist_csv_content), _ => true, }; } @@ -487,7 +487,7 @@ impl PipeElement { #[cfg(test)] mod tests { use super::super::matchers::{ - DefaultMatcher, MinlengthMatcher, PipeElement, RegexesFileMatcher, WhitelistFileMatcher, + AllowlistFileMatcher, DefaultMatcher, MinlengthMatcher, PipeElement, RegexesFileMatcher, }; use super::super::selectionnodes::{ AndSelectionNode, LeafSelectionNode, OrSelectionNode, SelectionNode, @@ -514,7 +514,7 @@ mod tests { ImagePath: min_length: 1234321 regexes: ./regexes.txt - whitelist: ./whitelist.txt + allowlist: ./allowlist.txt falsepositives: - unknown level: medium @@ -664,7 +664,7 @@ mod tests { ); } - // whitelist.txtが読み込めることを確認 + // allowlist.txtが読み込めることを確認 { let ancestor_node = ancestors[2].as_ref() as &dyn SelectionNode; assert_eq!(ancestor_node.is::(), true); @@ -673,12 +673,12 @@ mod tests { let ancestor_node = &ancestor_node.matcher; assert_eq!(ancestor_node.is_some(), true); let ancestor_matcher = ancestor_node.as_ref().unwrap(); - assert_eq!(ancestor_matcher.is::(), true); + assert_eq!(ancestor_matcher.is::(), true); let ancestor_matcher = ancestor_matcher - .downcast_ref::() + .downcast_ref::() .unwrap(); - let csvcontent = &ancestor_matcher.whitelist_csv_content; + let csvcontent = &ancestor_matcher.allowlist_csv_content; assert_eq!(csvcontent.len(), 2); assert_eq!( @@ -1068,14 +1068,14 @@ mod tests { #[test] fn test_detect_regexes() { // regexes.txtが正しく検知できることを確認 - // この場合ではEventIDが一致しているが、whitelistに一致するので検知しないはず。 + // この場合ではEventIDが一致しているが、allowlistに一致するので検知しないはず。 let rule_str = r#" enabled: true detection: selection: EventID: 4103 Channel: - - whitelist: whitelist.txt + - allowlist: allowlist.txt output: 'command=%CommandLine%' "#; @@ -1098,16 +1098,16 @@ mod tests { } #[test] - fn test_detect_whitelist() { - // whitelistが正しく検知できることを確認 - // この場合ではEventIDが一致しているが、whitelistに一致するので検知しないはず。 + fn test_detect_allowlist() { + // allowlistが正しく検知できることを確認 + // この場合ではEventIDが一致しているが、allowlistに一致するので検知しないはず。 let rule_str = r#" enabled: true detection: selection: EventID: 4103 Channel: - - whitelist: whitelist.txt + - allowlist: allowlist.txt output: 'command=%CommandLine%' "#; @@ -1130,16 +1130,16 @@ mod tests { } #[test] - fn test_detect_whitelist2() { - // whitelistが正しく検知できることを確認 - // この場合ではEventIDが一致しているが、whitelistに一致するので検知しないはず。 + fn test_detect_allowlist2() { + // allowlistが正しく検知できることを確認 + // この場合ではEventIDが一致しているが、allowlistに一致するので検知しないはず。 let rule_str = r#" enabled: true detection: selection: EventID: 4103 Channel: - - whitelist: whitelist.txt + - allowlist: allowlist.txt output: 'command=%CommandLine%' "#; diff --git a/src/detections/rule/selectionnodes.rs b/src/detections/rule/selectionnodes.rs index df1e320f..6a3b0c4a 100644 --- a/src/detections/rule/selectionnodes.rs +++ b/src/detections/rule/selectionnodes.rs @@ -291,7 +291,7 @@ impl LeafSelectionNode { return vec![ Box::new(matchers::MinlengthMatcher::new()), Box::new(matchers::RegexesFileMatcher::new()), - Box::new(matchers::WhitelistFileMatcher::new()), + Box::new(matchers::AllowlistFileMatcher::new()), Box::new(matchers::DefaultMatcher::new()), ]; } diff --git a/src/detections/utils.rs b/src/detections/utils.rs index 2dcd5363..7e27a9f6 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -41,8 +41,8 @@ pub fn check_regex(string: &str, regex_list: &Vec) -> bool { return false; } -pub fn check_whitelist(target: &str, whitelist: &Vec) -> bool { - for line in whitelist { +pub fn check_allowlist(target: &str, allowlist: &Vec) -> bool { + for line in allowlist { if line.is_empty() { continue; } @@ -170,12 +170,12 @@ mod tests { } #[test] - fn test_check_whitelist() { + fn test_check_allowlist() { let commandline = "\"C:\\Program Files\\Google\\Update\\GoogleUpdate.exe\""; - let whitelist = utils::read_txt("whitelist.txt").unwrap(); - assert!(true == utils::check_whitelist(commandline, &whitelist)); + let allowlist = utils::read_txt("allowlist.txt").unwrap(); + assert!(true == utils::check_allowlist(commandline, &allowlist)); let commandline = "\"C:\\Program Files\\Google\\Update\\GoogleUpdate2.exe\""; - assert!(false == utils::check_whitelist(commandline, &whitelist)); + assert!(false == utils::check_allowlist(commandline, &allowlist)); } }