bin/pwn_bdba_scan in pwn-0.4.921 vs bin/pwn_bdba_scan in pwn-0.4.922
- old
+ new
@@ -2,11 +2,10 @@
# frozen_string_literal: false
require 'cgi'
require 'optparse'
require 'pwn'
-require 'timeout'
require 'yaml'
opts = {}
OptionParser.new do |options|
options.banner = "USAGE:
@@ -31,11 +30,11 @@
options.on('-q', '--queue-timeout', '<Optional - Duration in Seconds for a File to Remain in Queue Prior to Aborting (Default: 5_400)>') do |q|
opts[:queue_timeout] = q
end
- options.on('-a', '--scan-attempts', '<Optional - Number of Attempts to Scan a File if the Scan was Aborted Due to Queue Timeouts (Default: 3)>') do |a|
+ options.on('-a', '--scan-attempts', '<Optional - Number of Attempts to Scan a File if the Scan was Aborted Due to Queue Timeouts or RestClient Exceptions (Default: 3)>') do |a|
opts[:scan_attempts] = a
end
options.on('-R', '--report-only', '<Optional - Only Generate a Black Duck Binary Analysis Scan Report for an Existing Scan (Default: false)>') do |o|
opts[:report_only] = o
@@ -118,11 +117,11 @@
token: token,
product_id: p[:product_id]
)
end
- raise Timeout::Error, "ERROR: BDBA Scan Aborted: #{target_file}"
+ raise IO::TimeoutError, "ERROR: BDBA Scan Aborted: #{target_file}"
end
10.times do
print '.'
sleep 1
@@ -138,13 +137,26 @@
type: report_type,
output_path: report_path
)
puts "\nReport Saved to: #{report_path}"
-rescue Timeout::Error
+rescue IO::TimeoutError,
+ RestClient::Unauthorized,
+ RestClient::Forbidden,
+ RestClient::BadRequest,
+ RestClient::ResourceNotFound,
+ RestClient::InternalServerError,
+ RestClient::BadGateway,
+ RestClient::ServiceUnavailable,
+ RestClient::GatewayTimeout
+
abort_total += 1
- retry if abort_total <= scan_attempts.to_i
+ if abort_total <= scan_attempts.to_i
+ puts 'Sleeping for 60 Seconds and Retrying...'
+ sleep 60
+ retry
+ end
puts 'Scan Attempts Reached - Goodbye.'
exit 1
rescue SystemExit, Interrupt
puts "\nGoodbye."