module SiteHelper def rank_color(rank) case rank when 'A+' then :primary when 'A' then :success when 'B' then :default when 'C', 'D' then :warning when 'E', 'F' then :danger else :error end end def rank_label(rank) "#{rank}".html_safe end def progress_color(percentage) case percentage when 0...20 then :error when 20...40 then :danger when 40...60 then :warning when 60...80 then :default when 80...90 then :success else :primary end end def score_progress(score) %Q(
#{score} / 100
).html_safe end def protocol_label(protocol) color = case protocol when 'TLSv1_2' then :success when 'SSLv3', 'SSLv2' then :danger else :default end "#{protocol}".html_safe end def protocol_labels(protocols) protocols.collect { |p| protocol_label p }.join("\n").html_safe end def key_label(key) return 'Aucune'.html_safe unless key "#{key.type.upcase} #{key[:size]} bits".html_safe end def key_labels(keys) return 'Aucune'.html_safe if keys.empty? keys.sort { |a, b| -1 * (a.rsa_size <=> b.rsa_size)} .collect { |k| key_label k }.join("\n").html_safe end def cipher_label(cipher) "\">#{cipher['size']} bits".html_safe end def color_key(key) case key.rsa_size when 0...1024 then :error when 1024...2048 then :danger when 2048...4096 then :warning else :success end end def cipher_color(key) case key when 0...112 then :error when 112...128 then :warning when 128...256 then :success else :primary end end def cipher_labels(cipher) { success: %i(pfs), warning: %i(des3 sha1), danger: %i(md5 psk srp anonymous null export des rc2 rc4) }.collect do |color, types| types.select { |t| CryptCheck::Tls::Cipher.send "#{t}?", cipher.name } .collect { |t| "#{t.upcase}" } end.flatten(1).join("\n").html_safe end end