From 4d65b345620513a276edf3302121fe5f125d4964 Mon Sep 17 00:00:00 2001 From: Ibrahim Rahhal Date: Fri, 19 Dec 2025 11:08:38 +0300 Subject: [PATCH] markdown export --- src/main.rs | 6 +++--- src/scanners/blast.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index b95ceca..d3e59df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,7 +81,7 @@ enum Commands { )] scan_type: Option, - #[arg(long, help = "Output the result to a file in a specific format. Valid options are json, html, sarif.")] + #[arg(long, help = "Output the result to a file in a specific format. Valid options are json, html, sarif, markdown.")] out_format: Option, #[arg(short, long, help = "Output the result to a file. you can use the out_format option to specify the format of the output file.")] @@ -277,8 +277,8 @@ fn main() { } if let Some(format) = out_format { - if !["json", "html", "sarif"].contains(&format.as_str()) { - eprintln!("Invalid out_format option. Expected one of 'json', 'html', 'sarif'."); + if !["json", "html", "sarif", "markdown"].contains(&format.as_str()) { + eprintln!("Invalid out_format option. Expected one of 'json', 'html', 'sarif', 'markdown'."); std::process::exit(1); } } diff --git a/src/scanners/blast.rs b/src/scanners/blast.rs index b04e14b..343898d 100644 --- a/src/scanners/blast.rs +++ b/src/scanners/blast.rs @@ -292,6 +292,20 @@ pub fn run( utils::terminal::clear_previous_line(); println!("\n\nScan report written to: {}\n\n", out_file.clone()); } + else if out_format == "markdown" { + let report = match utils::api::get_scan_report(&config.get_url(), &config.get_token(), &scan_id, Some("markdown")) { + Ok(markdown) => markdown, + Err(e) => { + eprintln!("\n\nFailed to fetch Markdown report: {}\n\n", e); + std::process::exit(1); + } + }; + *stop_signal.lock().unwrap() = true; + let _ = results_thread.join(); + fs::write(out_file.clone(), report).expect("\n\nFailed to write Markdown file, check if the file path is valid and you have the necessary permissions to write to it."); + utils::terminal::clear_previous_line(); + println!("\n\nScan report written to: {}\n\n", out_file.clone()); + } } }