-
Notifications
You must be signed in to change notification settings - Fork 211
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
Feature/str exact match#79 #100
Conversation
ちょっと、気になる部分があって、parse_selection_recursively()という関数に引数を追加している部分ですね。 |
あと、テストケースを書いてほしいです。 |
c26a9fd
to
02154bb
Compare
@itiB |
@itiB ちょっと、気になったのは以下の部分です。 ハイプに間違ったキーワードを指定した場合のエラー出力をしたい。
new()関数に実装している内容をinit()関数に移動したい。
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ichiichi11 さんのレビューコメントを追加しておきました。とりあえずCommentで出しておきます
src/detections/rule.rs
Outdated
let mut fixed_key_list = Vec::new(); | ||
for key in &key_list { | ||
if key.contains('|') { | ||
let v: Vec<&str> = key.split('|').collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ichiichi11 さんの記載に関連するところをコードと紐づけてレビューに入れておきました。(レビュー内容とコメントでのやり取りを容易にするため)
ハイプに間違ったキーワードを指定した場合のエラー出力をしたい。
例えば、今の実装だと、"contains"と書くべきところを"contain"と書いた場合、書き間違いに気づけないという問題があるかなと思います。
SelectionNodeトレイトを実装した構造体にはinit()という関数があって、この戻り値にResult::Errを返すと、detection.rsのparse_rule_filesでルールファイルのパースエラーを出力するような感じになっています。
パイプ(|)で指定できるのは、startsWithとendsWithとcontainsの3つだけだったと思うので、それ以外の文字列がハイプに指定されていた場合、init関数でエラー出力されるようにしてほしいです。あと、現状パイプが複数あることもないと思うので、その場合もエラーにしてほしいです。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
パイプでつなげられたものを含めてエラーが出るように変更しました、
また下のほうにエラーが出ることを確認するテストケースを追加しました。
こうやって new()
と init()
を使い分けるのですね....いままであんまり考えずに書いていました😥
指摘ありがとうございます!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itiB
いい感じなので、マージしました。
new() と init() を使い分けについては、今回は自分がそういう意図で設計していたので、指摘させてもらいました。こういうファイルをパースするような時の実装方法・設計方針は色々あると思うので、必ずしもこの方法が良いという感じではないです。
最初にSelectionNodeとかLeafMatcherとかのトレイト作ったのは私で、自分以外の人に設計意図が伝わらないソースを書いてしまったという私の問題かなーと思いました。もうちょっと、コメントを書くようにします。
@itiB さん 私の方でも確認致しました。動作として問題ないと思います。 @ichiichi11 さんのコメントはやり取りをConversationで管理したほうが良いと思いますので私のレビューのほうに入れておきました。 |
StartsWithとEndsWith、Containsの実装を行い正規表現以外の一致ルールを作成する。
close #79