bin/pwn_bdba_scan in pwn-0.4.916 vs bin/pwn_bdba_scan in pwn-0.4.917

- old
+ new

@@ -2,10 +2,11 @@ # frozen_string_literal: false require 'cgi' require 'optparse' require 'pwn' +require 'timeout' require 'yaml' opts = {} OptionParser.new do |options| options.banner = "USAGE: @@ -107,24 +108,20 @@ break if scan_progress_resp[:products].none? { |p| p[:status] == 'B' } || report_only # Cancel queued scan if it's been queued for more than 90 minutes if scan_progress_busy_duration > queue_timeout.to_i - abort_total += 1 puts "Scan Queued for More than #{queue_timeout} Seconds." - puts "Aborting and Re-Queuing Attempt #{abort_total} of #{scan_attempts}..." scan_progress_resp[:products].select { |p| p[:status] == 'B' }.each do |p| puts "Abort Queued Scan: #{p[:name]}" PWN::Plugins::BlackDuckBinaryAnalysis.abort_product_scan( token: token, product_id: p[:product_id] ) end - retry if abort_total <= scan_attempts.to_i - - raise "ERROR: BDBA Scan Aborted: #{target_file}" + raise Timeout::Error, "ERROR: BDBA Scan Aborted: #{target_file}" end 10.times do print '.' sleep 1 @@ -140,9 +137,17 @@ type: report_type, output_path: report_path ) puts "\nReport Saved to: #{report_path}" +rescue Timeout::Error + abort_total += 1 + + puts "Scan Attempt #{abort_total} of #{scan_attempts}..." + retry if abort_total <= scan_attempts.to_i + + puts 'Scan Attempts Reached - Goodbye.' + exit 1 rescue SystemExit, Interrupt puts "\nGoodbye." rescue StandardError => e raise e end