|
|
@ -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 |
|
|
|