New output format
parent
ced73e10d2
commit
fd47d21390
|
@ -3,32 +3,14 @@ class CheckWorker
|
|||
sidekiq_options retry: false
|
||||
|
||||
def key_to_json(key)
|
||||
key.nil? ? nil : { type: key.type, size: key.size, rsa_size: key.rsa_equivalent_size }
|
||||
key.nil? ? nil : { type: key.type, size: key.size }
|
||||
end
|
||||
|
||||
def perform(host, port=nil)
|
||||
host = SimpleIDN.to_ascii host.downcase
|
||||
hosts = self.analyze *(port ? [host, port] : [host])
|
||||
hosts = hosts.collect do |host, result|
|
||||
name, ip, p = host
|
||||
host = { name: name, ip: ip, port: p }
|
||||
|
||||
if result.is_a? CryptCheck::AnalysisFailure
|
||||
next {
|
||||
host: host,
|
||||
error: result.to_s
|
||||
}
|
||||
end
|
||||
|
||||
grade = result
|
||||
server = grade.server
|
||||
{
|
||||
host: host,
|
||||
handshake: to_json(server),
|
||||
grade: grade_to_json(grade)
|
||||
}
|
||||
end
|
||||
result = { date: DateTime.now, hosts: hosts }
|
||||
host = SimpleIDN.to_ascii host.downcase
|
||||
result = self.analyze *(port ? [host, port] : [host])
|
||||
result = result.to_h
|
||||
result[:date] = DateTime.now
|
||||
Datastore.post self.type, host, port, result
|
||||
end
|
||||
|
||||
|
@ -46,17 +28,7 @@ class CheckWorker
|
|||
private
|
||||
def grade_to_json(grade)
|
||||
{
|
||||
rank: grade.grade,
|
||||
details: {
|
||||
score: grade.score,
|
||||
protocol: grade.protocol_score,
|
||||
key_exchange: grade.key_exchange_score,
|
||||
cipher_strengths: grade.cipher_strengths_score
|
||||
},
|
||||
error: grade.error,
|
||||
danger: grade.danger,
|
||||
warning: grade.warning,
|
||||
success: grade.success
|
||||
rank: grade.grade,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,16 +3,10 @@ class HTTPSWorker < CheckWorker
|
|||
|
||||
protected
|
||||
def analyze(host, port=443)
|
||||
CryptCheck::Tls::Https.analyze host, port
|
||||
CryptCheck::Tls::Https::Host.new host, port
|
||||
end
|
||||
|
||||
def type
|
||||
:https
|
||||
end
|
||||
|
||||
def to_json(server)
|
||||
result = super
|
||||
result[:hsts] = server.hsts
|
||||
result
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue