Merge branch '596-new-feature-exclude-status' of github.com:Yamato-Security/hayabusa into 596-new-feature-exclude-status
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
- Clap Crateパッケージの更新 (#413) (@hitenkoku)
|
- Clap Crateパッケージの更新 (#413) (@hitenkoku)
|
||||||
- オプションの指定がないときに、`--help`と同じ画面出力を行うように変更した。(#387) (@hitenkoku)
|
- オプションの指定がないときに、`--help`と同じ画面出力を行うように変更した。(#387) (@hitenkoku)
|
||||||
- ルール内に`details`フィールドがないときに、`rules/config/default_details.txt`に設定されたデフォルトの出力を行えるようにした。 (#359) (@hitenkoku)
|
- ルール内に`details`フィールドがないときに、`rules/config/default_details.txt`に設定されたデフォルトの出力を行えるようにした。 (#359) (@hitenkoku)
|
||||||
|
- `output` オプションで指定されファイルのサイズを出力するようにした。 (#595) (@hitenkoku)
|
||||||
|
|
||||||
**バグ修正:**
|
**バグ修正:**
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
- Updated clap crate package to version 3. (#413) (@hitnekoku)
|
- Updated clap crate package to version 3. (#413) (@hitnekoku)
|
||||||
- Updated the default usage and help menu. (#387) (@hitenkoku)
|
- Updated the default usage and help menu. (#387) (@hitenkoku)
|
||||||
- Added default details output based on `rules/config/default_details.txt` when no `details` field in a rule is specified. (i.e. Sigma rules) (#359) (@hitenkoku)
|
- Added default details output based on `rules/config/default_details.txt` when no `details` field in a rule is specified. (i.e. Sigma rules) (#359) (@hitenkoku)
|
||||||
|
- Added saved file size output when `output` is specified. (#595) (@hitenkoku)
|
||||||
|
|
||||||
**Bug Fixes:**
|
**Bug Fixes:**
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,14 @@
|
|||||||
|
|
||||||
# Hayabusa について
|
# Hayabusa について
|
||||||
|
|
||||||
Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/)グループによって作られた**Windowsイベントログのファストフォレンジックタイムライン生成**および**スレットハンティングツール**です。 Hayabusaは日本語で[「ハヤブサ」](https://en.wikipedia.org/wiki/Peregrine_falcon)を意味し、ハヤブサが世界で最も速く、狩猟(hunting)に優れ、とても訓練しやすい動物であることから選ばれました。[Rust](https://www.rust-lang.org/) で開発され、マルチスレッドに対応し、可能な限り高速に動作するよう配慮されています。[Sigma](https://github.com/SigmaHQ/Sigma)ルールをHayabusaルール形式に変換する[ツール](https://github.com/Yamato-Security/hayabusa-rules/tree/main/tools/sigmac)も提供しています。Hayabusaの検知ルールもSigmaと同様にYML形式であり、カスタマイズ性や拡張性に優れます。稼働中のシステムで実行してライブ調査することも、複数のシステムからログを収集してオフライン調査することも可能です。(※現時点では、リアルタイムアラートや定期的なスキャンには対応していません。) 出力は一つのCSVタイムラインにまとめられ、Excel、[Timeline Explorer](https://ericzimmerman.github.io/#!index.md)、[Elastic Stack](doc/ElasticStackImport/ElasticStackImport-Japanese.md)等で簡単に分析できるようになります。
|
Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/)グループによって作られた**Windowsイベントログのファストフォレンジックタイムライン生成**および**スレットハンティングツール**です。 Hayabusaは日本語で[「ハヤブサ」](https://en.wikipedia.org/wiki/Peregrine_falcon)を意味し、ハヤブサが世界で最も速く、狩猟(hunting)に優れ、とても訓練しやすい動物であることから選ばれました。[Rust](https://www.rust-lang.org/) で開発され、マルチスレッドに対応し、可能な限り高速に動作するよう配慮されています。[Sigma](https://github.com/SigmaHQ/Sigma)ルールをHayabusaルール形式に変換する[ツール](https://github.com/Yamato-Security/hayabusa-rules/tree/main/tools/sigmac)も提供しています。Hayabusaの検知ルールもSigmaと同様にYML形式であり、カスタマイズ性や拡張性に優れます。稼働中のシステムで実行してライブ調査することも、複数のシステムからログを収集してオフライン調査することも可能です。また、 [Velociraptor](https://docs.velociraptor.app/)と[Hayabusa artifact](https://docs.velociraptor.app/exchange/artifacts/pages/windows.eventlogs.hayabusa/)を用いることで企業向けの広範囲なスレットハンティングとインシデントレスポンスにも活用できます。出力は一つのCSVタイムラインにまとめられ、Excel、[Timeline Explorer](https://ericzimmerman.github.io/#!index.md)、[Elastic Stack](doc/ElasticStackImport/ElasticStackImport-Japanese.md)等で簡単に分析できるようになります。
|
||||||
|
|
||||||
## 目次
|
## 目次
|
||||||
|
|
||||||
- [Hayabusa について](#hayabusa-について)
|
- [Hayabusa について](#hayabusa-について)
|
||||||
- [目次](#目次)
|
- [目次](#目次)
|
||||||
- [主な目的](#主な目的)
|
- [主な目的](#主な目的)
|
||||||
- [スレット(脅威)ハンティング](#スレット脅威ハンティング)
|
- [スレット(脅威)ハンティングと企業向けの広範囲なDFIR](#スレット脅威ハンティングと企業向けの広範囲なdfir)
|
||||||
- [フォレンジックタイムラインの高速生成](#フォレンジックタイムラインの高速生成)
|
- [フォレンジックタイムラインの高速生成](#フォレンジックタイムラインの高速生成)
|
||||||
- [スクリーンショット](#スクリーンショット)
|
- [スクリーンショット](#スクリーンショット)
|
||||||
- [起動画面](#起動画面)
|
- [起動画面](#起動画面)
|
||||||
@@ -41,7 +41,6 @@ Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/)
|
|||||||
- [Elastic Stackダッシュボードでの解析](#elastic-stackダッシュボードでの解析)
|
- [Elastic Stackダッシュボードでの解析](#elastic-stackダッシュボードでの解析)
|
||||||
- [タイムラインのサンプル結果](#タイムラインのサンプル結果)
|
- [タイムラインのサンプル結果](#タイムラインのサンプル結果)
|
||||||
- [特徴&機能](#特徴機能)
|
- [特徴&機能](#特徴機能)
|
||||||
- [予定されている機能](#予定されている機能)
|
|
||||||
- [ダウンロード](#ダウンロード)
|
- [ダウンロード](#ダウンロード)
|
||||||
- [Gitクローン](#gitクローン)
|
- [Gitクローン](#gitクローン)
|
||||||
- [アドバンス: ソースコードからのコンパイル(任意)](#アドバンス-ソースコードからのコンパイル任意)
|
- [アドバンス: ソースコードからのコンパイル(任意)](#アドバンス-ソースコードからのコンパイル任意)
|
||||||
@@ -87,9 +86,11 @@ Hayabusaは、日本の[Yamato Security](https://yamatosecurity.connpass.com/)
|
|||||||
|
|
||||||
## 主な目的
|
## 主な目的
|
||||||
|
|
||||||
### スレット(脅威)ハンティング
|
### スレット(脅威)ハンティングと企業向けの広範囲なDFIR
|
||||||
|
|
||||||
Hayabusaには現在、2300以上のSigmaルールと130以上のHayabusa検知ルールがあり、定期的にルールが追加されています。 最終的な目標はインシデントレスポンスや定期的なスレットハンティングのために、HayabusaエージェントをすべてのWindows端末にインストールして、中央サーバーにアラートを返す仕組みを作ることです。
|
Hayabusaには現在、2300以上のSigmaルールと130以上のHayabusa検知ルールがあり、定期的にルールが追加されています。
|
||||||
|
[Velociraptor](https://docs.velociraptor.app/)の[Hayabusa artifact](https://docs.velociraptor.app/exchange/artifacts/pages/windows.eventlogs.hayabusa/)を用いることで企業向けの広範囲なスレットハンティングだけでなくDFIR(デジタルフォレンジックとインシデントレスポンス)にも無料で利用することが可能です。この2つのオープンソースを組み合わせることで、SIEMが設定されていない環境でも実質的に遡及してSIEMを再現することができます。具体的な方法は[Eric Cupuano](https://twitter.com/eric_capuano)の[こちら](https://www.youtube.com/watch?v=Q1IoGX--814)の動画で学ぶことができます。
|
||||||
|
最終的な目標はインシデントレスポンスや定期的なスレットハンティングのために、HayabusaエージェントをすべてのWindows端末にインストールして、中央サーバーにアラートを返す仕組みを作ることです。
|
||||||
|
|
||||||
### フォレンジックタイムラインの高速生成
|
### フォレンジックタイムラインの高速生成
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ Windowsのイベントログは、
|
|||||||
1)解析が困難なデータ形式であること
|
1)解析が困難なデータ形式であること
|
||||||
2)データの大半がノイズであり調査に有用でないこと
|
2)データの大半がノイズであり調査に有用でないこと
|
||||||
から、従来は非常に長い時間と手間がかかる解析作業となっていました。 Hayabusa は、有用なデータのみを抽出し、専門的なトレーニングを受けた分析者だけでなく、Windowsのシステム管理者であれば誰でも利用できる読みやすい形式で提示することを主な目的としています。
|
から、従来は非常に長い時間と手間がかかる解析作業となっていました。 Hayabusa は、有用なデータのみを抽出し、専門的なトレーニングを受けた分析者だけでなく、Windowsのシステム管理者であれば誰でも利用できる読みやすい形式で提示することを主な目的としています。
|
||||||
[Evtx Explorer](https://ericzimmerman.github.io/#!index.md)や[Event Log Explorer](https://eventlogxp.com/)のような深掘り分析を行うツールの代替ではなく、分析者が20%の時間で80%の作業を行えるようにすることを目的としています。
|
Hayabusaは従来のWindowsイベントログ分析解析と比較して、分析者が20%の時間で80%の作業を行えるようにすることを目指しています。
|
||||||
|
|
||||||
# スクリーンショット
|
# スクリーンショット
|
||||||
|
|
||||||
@@ -160,11 +161,7 @@ CSVのタイムラインをElastic Stackにインポートする方法は[こち
|
|||||||
* イベントログから不審なユーザやファイルを素早く特定するためのピボットキーワードの一覧作成。
|
* イベントログから不審なユーザやファイルを素早く特定するためのピボットキーワードの一覧作成。
|
||||||
* 詳細な調査のために全フィールド情報の出力。
|
* 詳細な調査のために全フィールド情報の出力。
|
||||||
* 成功と失敗したユーザログオンの要約。
|
* 成功と失敗したユーザログオンの要約。
|
||||||
|
* [Velociraptor](https://docs.velociraptor.app/)と組み合わせた企業向けの広範囲なすべてのエンドポイントに対するスレットハンティングとDFIR。
|
||||||
# 予定されている機能
|
|
||||||
|
|
||||||
* すべてのエンドポイントでの企業全体のスレットハンティング。
|
|
||||||
* MITRE ATT&CKのヒートマップ生成機能。
|
|
||||||
|
|
||||||
# ダウンロード
|
# ダウンロード
|
||||||
|
|
||||||
@@ -729,6 +726,7 @@ Windows機での悪性な活動を検知する為には、デフォルトのロ
|
|||||||
|
|
||||||
## 英語
|
## 英語
|
||||||
|
|
||||||
|
* 2022/06/19 [VelociraptorチュートリアルとHayabusaの統合方法](https://www.youtube.com/watch?v=Q1IoGX--814) by [Eric Cupuano](https://twitter.com/eric_capuano)
|
||||||
* 2022/01/24 [Hayabusa結果をneo4jで可視化する方法](https://www.youtube.com/watch?v=7sQqz2ek-ko) by Matthew Seyer ([@forensic_matt](https://twitter.com/forensic_matt))
|
* 2022/01/24 [Hayabusa結果をneo4jで可視化する方法](https://www.youtube.com/watch?v=7sQqz2ek-ko) by Matthew Seyer ([@forensic_matt](https://twitter.com/forensic_matt))
|
||||||
|
|
||||||
## 日本語
|
## 日本語
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -20,14 +20,14 @@
|
|||||||
|
|
||||||
# About Hayabusa
|
# About Hayabusa
|
||||||
|
|
||||||
Hayabusa is a **Windows event log fast forensics timeline generator** and **threat hunting tool** created by the [Yamato Security](https://yamatosecurity.connpass.com/) group in Japan. Hayabusa means ["peregrine falcon"](https://en.wikipedia.org/wiki/Peregrine_falcon") in Japanese and was chosen as peregrine falcons are the fastest animal in the world, great at hunting and highly trainable. It is written in [Rust](https://www.rust-lang.org/) and supports multi-threading in order to be as fast as possible. We have provided a [tool](https://github.com/Yamato-Security/hayabusa-rules/tree/main/tools/sigmac) to convert [sigma](https://github.com/SigmaHQ/sigma) rules into hayabusa rule format. The hayabusa detection rules are based on sigma rules, written in YML in order to be as easily customizable and extensible as possible. It can be run either on running systems for live analysis or by gathering logs from multiple systems for offline analysis. (At the moment, it does not support real-time alerting or periodic scans.) The output will be consolidated into a single CSV timeline for easy analysis in Excel, [Timeline Explorer](https://ericzimmerman.github.io/#!index.md), or [Elastic Stack](doc/ElasticStackImport/ElasticStackImport-English.md).
|
Hayabusa is a **Windows event log fast forensics timeline generator** and **threat hunting tool** created by the [Yamato Security](https://yamatosecurity.connpass.com/) group in Japan. Hayabusa means ["peregrine falcon"](https://en.wikipedia.org/wiki/Peregrine_falcon") in Japanese and was chosen as peregrine falcons are the fastest animal in the world, great at hunting and highly trainable. It is written in [Rust](https://www.rust-lang.org/) and supports multi-threading in order to be as fast as possible. We have provided a [tool](https://github.com/Yamato-Security/hayabusa-rules/tree/main/tools/sigmac) to convert [Sigma](https://github.com/SigmaHQ/sigma) rules into Hayabusa rule format. The Sigma-compatible Hayabusa detection rules are written in YML in order to be as easily customizable and extensible as possible. Hayabusa can be run either on single running systems for live analysis, by gathering logs from single or multiple systems for offline analysis, or by running the [Hayabusa artifact](https://docs.velociraptor.app/exchange/artifacts/pages/windows.eventlogs.hayabusa/) with [Velociraptor](https://docs.velociraptor.app/) for enterprise-wide threat hunting and incident response. The output will be consolidated into a single CSV timeline for easy analysis in Excel, [Timeline Explorer](https://ericzimmerman.github.io/#!index.md), or [Elastic Stack](doc/ElasticStackImport/ElasticStackImport-English.md).
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [About Hayabusa](#about-hayabusa)
|
- [About Hayabusa](#about-hayabusa)
|
||||||
- [Table of Contents](#table-of-contents)
|
- [Table of Contents](#table-of-contents)
|
||||||
- [Main Goals](#main-goals)
|
- [Main Goals](#main-goals)
|
||||||
- [Threat Hunting](#threat-hunting)
|
- [Threat Hunting and Enterprise-wide DFIR](#threat-hunting-and-enterprise-wide-dfir)
|
||||||
- [Fast Forensics Timeline Generation](#fast-forensics-timeline-generation)
|
- [Fast Forensics Timeline Generation](#fast-forensics-timeline-generation)
|
||||||
- [Screenshots](#screenshots)
|
- [Screenshots](#screenshots)
|
||||||
- [Startup](#startup)
|
- [Startup](#startup)
|
||||||
@@ -40,7 +40,6 @@ Hayabusa is a **Windows event log fast forensics timeline generator** and **thre
|
|||||||
- [Analysis with the Elastic Stack Dashboard](#analysis-with-the-elastic-stack-dashboard)
|
- [Analysis with the Elastic Stack Dashboard](#analysis-with-the-elastic-stack-dashboard)
|
||||||
- [Analyzing Sample Timeline Results](#analyzing-sample-timeline-results)
|
- [Analyzing Sample Timeline Results](#analyzing-sample-timeline-results)
|
||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Planned Features](#planned-features)
|
|
||||||
- [Downloads](#downloads)
|
- [Downloads](#downloads)
|
||||||
- [Git cloning](#git-cloning)
|
- [Git cloning](#git-cloning)
|
||||||
- [Advanced: Compiling From Source (Optional)](#advanced-compiling-from-source-optional)
|
- [Advanced: Compiling From Source (Optional)](#advanced-compiling-from-source-optional)
|
||||||
@@ -86,14 +85,14 @@ Hayabusa is a **Windows event log fast forensics timeline generator** and **thre
|
|||||||
|
|
||||||
## Main Goals
|
## Main Goals
|
||||||
|
|
||||||
### Threat Hunting
|
### Threat Hunting and Enterprise-wide DFIR
|
||||||
|
|
||||||
Hayabusa currently has over 2300 sigma rules and over 130 hayabusa rules with more rules being added regularly. The ultimate goal is to be able to push out hayabusa agents to all Windows endpoints after an incident or for periodic threat hunting and have them alert back to a central server.
|
Hayabusa currently has over 2400 Sigma rules and over 130 Hayabusa built-in detection rules with more rules being added regularly. It can be used for enterprise-wide proactive threat hunting as well as DFIR (Digital Forensics and Incident Response) for free with [Velociraptor](https://docs.velociraptor.app/)'s [Hayabusa artifact](https://docs.velociraptor.app/exchange/artifacts/pages/windows.eventlogs.hayabusa/). By combining these two open-source tools, you can essentially retroactively reproduce a SIEM when there is no SIEM setup in the environment. You can learn about how to do this by watching [Eric Cupuano](https://twitter.com/eric_capuano)'s Velociraptor walkthrough [here](https://www.youtube.com/watch?v=Q1IoGX--814).
|
||||||
|
|
||||||
### Fast Forensics Timeline Generation
|
### Fast Forensics Timeline Generation
|
||||||
|
|
||||||
Windows event log analysis has traditionally been a very long and tedious process because Windows event logs are 1) in a data format that is hard to analyze and 2) the majority of data is noise and not useful for investigations. Hayabusa's main goal is to extract out only useful data and present it in an easy-to-read format that is usable not only by professionally trained analysts but any Windows system administrator.
|
Windows event log analysis has traditionally been a very long and tedious process because Windows event logs are 1) in a data format that is hard to analyze and 2) the majority of data is noise and not useful for investigations. Hayabusa's goal is to extract out only useful data and present it in a concise as possible easy-to-read format that is usable not only by professionally trained analysts but any Windows system administrator.
|
||||||
Hayabusa is not intended to be a replacement for tools like [Evtx Explorer](https://ericzimmerman.github.io/#!index.md) or [Event Log Explorer](https://eventlogxp.com/) for more deep-dive analysis but is intended for letting analysts get 80% of their work done in 20% of the time.
|
Hayabusa hopes to let analysts get 80% of their work done in 20% of the time when compared to traditional Windows event log analysis.
|
||||||
|
|
||||||
# Screenshots
|
# Screenshots
|
||||||
|
|
||||||
@@ -155,15 +154,11 @@ You can learn how to import CSV files into Elastic Stack [here](doc/ElasticStack
|
|||||||
* Create a list of unique pivot keywords to quickly identify abnormal users, hostnames, processes, etc... as well as correlate events.
|
* Create a list of unique pivot keywords to quickly identify abnormal users, hostnames, processes, etc... as well as correlate events.
|
||||||
* Output all fields for more thorough investigations.
|
* Output all fields for more thorough investigations.
|
||||||
* Successful and failed logon summary.
|
* Successful and failed logon summary.
|
||||||
|
* Enterprise-wide threat hunting and DFIR on all endpoints with [Velociraptor](https://docs.velociraptor.app/).
|
||||||
# Planned Features
|
|
||||||
|
|
||||||
* Enterprise-wide hunting on all endpoints.
|
|
||||||
* MITRE ATT&CK heatmap generation.
|
|
||||||
|
|
||||||
# Downloads
|
# Downloads
|
||||||
|
|
||||||
Please download the latest stable version of hayabusa with compiled binaries or the source code from the [Releases](https://github.com/Yamato-Security/hayabusa/releases) page.
|
Please download the latest stable version of Hayabusa with compiled binaries or compile the source code from the [Releases](https://github.com/Yamato-Security/hayabusa/releases) page.
|
||||||
|
|
||||||
# Git cloning
|
# Git cloning
|
||||||
|
|
||||||
@@ -188,7 +183,7 @@ If the update fails, you may need to rename the `rules` folder and try again.
|
|||||||
>> Caution: When updating, rules and config files in the `rules` folder are replaced with the latest rules and config files in the [hayabusa-rules](https://github.com/Yamato-Security/hayabusa-rules) repository.
|
>> Caution: When updating, rules and config files in the `rules` folder are replaced with the latest rules and config files in the [hayabusa-rules](https://github.com/Yamato-Security/hayabusa-rules) repository.
|
||||||
>> Any changes you make to existing files will be overwritten, so we recommend that you make backups of any files that you edit before updating.
|
>> Any changes you make to existing files will be overwritten, so we recommend that you make backups of any files that you edit before updating.
|
||||||
>> If you are performing level tuning with `--level-tuning`, please re-tune your rule files after each update.
|
>> If you are performing level tuning with `--level-tuning`, please re-tune your rule files after each update.
|
||||||
>> If you add new rules inside of the `rules` folder, they will **not** be overwritten or deleted when updating.
|
>> If you add **new** rules inside of the `rules` folder, they will **not** be overwritten or deleted when updating.
|
||||||
|
|
||||||
# Advanced: Compiling From Source (Optional)
|
# Advanced: Compiling From Source (Optional)
|
||||||
|
|
||||||
@@ -727,6 +722,7 @@ To create the most forensic evidence and detect with the highest accuracy, you n
|
|||||||
|
|
||||||
## English
|
## English
|
||||||
|
|
||||||
|
* 2022/06/19 [Velociraptor Walkthrough and Hayabusa Integration](https://www.youtube.com/watch?v=Q1IoGX--814) by [Eric Cupuano](https://twitter.com/eric_capuano)
|
||||||
* 2022/01/24 [Graphing Hayabusa results in neo4j](https://www.youtube.com/watch?v=7sQqz2ek-ko) by Matthew Seyer ([@forensic_matt](https://twitter.com/forensic_matt))
|
* 2022/01/24 [Graphing Hayabusa results in neo4j](https://www.youtube.com/watch?v=7sQqz2ek-ko) by Matthew Seyer ([@forensic_matt](https://twitter.com/forensic_matt))
|
||||||
|
|
||||||
## Japanese
|
## Japanese
|
||||||
|
|||||||
2
rules
2
rules
Submodule rules updated: 4d5b76a37d...8c14d12be3
@@ -3,7 +3,8 @@ use crate::detections::configs::TERM_SIZE;
|
|||||||
use crate::detections::print;
|
use crate::detections::print;
|
||||||
use crate::detections::print::{AlertMessage, IS_HIDE_RECORD_ID};
|
use crate::detections::print::{AlertMessage, IS_HIDE_RECORD_ID};
|
||||||
use crate::detections::utils;
|
use crate::detections::utils;
|
||||||
use crate::detections::utils::write_color_buffer;
|
use crate::detections::utils::{get_writable_color, write_color_buffer};
|
||||||
|
use bytesize::ByteSize;
|
||||||
use chrono::{DateTime, Local, TimeZone, Utc};
|
use chrono::{DateTime, Local, TimeZone, Utc};
|
||||||
use csv::QuoteStyle;
|
use csv::QuoteStyle;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
@@ -13,6 +14,7 @@ use lazy_static::lazy_static;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::BufWriter;
|
use std::io::BufWriter;
|
||||||
@@ -358,10 +360,32 @@ fn emit_csv<W: std::io::Write>(
|
|||||||
wtr.flush()?;
|
wtr.flush()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let output_path = configs::CONFIG.read().unwrap().args.output.clone();
|
||||||
|
if let Some(path) = output_path {
|
||||||
|
if let Ok(metadata) = fs::metadata(path) {
|
||||||
|
println!(
|
||||||
|
"Saved file: {} ({})",
|
||||||
|
configs::CONFIG
|
||||||
|
.read()
|
||||||
|
.unwrap()
|
||||||
|
.args
|
||||||
|
.output
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.display(),
|
||||||
|
ByteSize::b(metadata.len()).to_string_as(false)
|
||||||
|
);
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
disp_wtr_buf.clear();
|
disp_wtr_buf.clear();
|
||||||
disp_wtr_buf.set_color(ColorSpec::new().set_fg(None)).ok();
|
write_color_buffer(
|
||||||
writeln!(disp_wtr_buf, "Results Summary:").ok();
|
&disp_wtr,
|
||||||
disp_wtr.print(&disp_wtr_buf).ok();
|
get_writable_color(Some(Color::Green)),
|
||||||
|
"Results Summary:",
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
|
||||||
let terminal_width = match *TERM_SIZE {
|
let terminal_width = match *TERM_SIZE {
|
||||||
Some((Width(w), _)) => w as usize,
|
Some((Width(w), _)) => w as usize,
|
||||||
@@ -379,11 +403,22 @@ fn emit_csv<W: std::io::Write>(
|
|||||||
} else {
|
} else {
|
||||||
(reducted_record_cnt as f64) / (all_record_cnt as f64) * 100.0
|
(reducted_record_cnt as f64) / (all_record_cnt as f64) * 100.0
|
||||||
};
|
};
|
||||||
println!("Total events: {}", all_record_cnt);
|
write_color_buffer(
|
||||||
println!(
|
&disp_wtr,
|
||||||
|
get_writable_color(None),
|
||||||
|
&format!("Total events: {}", all_record_cnt),
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
write_color_buffer(
|
||||||
|
&disp_wtr,
|
||||||
|
get_writable_color(None),
|
||||||
|
&format!(
|
||||||
"Data reduction: {} events ({:.2}%)",
|
"Data reduction: {} events ({:.2}%)",
|
||||||
reducted_record_cnt, reducted_percent
|
reducted_record_cnt, reducted_percent
|
||||||
);
|
),
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
println!();
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
_print_unique_results(
|
_print_unique_results(
|
||||||
|
|||||||
@@ -252,6 +252,15 @@ pub fn write_color_buffer(
|
|||||||
wtr.print(&buf)
|
wtr.print(&buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// no-colorのオプションの指定があるかを確認し、指定されている場合はNoneをかえし、指定されていない場合は引数で指定されたColorをSomeでラップして返す関数
|
||||||
|
pub fn get_writable_color(color: Option<Color>) -> Option<Color> {
|
||||||
|
if configs::CONFIG.read().unwrap().args.no_color {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CSVのrecord infoカラムに出力する文字列を作る
|
* CSVのrecord infoカラムに出力する文字列を作る
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user