Skip to content

Commit

Permalink
Merge pull request #1481 from Yamato-Security/1480-color-update
Browse files Browse the repository at this point in the history
update color scheme
  • Loading branch information
YamatoSecurity authored Nov 9, 2024
2 parents bf754af + ad00cce commit 4ed05cf
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-Japanese.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- `yaml-rust`クレートを`yaml-rust2`に更新した。(#461) (@yamatosecurity)
- `windash`文字が、`rules/config/windash_characters.txt`から動的に読み込まれるようになった。(#1440) (@fukusuket)
- `logon-summary`コマンドがRDPイベントからのログオン情報を表示するようになった。注意: ファイルに保存する場合、Hayabusaはより詳細な情報を出力する。(#1468) (@fukusuket)
- 見やすくなるように色を更新した。 (#1480) (@yamatosecurity)

**バグ修正:**

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Updated the `yaml-rust` crate to `yaml-rust2`. (#461) (@yamatosecurity)
- `windash` characters are now being dynamically read from `rules/config/windash_characters.txt`. (#1440) (@fukusuket)
- `logon-summary` command now displays logon information from RDP events. Note: Hayabusa will output more detailed information when saving to a file. (#1468) (@fukusuket)
- The colors were updated to make it easier to read. (#1480) (@yamatosecurity)

**Bug Fixes:**

Expand Down
27 changes: 19 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ bytesize = "1.*"
chrono = "0.4.*"
cidr-utils = "0.6.*"
clap = { version = "4.*", features = ["derive", "cargo", "color"]}
colored = "2"
comfy-table = "7.*"
compact_str = "0.8.*"
console = "0.15.*"
Expand Down
2 changes: 1 addition & 1 deletion rules
36 changes: 29 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::{
use bytesize::ByteSize;
use chrono::{DateTime, Datelike, Local, NaiveDateTime, Utc};
use clap::Command;
use colored::Colorize;
use compact_str::CompactString;
use console::{style, Style};
use dialoguer::Confirm;
Expand Down Expand Up @@ -779,7 +780,7 @@ impl App {
for profile in profile_list.iter() {
write_color_buffer(
&BufferWriter::stdout(ColorChoice::Always),
Some(Color::Green),
Some(Color::Rgb(0, 255, 0)),
&format!("- {:<25}", &format!("{}:", profile[0])),
false,
)
Expand Down Expand Up @@ -1243,7 +1244,21 @@ impl App {
unpicked_item_prefix: style(" ".to_string()).for_stderr(),
}
} else {
ColorfulTheme::default()
ColorfulTheme {
active_item_prefix: Style::new().color256(214).apply_to("❯".to_string()), // orange
checked_item_prefix: Style::new().color256(46).apply_to("✔".to_string()), // green
picked_item_prefix: Style::new().color256(214).apply_to("❯".to_string()), // orange
active_item_style: Style::new().color256(51), // cyan
values_style: Style::new().color256(46), // green
prompt_prefix: Style::new().color256(214).apply_to("?".to_string()), // orange
prompt_suffix: Style::new().color256(15).apply_to("›".to_string()), // cyan
defaults_style: Style::new().color256(51), // cyan
hint_style: Style::new().color256(214), // orange
success_prefix: Style::new().color256(46).apply_to("✔".to_string()), // green
success_suffix: Style::new().color256(15).apply_to("·".to_string()), // white
error_prefix: Style::new().color256(9).apply_to("✘".to_string()), // red
..Default::default()
}
};
let selected_index = Select::with_theme(&color_theme)
.with_prompt("Which set of detection rules would you like to load?")
Expand Down Expand Up @@ -1539,20 +1554,27 @@ impl App {
}

let template = if stored_static.common_options.no_color {
"[{elapsed_precise}] {human_pos} / {human_len} {spinner} [{bar:40}] {percent}%\r\n\r\n{msg}"
"[{elapsed_precise}] {human_pos} / {human_len} {spinner} [{bar:40}] {percent}%\r\n\r\n{msg}".to_string()
} else {
"[{elapsed_precise}] {human_pos} / {human_len} {spinner:.green} [{bar:40.green}] {percent}%\r\n\r\n{msg}"
let spinner = "{spinner}".truecolor(0, 255, 0).to_string();
let bar = "{bar:40}".truecolor(0, 255, 0).to_string();
format!(
"[{{elapsed_precise}}] {{human_pos}} / {{human_len}} {} [{}] {{percent}}%\r\n\r\n{{msg}}",
spinner, bar
)
};
let progress_style = ProgressStyle::with_template(template)

let progress_style = ProgressStyle::with_template(&template) // Pass `&template` here
.unwrap()
.progress_chars("=> ");

let pb = ProgressBar::with_draw_target(
Some(evtx_files.len() as u64),
ProgressDrawTarget::stdout_with_hz(10),
)
.with_tab_width(55);
pb.set_style(progress_style);
// I tried progress bar with low memory option(output log on detection) but it seemts that progress bar didn't go well with low memory option.
// I tried progress bar with low memory option(output log on detection) but it seems that progress bar didn't go well with low memory option.
// I disabled progress bar if low memory option is specified.
let is_show_progress = !stored_static.is_low_memory || stored_static.output_path.is_some();
if is_show_progress {
Expand Down Expand Up @@ -2321,7 +2343,7 @@ impl App {
let output_color = if stored_static.common_options.no_color {
None
} else {
Some(Color::Green)
Some(Color::Rgb(0, 255, 0))
};
write_color_buffer(
&BufferWriter::stdout(ColorChoice::Always),
Expand Down

0 comments on commit 4ed05cf

Please sign in to comment.