changed downcast library from mopa to downcast_rs #447 (#450)

This commit is contained in:
DustInDark
2022-03-11 14:49:47 +09:00
committed by GitHub
parent d49d6f6210
commit 04b881cb66
5 changed files with 15 additions and 14 deletions

14
Cargo.lock generated
View File

@@ -495,6 +495,12 @@ version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "downcast-rs"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "dtoa"
version = "0.4.8"
@@ -843,6 +849,7 @@ dependencies = [
"colored",
"csv",
"dotenv",
"downcast-rs",
"evtx",
"flate2",
"git2",
@@ -852,7 +859,6 @@ dependencies = [
"is_elevated",
"lazy_static",
"linked-hash-map",
"mopa",
"num_cpus",
"openssl",
"pbr",
@@ -1299,12 +1305,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "mopa"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a785740271256c230f57462d3b83e52f998433a7062fc18f96d5999474a9f915"
[[package]]
name = "native-tls"
version = "0.2.8"

View File

@@ -23,7 +23,7 @@ yaml-rust = "0.4.*"
linked-hash-map = "0.5.*"
tokio = { version = "1", features = ["full"] }
num_cpus = "1.13.*"
mopa = "0.2.*"
downcast-rs = "1.2.0"
slack-hook = "0.8"
dotenv = "0.15.*"
hhmmss = "*"

View File

@@ -3,7 +3,7 @@ use std::collections::VecDeque;
use yaml_rust::Yaml;
use crate::detections::{detection::EvtxRecordInfo, utils};
use mopa::mopafy;
use downcast_rs::Downcast;
use lazy_static::lazy_static;
lazy_static! {
@@ -15,7 +15,7 @@ lazy_static! {
//
// 新規にLeafMatcherを実装するクラスを作成した場合、
// LeafSelectionNodeのget_matchersクラスの戻り値の配列に新規作成したクラスのインスタンスを追加する。
pub trait LeafMatcher: mopa::Any {
pub trait LeafMatcher: Downcast {
/// 指定されたkey_listにマッチするLeafMatcherであるかどうか判定する。
fn is_target_key(&self, key_list: &[String]) -> bool;
@@ -28,7 +28,7 @@ pub trait LeafMatcher: mopa::Any {
/// ルールファイルの書き方が間違っている等の原因により、正しくルールファイルからパースできない場合、戻り値のResult型でエラーを返してください。
fn init(&mut self, key_list: &[String], select_value: &Yaml) -> Result<(), Vec<String>>;
}
mopafy!(LeafMatcher);
downcast_rs::impl_downcast!(LeafMatcher);
/// 指定された文字数以上であることをチェックするクラス。
pub struct MinlengthMatcher {

View File

@@ -1,13 +1,13 @@
use crate::detections::{detection::EvtxRecordInfo, utils};
use crate::filter::FILTER_REGEX;
use mopa::mopafy;
use downcast_rs::Downcast;
use std::{sync::Arc, vec};
use yaml_rust::Yaml;
use super::matchers;
// Ruleファイルの detection- selection配下のードはこのtraitを実装する。
pub trait SelectionNode: mopa::Any {
pub trait SelectionNode: Downcast {
// 引数で指定されるイベントログのレコードが、条件に一致するかどうかを判定する
// このトレイトを実装する構造体毎に適切な判定処理を書く必要がある。
fn select(&self, event_record: &EvtxRecordInfo) -> bool;
@@ -24,7 +24,7 @@ pub trait SelectionNode: mopa::Any {
// 子孫ノードを取得する(グラフ理論のdescendantと同じ意味)
fn get_descendants(&self) -> Vec<&dyn SelectionNode>;
}
mopafy!(SelectionNode);
downcast_rs::impl_downcast!(SelectionNode);
/// detection - selection配下でAND条件を表すード
pub struct AndSelectionNode {

View File

@@ -1,3 +1,4 @@
extern crate downcast_rs;
extern crate serde;
extern crate serde_derive;