Browse Source

Order ciphers by strength

master
Aeris 4 years ago
parent
commit
b20c94ff2d
3 changed files with 10 additions and 12 deletions
  1. 2
    1
      app/helpers/check_helper.rb
  2. 4
    6
      app/views/check/show.html.erb
  3. 4
    5
      app/views/site/ciphers.html.erb

+ 2
- 1
app/helpers/check_helper.rb View File

@@ -90,7 +90,8 @@ module CheckHelper
end
end

def cipher_name_label(cipher, state)
def cipher_name_label(cipher)
state = cipher.state
color = case
when !state[:error].empty? then :error
when !state[:danger].empty? then :danger

+ 4
- 6
app/views/check/show.html.erb View File

@@ -86,17 +86,15 @@
</thead>
<tbody>
<% %w(TLSv1_2 TLSv1_1 TLSv1 SSLv3 SSLv2).each do |protocol|
ciphers = @result.ciphers.select { |c| c.protocol == protocol }
.sort { |a, b| -1 * (a['size'] <=> b['size']) }
ciphers = CryptCheck::Tls::Cipher.sort(@result.ciphers.select { |c| c.protocol == protocol }
.collect { |c| CryptCheck::Tls::Cipher.new protocol, [c.name, nil, c[:size]], c.dh })
unless ciphers.empty? %>
<tr>
<th colspan="3"><%= protocol_label protocol %></th>
</tr>
<% ciphers.each do |cipher|
cipher = CryptCheck::Tls::Cipher.new protocol, [cipher.name, nil, cipher[:size]], cipher.dh
%>
<% ciphers.each do |cipher| %>
<tr>
<th><%= cipher_name_label cipher, cipher.state %></th>
<th><%= cipher_name_label cipher %></th>
<td><%= cipher_size_label cipher %></td>
<td><%= key_label cipher.dh if cipher.dh %></td>
<td><%= cipher_labels cipher %></td>

+ 4
- 5
app/views/site/ciphers.html.erb View File

@@ -19,13 +19,12 @@
-->
<%
context.ciphers = 'ALL:COMPLEMENTOFALL'
context.ciphers.collect { |c| CryptCheck::Tls::Cipher.new protocol, c }
.sort { |a, b| -1 * (a.size <=> b.size)}.each do |cipher| %>
ciphers = context.ciphers.collect { |c| CryptCheck::Tls::Cipher.new protocol, c }
CryptCheck::Tls::Cipher.sort(ciphers).each do |cipher| %>
<tr>
<% state = cipher.state %>
<th><%= cipher_name_label cipher, state %></th>
<th><%= cipher_name_label cipher %></th>
<th><%= cipher_size_label cipher %></th>
<th><%= cipher_labels state %></th>
<th><%= cipher_labels cipher %></th>
</tr>
<% end %>
<% end %>

Loading…
Cancel
Save