cargo fmt
This commit is contained in:
@@ -546,7 +546,10 @@ fn emit_csv<W: std::io::Write>(
|
||||
}
|
||||
}
|
||||
if html_output_flag {
|
||||
htmlreport::add_md_data("Results Summary {#results_summary}".to_string(), html_output_stock);
|
||||
htmlreport::add_md_data(
|
||||
"Results Summary {#results_summary}".to_string(),
|
||||
html_output_stock,
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -805,7 +808,11 @@ fn _print_detection_summary_tables(
|
||||
let mut col_color = vec![];
|
||||
for level in LEVEL_ABBR.values() {
|
||||
let mut col_output: Vec<String> = vec![];
|
||||
let header_output = &format!("Top {} alerts: {{#top_{}_alerts}}", LEVEL_FULL.get(level.as_str()).unwrap(), LEVEL_FULL.get(level.as_str()).unwrap());
|
||||
let header_output = &format!(
|
||||
"Top {} alerts: {{#top_{}_alerts}}",
|
||||
LEVEL_FULL.get(level.as_str()).unwrap(),
|
||||
LEVEL_FULL.get(level.as_str()).unwrap()
|
||||
);
|
||||
col_output.push(header_output.to_owned());
|
||||
|
||||
col_color.push(_get_table_color(
|
||||
@@ -825,10 +832,11 @@ fn _print_detection_summary_tables(
|
||||
for x in sorted_detections.iter() {
|
||||
html_output_stock.push(format!(
|
||||
"- [{}]({}) ({})",
|
||||
x.0
|
||||
,rule_title_path_map
|
||||
x.0,
|
||||
rule_title_path_map
|
||||
.get(x.0)
|
||||
.unwrap_or(&"<Not Found Path>".to_string()).replace('\\', "/"),
|
||||
.unwrap_or(&"<Not Found Path>".to_string())
|
||||
.replace('\\', "/"),
|
||||
x.1.to_formatted_string(&Locale::en)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -696,7 +696,10 @@ impl Detection {
|
||||
html_report_stock.push(format!("- {}", tmp_total_detect_output));
|
||||
}
|
||||
if !html_report_stock.is_empty() {
|
||||
htmlreport::add_md_data("General Overview {#general_overview}".to_string(), html_report_stock);
|
||||
htmlreport::add_md_data(
|
||||
"General Overview {#general_overview}".to_string(),
|
||||
html_report_stock,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
src/main.rs
25
src/main.rs
@@ -93,13 +93,14 @@ impl App {
|
||||
}
|
||||
let analysis_start_time: DateTime<Local> = Local::now();
|
||||
if configs::CONFIG.read().unwrap().args.html_report.is_some() {
|
||||
let output_data = vec![
|
||||
format!(
|
||||
"- Start time: {}",
|
||||
analysis_start_time.format("%Y/%m/%d %H:%M")
|
||||
),
|
||||
];
|
||||
htmlreport::add_md_data("General Overview {#general_overview}".to_string(), output_data);
|
||||
let output_data = vec![format!(
|
||||
"- Start time: {}",
|
||||
analysis_start_time.format("%Y/%m/%d %H:%M")
|
||||
)];
|
||||
htmlreport::add_md_data(
|
||||
"General Overview {#general_overview}".to_string(),
|
||||
output_data,
|
||||
);
|
||||
}
|
||||
|
||||
// Show usage when no arguments.
|
||||
@@ -390,7 +391,10 @@ impl App {
|
||||
println!();
|
||||
if configs::CONFIG.read().unwrap().args.html_report.is_some() {
|
||||
let output_data = vec![format!("- {}", elapsed_output_str)];
|
||||
htmlreport::add_md_data("General Overview {#general_overview}".to_string(), output_data);
|
||||
htmlreport::add_md_data(
|
||||
"General Overview {#general_overview}".to_string(),
|
||||
output_data,
|
||||
);
|
||||
}
|
||||
// Qオプションを付けた場合もしくはパースのエラーがない場合はerrorのstackが0となるのでエラーログファイル自体が生成されない。
|
||||
if ERROR_LOG_STACK.lock().unwrap().len() > 0 {
|
||||
@@ -612,7 +616,10 @@ impl App {
|
||||
format!("- Analyzed event files: {}", evtx_files.len()),
|
||||
format!("- {}", total_size_output),
|
||||
];
|
||||
htmlreport::add_md_data("General Overview #{general_overview}".to_string(), output_data);
|
||||
htmlreport::add_md_data(
|
||||
"General Overview #{general_overview}".to_string(),
|
||||
output_data,
|
||||
);
|
||||
}
|
||||
|
||||
let rule_files = detection::Detection::parse_rule_files(
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use crate::detections::message::AlertMessage;
|
||||
use hashbrown::HashMap;
|
||||
use horrorshow::helper::doctype;
|
||||
use horrorshow::prelude::*;
|
||||
use lazy_static::lazy_static;
|
||||
use pulldown_cmark::{html, Options, Parser};
|
||||
use std::fs::create_dir;
|
||||
@@ -8,8 +10,6 @@ use std::io::BufWriter;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::sync::RwLock;
|
||||
use horrorshow::prelude::*;
|
||||
use horrorshow::helper::doctype;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref HTML_REPORTER: RwLock<HtmlReporter> = RwLock::new(HtmlReporter::new());
|
||||
@@ -105,18 +105,21 @@ pub fn create_html_file(input_html: String, path_str: String) {
|
||||
return;
|
||||
}
|
||||
let mut html_writer = BufWriter::new(File::create(path).unwrap());
|
||||
let html_data = format!("{}", html! {
|
||||
: doctype::HTML;
|
||||
html {
|
||||
head {
|
||||
meta(charset="UTF-8");
|
||||
link(rel="stylesheet", type="text/css", href="./hayabusa_report.css");
|
||||
let html_data = format!(
|
||||
"{}",
|
||||
html! {
|
||||
: doctype::HTML;
|
||||
html {
|
||||
head {
|
||||
meta(charset="UTF-8");
|
||||
link(rel="stylesheet", type="text/css", href="./hayabusa_report.css");
|
||||
}
|
||||
body : Raw(input_html.clone().as_str())
|
||||
}
|
||||
body : Raw(input_html.clone().as_str())
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
writeln!(html_writer,"{}", html_data).ok();
|
||||
writeln!(html_writer, "{}", html_data).ok();
|
||||
println!(
|
||||
"HTML Report was generated. Please check {} for details.",
|
||||
path_str
|
||||
@@ -146,9 +149,10 @@ mod tests {
|
||||
"- Elapsed Time: 00:00:29.035".to_string(),
|
||||
"".to_string(),
|
||||
];
|
||||
html_reporter
|
||||
.md_datas
|
||||
.insert("General Overview {#general_overview}".to_string(), general_data.clone());
|
||||
html_reporter.md_datas.insert(
|
||||
"General Overview {#general_overview}".to_string(),
|
||||
general_data.clone(),
|
||||
);
|
||||
let general_overview_str = format!(
|
||||
"<ul>\n<li>{}</li>\n</ul>",
|
||||
general_data[..general_data.len() - 1]
|
||||
|
||||
Reference in New Issue
Block a user