You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.1 KiB

#!/usr/bin/env ruby
require 'erb'
require 'yaml'
$:.unshift 'lib'
require 'sslcheck'
SCORES = %w(A+ A A- B C D E F T M)
def score(a); SCORES.index a.rank; end
def check(hostname)
hostname.strip!
print ' ', hostname, ' : '
begin
result = SSLCheck::SSLLabs::API.new hostname
puts result.rank
result
rescue SSLCheck::SSLLabs::NoEncryptionError
puts 'no encryption'
raise
rescue => e
puts e
raise
end
end
config = YAML.load_file 'hosts.yml'
results = Hash[config.collect { |c| [c['description'], []] }]
loop do
waiting = false
config.each do |c|
description, hosts = c['description'], c['hostnames']
puts description
hosts.clone.each do |host|
begin
results[description] << check(host)
hosts.delete host
rescue SSLCheck::SSLLabs::WaitingError
waiting = true
rescue SSLCheck::SSLLabs::Error
rescue => e
p e.backtrace
end
end
end
break if not waiting
puts 'Waiting end of analyze'
sleep 1*60
end
results.each { |d, _| results[d].sort! { |a, b| score(a) <=> score(b) } }
puts 'Generate results'
File.write 'output/index.html', ERB.new(File.read('index.erb')).result(binding)