Skip to content

Commit ac6cbed

Browse files
committed
fix(scanner): fix Division-by-Zero
1 parent 4c983b1 commit ac6cbed

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/scanning/file_scanner.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,15 @@ pub async fn scan_file(path: String) {
157157
0.0
158158
};
159159

160-
let percent = format!("{:.2}", (processed_count as f64 / total_found_count as f64) * 100.0);
160+
let percent = if total_found_count > 0 {
161+
format!("{:.2}", (total_found_count as f64 / processed_count as f64) * 100.0)
162+
} else {
163+
"0.00".to_string()
164+
};
161165

162166
logger::info(
163167
format!(
164-
"File scan finished in {}. Found {} servers from {} targets. ({}% {}{})",
168+
"File scan finished in {}. Found {} servers from {} targets, {}%. ({}{})",
165169
format_time(elapsed_time.as_secs()).hex(DefaultColor::Highlight.hex()),
166170
total_found_count.hex(DefaultColor::Highlight.hex()),
167171
total_targets.hex(DefaultColor::Highlight.hex()),

0 commit comments

Comments
 (0)