Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enum Commands {
)]
scan_type: Option<String>,

#[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<String>,

#[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.")]
Expand Down Expand Up @@ -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);
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/scanners/blast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Comment on lines +295 to +308
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block duplicates logic from the existing format export blocks. The pattern of fetching the report, stopping the signal, joining the thread, writing the file, and printing the success message is repeated. Consider extracting this common logic into a helper function that takes the format type as a parameter to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
}
}

Expand Down