Skip to content

Commit

Permalink
feat: add TXT report generation and update supported formats in scan_…
Browse files Browse the repository at this point in the history
…xss and errors_alerts modules
  • Loading branch information
Kremilly committed Dec 10, 2024
1 parent ce12ea8 commit 69f7cca
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/plugins/reports_xss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ pub struct ReportsXSS;

impl ReportsXSS {

pub fn txt(&self, detections: Vec<(String, usize, String, String)>, output_path: &str) -> Result<(), Box<dyn Error>> {
let mut file = File::create(output_path)?;

writeln!(file, "XSS Detection Report")?;
writeln!(file, "====================")?;

for (table, row_index, column, value) in detections {
writeln!(file, "Table : {}", table)?;
writeln!(file, "Row : {}", row_index)?;
writeln!(file, "Column : {}", column)?;
writeln!(file, "Value : {}", value)?;
writeln!(file, "---------------------")?;
}

ScanAlerts::reports_generated(output_path);
Ok(())
}

pub fn csv(&self, detections: Vec<(String, usize, String, String)>, output_path: &str) -> Result<(), Box<dyn Error>> {
let mut writer = Writer::from_path(output_path)?;
writer.write_record(&["Table", "Row Index", "Column", "Value"])?;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/scan_xss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ impl ScanXSS {
if let Some(file) = &self.file {
if file.ends_with(".csv") {
ReportsXSS.csv(detections, file)?;
} else if file.ends_with(".txt") {
ReportsXSS.txt(detections, file)?;
} else if file.ends_with(".json") {
ReportsXSS.json(detections, file)?;
} else if file.ends_with(".html") || file.ends_with(".htm") {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/errors_alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl ErrorsAlerts {
}

pub fn report_format() {
let message = "Invalid file format, only CSV, HTM, HTML and JSON are supported.";
let message = "Invalid file format, only TXT, CSV, HTM/HTML and JSON are supported.";

println!("{}", "-".repeat(50));
println!(
Expand Down

0 comments on commit 69f7cca

Please sign in to comment.