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

@@ -3,6 +3,7 @@ extern crate csv;
extern crate regex;
use crate::detections::configs;
use termcolor::Color;
use tokio::runtime::Builder;
use tokio::runtime::Runtime;
@@ -12,11 +13,13 @@ use regex::Regex;
use serde_json::Value;
use std::cmp::Ordering;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::{BufRead, BufReader};
use std::str;
use std::string::String;
use std::vec;
use termcolor::{BufferWriter, ColorSpec, WriteColor};
use super::detection::EvtxRecordInfo;
@@ -239,6 +242,20 @@ pub fn create_rec_info(data: Value, path: String, keys: &[String]) -> EvtxRecord
}
}
/**
* 標準出力のカラー出力設定を指定した値に変更し画面出力を行う関数
*/
pub fn write_color_buffer(
wtr: BufferWriter,
color: Option<Color>,
output_str: &str,
) -> io::Result<()> {
let mut buf = wtr.buffer();
buf.set_color(ColorSpec::new().set_fg(color)).ok();
writeln!(buf, "{}", output_str).ok();
wtr.print(&buf)
}
/**
* CSVのrecord infoカラムに出力する文字列を作る
*/