Skip to content

Commit 5827a79

Browse files
committed
refactor: rename and reorganize alert reporting for improved clarity and functionality
1 parent 09fcd2e commit 5827a79

File tree

6 files changed

+39
-29
lines changed

6 files changed

+39
-29
lines changed

src/core/dump.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{
1818
handlers::dump_handlers::DumpHandlers,
1919

2020
ui::{
21-
normal_alerts::NormalAlerts,
21+
report_alerts::ReportAlerts,
2222
success_alerts::SuccessAlerts
2323
},
2424

@@ -132,7 +132,7 @@ impl Dump {
132132
let dump_count = DUMP_COUNT.load(Ordering::SeqCst);
133133

134134
if let Some(last_dump) = DumpHandlers.get_most_recent_sql_file(&dump_file_path_clone) {
135-
NormalAlerts::report(&dump_file_path_clone, dump_count, &last_dump);
135+
ReportAlerts::report(&dump_file_path_clone, dump_count, &last_dump);
136136
}
137137

138138
SuccessAlerts::terminate();

src/plugins/reports_xss.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use std::{
1010

1111
use crate::{
1212
utils::file::FileUtils,
13-
ui::report_alerts::ReportAlerts,
1413
handlers::html_handlers::HTMLHandlers,
14+
ui::report_xss_alerts::ReportXSSAlerts,
1515

1616
constants::{
1717
urls::Urls,
@@ -50,7 +50,7 @@ impl ReportsXSS {
5050

5151
file.write_all(b"</XSSDetectionReport>\n")?;
5252

53-
ReportAlerts::generated(output_path);
53+
ReportXSSAlerts::generated(output_path);
5454
Ok(())
5555
}
5656

@@ -68,7 +68,7 @@ impl ReportsXSS {
6868
writeln!(file, "---------------------")?;
6969
}
7070

71-
ReportAlerts::generated(output_path);
71+
ReportXSSAlerts::generated(output_path);
7272
Ok(())
7373
}
7474

@@ -87,7 +87,7 @@ impl ReportsXSS {
8787

8888
writer.flush()?;
8989

90-
ReportAlerts::generated(output_path);
90+
ReportXSSAlerts::generated(output_path);
9191
Ok(())
9292
}
9393

@@ -105,7 +105,7 @@ impl ReportsXSS {
105105
let file = File::create(output_path)?;
106106
to_writer_pretty(file, &detections)?;
107107

108-
ReportAlerts::generated(output_path);
108+
ReportXSSAlerts::generated(output_path);
109109
Ok(())
110110
}
111111

@@ -135,7 +135,7 @@ impl ReportsXSS {
135135

136136
file.write_all(b"</table></div></body></html>")?;
137137

138-
ReportAlerts::generated(output_path);
138+
ReportXSSAlerts::generated(output_path);
139139
Ok(())
140140
}
141141

@@ -149,7 +149,7 @@ impl ReportsXSS {
149149
"xml" => self.xml(detections, file_path),
150150
"json" => self.json(detections, file_path),
151151
"html" => self.html(detections, file_path),
152-
_ => Ok(ReportAlerts::invalid_format()),
152+
_ => Ok(ReportXSSAlerts::invalid_format()),
153153
};
154154

155155
result?;

src/ui/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ pub mod ui_base;
33
pub mod scan_alerts;
44
pub mod share_alerts;
55
pub mod schema_alerts;
6-
pub mod report_alerts;
76
pub mod checksum_alerts;
7+
pub mod report_xss_alerts;
88

99
pub mod normal_alerts;
10+
pub mod report_alerts;
1011
pub mod errors_alerts;
1112
pub mod success_alerts;

src/ui/normal_alerts.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,4 @@ impl NormalAlerts {
1919
);
2020
}
2121

22-
pub fn report(dump_file_path: &str, dump_count: usize, last_dump: &str) {
23-
println!("\nFinal Report:\n");
24-
25-
println!("Directory: {}", dump_file_path.bold().blue());
26-
println!("Total number of dumps: {}", dump_count.to_string().bold().blue());
27-
println!("Last dump: {}", last_dump.bold().cyan());
28-
}
29-
3022
}

src/ui/report_alerts.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@ pub struct ReportAlerts;
66

77
impl ReportAlerts {
88

9-
pub fn generated(output_path: &str) {
10-
println!("{}", "-".repeat(50));
11-
println!("Report generated and salved in: {}", output_path.green());
12-
}
13-
14-
pub fn invalid_format() {
15-
let message = "Invalid file format, only TXT, CSV, HTML and JSON are supported.";
9+
pub fn report(dump_file_path: &str, dump_count: usize, last_dump: &str) {
10+
println!("\nFinal Report:\n");
1611

17-
println!("{}", "-".repeat(50));
18-
println!(
19-
"{}", message.red().bold(),
20-
);
12+
println!("Directory: {}", dump_file_path.bold().blue());
13+
println!("Total number of dumps: {}", dump_count.to_string().bold().blue());
14+
println!("Last dump: {}", last_dump.bold().cyan());
2115
}
2216

2317
}

src/ui/report_xss_alerts.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
extern crate colored;
2+
3+
use colored::*;
4+
5+
pub struct ReportXSSAlerts;
6+
7+
impl ReportXSSAlerts {
8+
9+
pub fn generated(output_path: &str) {
10+
println!("{}", "-".repeat(50));
11+
println!("Report generated and salved in: {}", output_path.green());
12+
}
13+
14+
pub fn invalid_format() {
15+
let message = "Invalid file format, only TXT, CSV, HTML and JSON are supported.";
16+
17+
println!("{}", "-".repeat(50));
18+
println!(
19+
"{}", message.red().bold(),
20+
);
21+
}
22+
23+
}

0 commit comments

Comments
 (0)