Browse Source

Order ciphers by strength

Aeris 3 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
90 90
 		end
91 91
 	end
92 92
 
93
-	def cipher_name_label(cipher, state)
93
+	def cipher_name_label(cipher)
94
+		state = cipher.state
94 95
 		color = case
95 96
 					when !state[:error].empty? then :error
96 97
 					when !state[:danger].empty? then :danger

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

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

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

@@ -19,13 +19,12 @@
19 19
 				-->
20 20
 				<%
21 21
 				   context.ciphers = 'ALL:COMPLEMENTOFALL'
22
-				   context.ciphers.collect { |c| CryptCheck::Tls::Cipher.new protocol, c }
23
-						   .sort { |a, b| -1 * (a.size <=> b.size)}.each do |cipher| %>
22
+				   ciphers = context.ciphers.collect { |c| CryptCheck::Tls::Cipher.new protocol, c }
23
+				   CryptCheck::Tls::Cipher.sort(ciphers).each do |cipher| %>
24 24
 				<tr>
25
-					<% state = cipher.state %>
26
-					<th><%= cipher_name_label cipher, state %></th>
25
+					<th><%= cipher_name_label cipher %></th>
27 26
 					<th><%= cipher_size_label cipher %></th>
28
-					<th><%= cipher_labels state %></th>
27
+					<th><%= cipher_labels cipher %></th>
29 28
 				</tr>
30 29
 				   <% end %>
31 30
 			<% end %>

Loading…
Cancel
Save