23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/zapr.rb', line 23
def execute
signal_usage_error "Path to ZAP must be set" unless zap_path
signal_usage_error "Path to ZAP does not exist" unless File.file?(zap_path)
signal_usage_error "Invalid target URL" unless target =~ /\A#{URI::regexp(['http', 'https'])}\z/
begin
zap = Zapr::Proxy.new(target, zap_path, timeout)
debug? ? zap.start : dev_null { zap.start }
zap.spider
zap.attack
puts summary? ? zap.summary : zap.pretty_alerts
rescue Timeout::Error
puts "=====> Timeout".red
puts "the execution of the spider or scan took too long"
exit 124
rescue Exception => e
puts "=====> An error occured".red
puts e.message
puts e.backtrace.join("\n")
exit 125
ensure
zap.shutdown if defined? zap
end
exit zap.exit_code if detailed_exit_codes?
end
|