From cbb455b4d3682ca1c2539760572940a991300b25 Mon Sep 17 00:00:00 2001 From: aeris Date: Sat, 11 Nov 2017 19:33:54 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20HTML=C2=A0pages=20for=20v2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/application.scss | 4 + app/helpers/check_helper.rb | 166 ++++++++++-------------- app/views/check/show.html.erb | 12 +- app/views/site/ciphers.html.erb | 14 +- app/views/site/suite.html.erb | 148 +++++++++++---------- 5 files changed, 158 insertions(+), 186 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a7ba12f..13d6e92 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -37,6 +37,10 @@ body { table.center td { text-align: center; + + &.left { + text-align: left; + } } td.error { diff --git a/app/helpers/check_helper.rb b/app/helpers/check_helper.rb index af4bb21..35cb1e5 100644 --- a/app/helpers/check_helper.rb +++ b/app/helpers/check_helper.rb @@ -36,18 +36,20 @@ module CheckHelper def rank_color(rank) case rank - when :'A+' then - :great - when :A then - :best - when :B then - :good - when :C, :D then - :warning - when :E, :F then - :error - else - :critical + when :'A+', :A + :great + when :'B+', :B + :best + when :'C+', :C + :good + when :D + nil + when :E + :warning + when :F + :error + else + :critical end end @@ -55,32 +57,6 @@ module CheckHelper label rank, rank_color(rank) 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) label protocol.to_sym, protocol.status end @@ -106,31 +82,31 @@ module CheckHelper def key_color(key) case key[:size] - when nil then - :default - when 0...1024 then - :error - when 1024...2048 then - :danger - when 2048...4096 then - :warning - else - :success + when nil then + :default + 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 nil then - :default - when 0...128 then - :error - when 112...128 then - :danger - when 128...256 then - :success - else - :primary + when nil then + :default + when 0...128 then + :error + when 112...128 then + :danger + when 128...256 then + :success + else + :primary end end @@ -147,14 +123,14 @@ module CheckHelper def cipher_kex_type_cell(kex) color = case kex - when :ecdh then - nil - when :dh then - :warning - when :rsa then - :error - else - :critical + when :ecdh then + nil + when :dh then + :warning + when :rsa then + :error + else + :critical end kex ||= 'None' cell kex.to_s.upcase, color @@ -167,10 +143,10 @@ module CheckHelper def cipher_auth_type_cell(auth) color = case auth - when :ecdsa, :rsa then - nil - else - :critical + when :ecdsa, :rsa then + nil + else + :critical end auth ||= 'None' cell auth.to_s.upcase, color @@ -183,10 +159,10 @@ module CheckHelper def cipher_enc_type_cell(enc) color = case enc - when :chacha20 - :success - when nil, :rc4 - :critical + when :chacha20 + :success + when nil, :rc4 + :critical end enc ||= 'NONE' cell enc.to_s.upcase, color @@ -194,44 +170,46 @@ module CheckHelper def cipher_enc_block_size_cell(enc) color = case - when enc.nil? - nil - when enc <= 64 - :critical - when enc < 128 - :error + when enc == :stream + nil + when enc.nil? + nil + when enc <= 64 + :critical + when enc < 128 + :error end cell enc, color end def cipher_enc_key_size_cell(enc) color = case - when enc.nil? - nil - when enc < 128 - :critical + when enc.nil? + nil + when enc < 128 + :critical end cell enc, color end def cipher_enc_mode_cell(enc) color = case enc - when :gcm, :ccm, :aead - :success + when :gcm, :ccm, :aead + :success end cell enc.to_s.upcase, color end def cipher_mac_type_cell(mac) color = case mac - when :poly1305 then - :success - when :sha384, :sha256 then - nil - when :sha1 then - :warning - else - :critical + when :poly1305 then + :success + when :sha384, :sha256 then + nil + when :sha1 then + :warning + else + :critical end cell mac.to_s.upcase, color end diff --git a/app/views/check/show.html.erb b/app/views/check/show.html.erb index 4c79122..8bb0c43 100644 --- a/app/views/check/show.html.erb +++ b/app/views/check/show.html.erb @@ -110,17 +110,13 @@ <%= t 'Name' %> - <%= t 'Key exchange' %> - <%= t 'Authentication' %> + <%= t 'Key exchange' %> + <%= t 'Authentication' %> <%= t 'Encryption' %> <%= t 'MAC' %> <%= t 'PFS' %> - <%= t 'Type' %> - <%= t 'Key size' %> - <%= t 'Type' %> - <%= t 'Key size' %> <%= t 'Type' %> <%= t 'Key size' %> <%= t 'Block size' %> @@ -150,11 +146,7 @@ <%= cipher_name_label cipher %> <%= cipher_kex_type_cell kex %> - - <%#= cipher_kex_size_cell kex&.last %> <%= cipher_auth_type_cell auth %> - - <%#= cipher_auth_size_cell auth&.last %> <%= cipher_enc_type_cell enc[0] %> <%= cipher_enc_key_size_cell enc[1] %> <%= cipher_enc_block_size_cell enc[2] %> diff --git a/app/views/site/ciphers.html.erb b/app/views/site/ciphers.html.erb index 7dd5d80..ec0e217 100644 --- a/app/views/site/ciphers.html.erb +++ b/app/views/site/ciphers.html.erb @@ -12,8 +12,8 @@ <%= t 'Type' %> - <%= t 'Block size' %> <%= t 'Key size' %> + <%= t 'Block size' %> <%= t 'Mode' %> <%= t 'Type' %> <%= t 'Size' %> @@ -31,12 +31,12 @@ <%= cipher_name_label cipher %> <%= cipher_auth_type_cell auth %> <%= cipher_kex_type_cell kex %> - <%= cipher_enc_type_cell enc&.first %> - <%= cipher_enc_block_size_cell enc&.[] 1 %> - <%= cipher_enc_key_size_cell enc&.[] 2 %> - <%= cipher_enc_mode_cell enc&.last %> - <%= cipher_mac_type_cell mac&.first %> - <%= cipher_mac_size_cell mac&.last %> + <%= cipher_enc_type_cell enc[0] %> + <%= cipher_enc_key_size_cell enc[1] %> + <%= cipher_enc_block_size_cell enc[2] %> + <%= cipher_enc_mode_cell enc[3] %> + <%= cipher_mac_type_cell mac[0] %> + <%= cipher_mac_size_cell mac[1] %> <%= cipher_pfs_cell pfs %> <% end %> diff --git a/app/views/site/suite.html.erb b/app/views/site/suite.html.erb index 0796c9d..0d30be0 100644 --- a/app/views/site/suite.html.erb +++ b/app/views/site/suite.html.erb @@ -5,56 +5,55 @@
- +
- - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + <% - iana_ciphers = Hash[@ciphers.collect { |c| [Rails.application.config.openssl_ciphers[c.name], c] }] - Rails.application.config.user_agents_ciphers.each do |ua, support| - cipher = (support['ciphers'].collect(&:first) & iana_ciphers.keys).first - if cipher - cipher = iana_ciphers[cipher] - params = cipher.params - kex = params[:kex] - auth = params[:auth] - enc = params[:enc] - mac = params[:mac] - pfs = params[:pfs] - end + iana_ciphers = Hash[@ciphers.collect { |c| [Rails.application.config.openssl_ciphers[c.name], c] }] + Rails.application.config.user_agents_ciphers.each do |ua, support| + cipher = (support['ciphers'].collect(&:first) & iana_ciphers.keys).first + if cipher + cipher = iana_ciphers[cipher] + kex = cipher.kex + auth = cipher.auth + enc = cipher.encryption + mac = cipher.hmac + pfs = cipher.pfs? + end %> <% if cipher %> - - <%= cipher_kex_type_cell kex&.first %> - <%= cipher_auth_type_cell auth&.first %> - <%= cipher_enc_type_cell enc&.first %> - <%= cipher_enc_key_size_cell enc&.[] 1 %> - <%= cipher_enc_block_size_cell enc&.[] 2 %> - <%= cipher_enc_mode_cell enc&.last %> - <%= cipher_mac_type_cell mac&.first %> - <%= cipher_mac_size_cell mac&.last %> - <%= cipher_pfs_cell pfs %> + + <%= cipher_auth_type_cell auth %> + <%= cipher_kex_type_cell kex %> + <%= cipher_enc_type_cell enc[0] %> + <%= cipher_enc_key_size_cell enc[1] %> + <%= cipher_enc_block_size_cell enc[2] %> + <%= cipher_enc_mode_cell enc[3] %> + <%= cipher_mac_type_cell mac[0] %> + <%= cipher_mac_size_cell mac[1] %> + <%= cipher_pfs_cell pfs %> <% else %> - + <% end %> <% end %> @@ -65,46 +64,45 @@
<%= t 'User agent' %><%= t 'Name' %><%= t 'Key exchange' %><%= t 'Authentication' %><%= t 'Encryption' %><%= t 'MAC' %><%= t 'PFS' %>
<%= t 'Type' %><%= t 'Key size' %><%= t 'Block size' %><%= t 'Mode' %><%= t 'Type' %><%= t 'Size' %>
<%= t 'User agent' %><%= t 'Name' %><%= t 'Key exchange' %><%= t 'Authentication' %><%= t 'Encryption' %><%= t 'MAC' %><%= t 'PFS' %>
<%= t 'Type' %><%= t 'Key size' %><%= t 'Block size' %><%= t 'Mode' %><%= t 'Type' %><%= t 'Size' %>
<%= ua %><%= cipher_name_label cipher %><%= cipher_name_label cipher %><%= label t('Not supported'), :error %><%= label t('Not supported'), :error, false %>
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - <% @ciphers.each do |cipher| - params = cipher.params - kex = params[:kex] - auth = params[:auth] - enc = params[:enc] - mac = params[:mac] - pfs = params[:pfs] - %> + <% @ciphers.each do |cipher| + kex = cipher.kex + auth = cipher.auth + enc = cipher.encryption + mac = cipher.hmac + pfs = cipher.pfs? + %> - <%= cipher_kex_type_cell kex&.first %> - <%= cipher_auth_type_cell auth&.first %> - <%= cipher_enc_type_cell enc&.first %> - <%= cipher_enc_key_size_cell enc&.[] 1 %> - <%= cipher_enc_block_size_cell enc&.[] 2 %> - <%= cipher_enc_mode_cell enc&.last %> - <%= cipher_mac_type_cell mac&.first %> - <%= cipher_mac_size_cell mac&.last %> + <%= cipher_auth_type_cell auth %> + <%= cipher_kex_type_cell kex %> + <%= cipher_enc_type_cell enc[0] %> + <%= cipher_enc_key_size_cell enc[1] %> + <%= cipher_enc_block_size_cell enc[2] %> + <%= cipher_enc_mode_cell enc[3] %> + <%= cipher_mac_type_cell mac[0] %> + <%= cipher_mac_size_cell mac[1] %> <%= cipher_pfs_cell pfs %> - <% end %> - + <% end %> +
<%= t 'Name' %><%= t 'Key exchange' %><%= t 'Authentication' %><%= t 'Encryption' %><%= t 'MAC' %><%= t 'PFS' %>
<%= t 'Type' %><%= t 'Key size' %><%= t 'Block size' %><%= t 'Mode' %><%= t 'Type' %><%= t 'Size' %>
<%= t 'Name' %><%= t 'Key exchange' %><%= t 'Authentication' %><%= t 'Encryption' %><%= t 'MAC' %><%= t 'PFS' %>
<%= t 'Type' %><%= t 'Key size' %><%= t 'Block size' %><%= t 'Mode' %><%= t 'Type' %><%= t 'Size' %>
<%= cipher_name_label cipher %>