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
+3 -3
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 {
+3 -3
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 {
+1
View File
@@ -1,3 +1,4 @@
extern crate downcast_rs;
extern crate serde;
extern crate serde_derive;