@@ -96,13 +96,13 @@ def run
96
96
97
97
loop do
98
98
# Stop scanning if we hit a fatal error
99
- break if @scan_errors . length > 0
99
+ break if has_fatal_errors?
100
100
101
101
# Spawn threads for each host
102
102
while ( @tl . length < threads_max )
103
103
104
104
# Stop scanning if we hit a fatal error
105
- break if @scan_errors . length > 0
105
+ break if has_fatal_errors?
106
106
107
107
ip = ar . next_ip
108
108
break if not ip
@@ -131,7 +131,7 @@ def run
131
131
end
132
132
133
133
# Stop scanning if we hit a fatal error
134
- break if @scan_errors . length > 0
134
+ break if has_fatal_errors?
135
135
136
136
# Exit once we run out of hosts
137
137
if ( @tl . length == 0 )
@@ -152,7 +152,7 @@ def run
152
152
scanner_show_progress ( ) if @show_progress
153
153
end
154
154
155
- scanner_report_fatal_errors
155
+ scanner_handle_fatal_errors
156
156
return
157
157
end
158
158
@@ -171,7 +171,7 @@ def run
171
171
nohosts = false
172
172
173
173
# Stop scanning if we hit a fatal error
174
- break if @scan_errors . length > 0
174
+ break if has_fatal_errors?
175
175
176
176
while ( @tl . length < threads_max )
177
177
@@ -218,7 +218,7 @@ def run
218
218
end
219
219
220
220
# Stop scanning if we hit a fatal error
221
- break if @scan_errors . length > 0
221
+ break if has_fatal_errors?
222
222
223
223
# Exit if there are no more pending threads
224
224
if ( @tl . length == 0 )
@@ -241,7 +241,7 @@ def run
241
241
scanner_show_progress ( ) if @show_progress
242
242
end
243
243
244
- scanner_report_fatal_errors
244
+ scanner_handle_fatal_errors
245
245
return
246
246
end
247
247
@@ -264,8 +264,12 @@ def seppuko!
264
264
end
265
265
end
266
266
267
- def scanner_report_fatal_errors
268
- return unless @scan_errors && @scan_errors . length > 0
267
+ def has_fatal_errors?
268
+ @scan_errors && !@scan_errors . empty?
269
+ end
270
+
271
+ def scanner_handle_fatal_errors
272
+ return unless has_fatal_errors?
269
273
return unless @tl
270
274
271
275
# First kill any running threads
@@ -275,7 +279,7 @@ def scanner_report_fatal_errors
275
279
@scan_errors . uniq . each do |emsg |
276
280
print_error ( "Fatal: #{ emsg } " )
277
281
end
278
- print_status ( "Scan terminated due to one or more fatal errors" )
282
+ print_error ( "Scan terminated due to one or more fatal errors" )
279
283
end
280
284
281
285
def scanner_progress
@@ -284,6 +288,8 @@ def scanner_progress
284
288
end
285
289
286
290
def scanner_show_progress
291
+ # it should already be in the process of shutting down if there are fatal errors
292
+ return if has_fatal_errors?
287
293
pct = scanner_progress
288
294
if pct >= ( @range_percent + @show_percent )
289
295
@range_percent = @range_percent + @show_percent
0 commit comments