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

ユーザが対応できないエラーが多く画面に出力されてしまい見栄えが良くない #301

Closed
hitenkoku opened this issue Dec 18, 2021 · 5 comments · Fixed by #310 or #316
Assignees
Labels
enhancement New feature or request Priority:Medium
Milestone

Comments

@hitenkoku
Copy link
Collaborator

hitenkoku commented Dec 18, 2021

背景

関連ライブラリの更新やdeprecated ruleのalias登録漏れなどがあった時にユーザが対応できないエラーが多く画面に出力されてしまい見栄えが良くない

仕様

  • ERRORログ発生時にlogsディレクトリを作成し、errorlog-(YYYYDD_hhmmss).log[以降:エラーログファイル]を作成。エラーログファイルには以下の情報が書かれる
    • 実行時のコマンドラインオプション
    • 発生したエラー(行数文)
  • 検知処理完了時に以下のエラーログファイルが存在している場合に以下の意味を持つ英文を出力する

    発生したerrorは(相対パス)に出力しました。詳細はファイルを見てください。

  • このエラーログファイルの対象は以下の機能での実行時に発生したエラーとする。それ以外は標準入出力に出力ようにする
    • ruleの読み込み
    • evtxの読み込み
    • レコード情報を用いた検知確認
@hitenkoku hitenkoku added this to the v2.0 milestone Dec 18, 2021
@hitenkoku hitenkoku added enhancement New feature or request Priority:Medium labels Dec 18, 2021
@hitenkoku hitenkoku self-assigned this Dec 18, 2021
@hitenkoku hitenkoku modified the milestones: v2.0, v1.0 Dec 18, 2021
@hitenkoku
Copy link
Collaborator Author

仕様確定。以降は候補として挙がっていた要素をメモがてら残しておきます。

  • verboseオプションなしの際はエラーが発生したことを一行で簡単に表示して詳細はverboseオプションをつけて確認するように促す

  • 最後にError Summaryを出すようにする

例:
The following errors occurred:
Failed to parse event files: 200
An error occurred while trying to deserialize evtx stream: 10
Please enable --verbose to check which files are causing errors.
そうすると、見栄えがデフォルトで良くなって、エラーがあった場合は分かるし、調べる方法も分かります。
(標準出力でスキャンしている場合は沢山出力がある時は上までスクロールして、エラー情報を探すのは(私の経験では)結構大変なので、最後に出した方が楽の気がします。)
※すぐ実装できないと思うので、リリース後でも良いと思います。一行で簡単に表示するよりエラー数を数えてサマリーで出力した方が実装しやすいかも?

@YamatoSecurity
Copy link
Collaborator

もし可能であれば、毎回デフォルトでエラーファイルが作成されると、テストする時にファイルが大量に作成されて、ずっと消すのは手間がかかるので、-Q --quiet-errors 'Quiet errors mode. Do not display errors or save error logs'というオプションでエラーメッセージを出力・保存しないようにできたらお願いしたいです。(大変でしたら無視してください)

@hitenkoku
Copy link
Collaborator Author

@YamatoSecurity 承りました。対応は可能です。

hitenkoku added a commit that referenced this issue Dec 19, 2021
hitenkoku added a commit that referenced this issue Dec 19, 2021
hitenkoku added a commit that referenced this issue Dec 19, 2021
hitenkoku added a commit that referenced this issue Dec 19, 2021
hitenkoku added a commit that referenced this issue Dec 19, 2021
hitenkoku added a commit that referenced this issue Dec 20, 2021
hitenkoku added a commit that referenced this issue Dec 20, 2021
@hitenkoku hitenkoku reopened this Dec 20, 2021
@hitenkoku
Copy link
Collaborator Author

一旦エラーが出ていたためrevert

@hitenkoku
Copy link
Collaborator Author

ログファイルの削除で発生していた問題についても判明しました。ファイルパスでは小文字で指定しているのですが、大文字小文字を区別せずにそのフォルダの配下にエラーログファイルの作成が行われてしまうということを確認しました。
プログラム内では./logs/errorlog...と指定しているのですが、hayabusa.exeの同一階層にLogsフォルダとかlOgsフォルダがいた場合はそちらの配下にerrorlogを作成してしまうようです。
ただ削除するときには./logs/errorlog...を読み行こうとしてファイルがないからエラーが出るという形のようです

本件、少し前に rustのレポジトリでも対処されたようです……

rust-lang/rust#91464

1.59.0のRustで対応するみたいなのでそれまでは一旦エラーログは削除しない方向で対応しようと思いますがよろしいでしょうか……?それか、logsフォルダをあまりかぶらないであろうhayabusa-logsフォルダなどに改名してしまって対応するという方法もあるかと思いますが……

hitenkoku added a commit that referenced this issue Dec 20, 2021
hitenkoku added a commit that referenced this issue Dec 20, 2021
Squashed commit of the following:

commit 617f121
Author: DustInDark <[email protected]>
Date:   Tue Dec 21 00:57:13 2021 +0900

    fix test typo and merge #301

commit 78926eb
Merge: c492ba1 83d891b
Author: DustInDark <[email protected]>
Date:   Tue Dec 21 00:22:55 2021 +0900

    Merge branch 'main' into feature/output_errorlog_file#301

commit c492ba1
Author: DustInDark <[email protected]>
Date:   Tue Dec 21 00:18:52 2021 +0900

    renamed hayabusa-logs to logs

commit ac01891
Author: DustInDark <[email protected]>
Date:   Mon Dec 20 23:48:48 2021 +0900

    changed output file path deprecated #303

commit dcef677
Author: DustInDark <[email protected]>
Date:   Mon Dec 20 23:47:42 2021 +0900

    removed error file delete logic

commit b09dec2
Author: DustInDark <[email protected]>
Date:   Mon Dec 20 23:46:49 2021 +0900

    fixed -Q option flag #309
hitenkoku added a commit that referenced this issue Dec 20, 2021
hitenkoku added a commit that referenced this issue Dec 21, 2021
- To save error log, created empty folder logs

- fixed output
YamatoSecurity added a commit that referenced this issue Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Priority:Medium
Projects
None yet
2 participants