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

auto completion #1058

Open
kazuminn opened this issue May 27, 2023 · 10 comments · May be fixed by #1340
Open

auto completion #1058

kazuminn opened this issue May 27, 2023 · 10 comments · May be fixed by #1340
Assignees
Labels
under-investigation under investigation to develop

Comments

@kazuminn
Copy link
Collaborator

$ ./target/release/hayabusa csv-timeline -f ../hayabusa-sample-evtx/YamatoSecurity/Sysmon/Sysmon-27-BlockExeWrite_AbusingCertutil.evtx

の状態からusageみたいなものを(他のオプションなど)を表示することが可能なら、便利かもしれない。

今は、

$ ./target/release/hayabusa csv-timeline

とすると、表示できるがこの状態になるように、消さないといけない。

補完もできると、嬉しいかもしれない。

@kazuminn
Copy link
Collaborator Author

linuxのbashとかなら、ソフトウェア側からの何かを提供する形になってるのを聞いたことがありますが、windowsは何もわからない。

@kazuminn
Copy link
Collaborator Author

$ ./target/release/hayabusa csv-timeline -f ../hayabusa-sample-evtx/YamatoSecurity/Sysmon/Sysmon-27-BlockExeWrite_AbusingCertutil.evtx help

みたいに、helpを足すと、ほかのオプションも見れるなども、良いかもしれない。

@kazuminn kazuminn added the under-investigation under investigation to develop label May 27, 2023
@hitenkoku
Copy link
Collaborator

The following issues are managed for completions

#818

@YamatoSecurity
Copy link
Collaborator

@kazuminn ありがとうございます!
hayabusa.exe c<TAB>を押した時にccsv-timelineにタブ補完できたら、凄く楽になるので、コマンドのタブ補完を導入したいのですが、以前Dさんが調べた時に、bash, powershell, command prompt等々それぞれの環境に対応する必要がありそうで、大変そうだったので、一旦放置していると思います。

オプションも結構多いので、オプションを忘れた場合は、hayabusa.exe csv-timeline -f file.exe <TAB>を押した時に、ヘルプメニューが出てきたら、便利だと思いますが、実装が難しいのでは?
今はユーザがhayabusa.exe csv-timelineでヘルプメニューを出してから、コマンドを打てば、途中でオプションを忘れた場合は上を見ればあるので、オプションのタブ補完は優先度低いと思います。

@kazuminn
Copy link
Collaborator Author

kazuminn commented May 3, 2024

bash, powershell, command prompt等々それぞれの環境に対応する必要がありそうで、大変そうだったので、一旦放置していると思います。

clap_completeクレートを使えば、bash, zsh, fish, poweshell, elvish
に対応可能なので、実装してみます。

@kazuminn kazuminn linked a pull request May 3, 2024 that will close this issue
@kazuminn
Copy link
Collaborator Author

kazuminn commented May 3, 2024

@YamatoSecurity
bashで動作を確認できましたが、ユーザー側に設定してもらう必要があります。

ユーザー側で
auto-completeサブコマンドを実行すると、シェルスクリプトを吐いてくれて
そのスクリプトをshellごとの補完システムに合わせて登録すると動きます。

そこが若干面倒なのが、懸念点です。

@YamatoSecurity
Copy link
Collaborator

@kazuminn なるほど、自動的に追加できたら良いと思ったけど、すでに追加されている可能性があるので、ちょっと危ないですね。それを完璧に検知して上書きできなかったら、シェルプロフィールが壊れてしまうので、少し手間がかかるのが残念だけど、仕方なく手動で追加して貰うのが一番無難そうですね。

@YamatoSecurity
Copy link
Collaborator

Hayabusaのscan wizardのようにユーザがどのシェルを使っているか聞いて、それに対応するスクリプトを出力するようにできますか?
例:

? Which shell are you using? ›
❯ 1. Bash
  2. Fish
  3. Zsh
  4. PowerShell

@kazuminn
Copy link
Collaborator Author

kazuminn commented May 4, 2024

@YamatoSecurity scan wizard対応できると思います。やってみます。 💪

@kazuminn
Copy link
Collaborator Author

こちらの別のライブラリを使うと、自動的にintegrateしてくれるかもしれないので、調査してみます。

https://docs.rs/clap_autocomplete/latest/clap_autocomplete/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under-investigation under investigation to develop
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants