display logo in green (#552)

* added termcolor reset function #537

* added logo green output #537

* fixed test

* cargo fmt

* updated changelog #537

* fixed clippy error

* update logo screenshot

* updated rules

* changed no colored logo when --no-color option is enabled

* fixed colored reset bug when --update-rules option is enabled

* fixed color reset bug when --level-tuning option is enabled

* cargo fmt

Co-authored-by: Tanaka Zakku <71482215+YamatoSecurity@users.noreply.github.com>
This commit is contained in:
DustInDark
2022-05-31 17:06:12 +09:00
committed by GitHub
parent 2653e87588
commit 4c1aa94eba
14 changed files with 202 additions and 191 deletions

View File

@@ -1,9 +1,12 @@
use crate::detections::utils::write_color_buffer;
use crate::detections::{configs, utils};
use crate::filter::RuleExclude;
use crate::yaml::ParseYaml;
use std::collections::HashMap;
use std::fs::{self, File};
use std::io::Write;
use termcolor::{BufferWriter, ColorChoice};
pub struct LevelTuning {}
impl LevelTuning {
@@ -55,7 +58,12 @@ impl LevelTuning {
// Convert rule files
for (path, rule) in rulefile_loader.files {
if let Some(new_level) = tuning_map.get(rule["id"].as_str().unwrap()) {
println!("path: {}", path);
write_color_buffer(
BufferWriter::stdout(ColorChoice::Always),
None,
&format!("path: {}", path),
)
.ok();
let mut content = match fs::read_to_string(&path) {
Ok(_content) => _content,
Err(e) => return Result::Err(e.to_string()),
@@ -85,11 +93,16 @@ impl LevelTuning {
file.write_all(content.as_bytes()).unwrap();
file.flush().unwrap();
println!(
"level: {} -> {}",
rule["level"].as_str().unwrap(),
new_level
);
write_color_buffer(
BufferWriter::stdout(ColorChoice::Always),
None,
&format!(
"level: {} -> {}",
rule["level"].as_str().unwrap(),
new_level
),
)
.ok();
}
}
Result::Ok(())