From 8ebb09340ac8571008e16f1774ccfcb499914a04 Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Sun, 24 Jul 2022 20:25:52 +0900 Subject: [PATCH] changed crate from hashbrown to std::collections due to be merged hashbrown in std::collections #629 --- src/detections/configs.rs | 2 +- src/detections/rule/condition_parser.rs | 2 +- src/detections/rule/count.rs | 11 +++++------ src/detections/rule/mod.rs | 2 +- src/main.rs | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/detections/configs.rs b/src/detections/configs.rs index ab23ef0a..e9b3b9ca 100644 --- a/src/detections/configs.rs +++ b/src/detections/configs.rs @@ -476,7 +476,7 @@ pub fn load_pivot_keywords(path: &str) { .write() .unwrap() .entry(map[0].to_string()) - .or_insert(PivotKeyword::new()); + .or_insert_with(PivotKeyword::new); PIVOT_KEYWORD .write() diff --git a/src/detections/rule/condition_parser.rs b/src/detections/rule/condition_parser.rs index c06dc96b..cf53a9da 100644 --- a/src/detections/rule/condition_parser.rs +++ b/src/detections/rule/condition_parser.rs @@ -5,7 +5,7 @@ use self::selectionnodes::{ AndSelectionNode, NotSelectionNode, OrSelectionNode, RefSelectionNode, SelectionNode, }; use super::selectionnodes; -use hashbrown::HashMap; +use std::collections::HashMap; use std::sync::Arc; lazy_static! { diff --git a/src/detections/rule/count.rs b/src/detections/rule/count.rs index 8e086e90..a4cbd5e1 100644 --- a/src/detections/rule/count.rs +++ b/src/detections/rule/count.rs @@ -6,7 +6,7 @@ use crate::detections::message::QUIET_ERRORS_FLAG; use crate::detections::rule::AggResult; use crate::detections::rule::RuleNode; use chrono::{DateTime, TimeZone, Utc}; -use hashbrown::HashMap; +use std::collections::HashMap; use serde_json::Value; use std::num::ParseIntError; use std::path::Path; @@ -311,10 +311,9 @@ impl CountStrategy for FieldStrategy { } let value = &datas[idx as usize].field_record_value; - let key_val = self.value_2_cnt.get_key_value_mut(value); + let key_val = self.value_2_cnt.get_mut(value); if let Some(kv) = key_val { - let (_, val) = kv; - *val += 1; + *kv += 1; } else { self.value_2_cnt.insert(value.to_string(), 1); } @@ -326,12 +325,12 @@ impl CountStrategy for FieldStrategy { } let record_value = &datas[idx as usize].field_record_value; - let key_val = self.value_2_cnt.get_key_value_mut(record_value); + let key_val = self.value_2_cnt.get_mut(record_value); if key_val.is_none() { return; } - let val: &mut i64 = key_val.unwrap().1; + let val: &mut i64 = key_val.unwrap(); if val <= &mut 1 { // 0になる場合はキー自体削除する self.value_2_cnt.remove(record_value); diff --git a/src/detections/rule/mod.rs b/src/detections/rule/mod.rs index 60f55011..cceb4c49 100644 --- a/src/detections/rule/mod.rs +++ b/src/detections/rule/mod.rs @@ -2,7 +2,7 @@ extern crate regex; use chrono::{DateTime, Utc}; -use hashbrown::HashMap; +use std::collections::HashMap; use std::{fmt::Debug, sync::Arc, vec}; use yaml_rust::Yaml; diff --git a/src/main.rs b/src/main.rs index 5452427b..a6e7b784 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ extern crate static_vcruntime; use bytesize::ByteSize; use chrono::{DateTime, Datelike, Local}; use evtx::{EvtxParser, ParserSettings}; -use hashbrown::{HashMap, HashSet}; +use std::collections::{HashMap, HashSet}; use hayabusa::detections::configs::CURRENT_EXE_PATH; use hayabusa::detections::configs::{load_pivot_keywords, TargetEventTime, TARGET_EXTENSIONS}; use hayabusa::detections::detection::{self, EvtxRecordInfo};