Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ルールファイルの読み込みが遅い #254

Closed
hach1yon opened this issue Dec 1, 2021 · 0 comments · Fixed by #260
Closed

ルールファイルの読み込みが遅い #254

hach1yon opened this issue Dec 1, 2021 · 0 comments · Fixed by #260
Assignees
Milestone

Comments

@hach1yon
Copy link
Collaborator

hach1yon commented Dec 1, 2021

正規表現をキャッシュすれば、早くなる

condition_parser.rs ConditionCompiler::new()

        regex_patterns.push(Regex::new(r"^\(").unwrap());
        regex_patterns.push(Regex::new(r"^\)").unwrap());
        regex_patterns.push(Regex::new(r"^ ").unwrap());
        // ^\w+については、sigmaのソースのsigma/tools/sigma/parser/condition.pyのSigmaConditionTokenizerを参考にしている。
        // 上記ソースの(SigmaConditionToken.TOKEN_ID,     re.compile("[\\w*]+")),を参考。
        regex_patterns.push(Regex::new(r"^\w+").unwrap());

condition_parser.rs ConditionCompiler.compile_condition()

let re_pipe = Regex::new(r"\|.*").unwrap();

aggregation_parser.rs AggegationConditionCompiler::new()

        // ここで字句解析するときに使う正規表現の一覧を定義する。
        // ここはSigmaのGithubレポジトリにある、toos/sigma/parser/condition.pyのSigmaConditionTokenizerのtokendefsを参考にしています。
        let mut regex_patterns = vec![];
        regex_patterns.push(Regex::new(r"^count\( *\w* *\)").unwrap()); // countの式
        regex_patterns.push(Regex::new(r"^ ").unwrap());
        regex_patterns.push(Regex::new(r"^by").unwrap());
        regex_patterns.push(Regex::new(r"^==").unwrap());
        regex_patterns.push(Regex::new(r"^<=").unwrap());
        regex_patterns.push(Regex::new(r"^>=").unwrap());
        regex_patterns.push(Regex::new(r"^<").unwrap());
        regex_patterns.push(Regex::new(r"^>").unwrap());
        regex_patterns.push(Regex::new(r"^\w+").unwrap());

aggregation_parser.rs AggegationConditionCompiler.compile_body()

let re_pipe = Regex::new(r"\|.*").unwrap();
@hitenkoku hitenkoku added this to the v2.0 milestone Dec 1, 2021
@hitenkoku hitenkoku modified the milestones: v2.0, v1.0 Dec 1, 2021
hach1yon pushed a commit that referenced this issue Dec 5, 2021
* fixed cached aggregation parser regex #254

* fixed cached condition parser regex #254

* fixed cached condition parser regex re_pipe #254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants