ソースを参照

Fix HTML pages for v2

new-scoring
aeris 1年前
コミット
cbb455b4d3

+ 4
- 0
app/assets/stylesheets/application.scss ファイルの表示

@@ -37,6 +37,10 @@ body {
37 37
 
38 38
 table.center td {
39 39
 	text-align: center;
40
+
41
+	&.left {
42
+		text-align: left;
43
+	}
40 44
 }
41 45
 
42 46
 td.error {

+ 72
- 94
app/helpers/check_helper.rb ファイルの表示

@@ -36,18 +36,20 @@ module CheckHelper
36 36
 
37 37
 	def rank_color(rank)
38 38
 		case rank
39
-			when :'A+' then
40
-				:great
41
-			when :A then
42
-				:best
43
-			when :B then
44
-				:good
45
-			when :C, :D then
46
-				:warning
47
-			when :E, :F then
48
-				:error
49
-			else
50
-				:critical
39
+		when :'A+', :A
40
+			:great
41
+		when :'B+', :B
42
+			:best
43
+		when :'C+', :C
44
+			:good
45
+		when :D
46
+			nil
47
+		when :E
48
+			:warning
49
+		when :F
50
+			:error
51
+		else
52
+			:critical
51 53
 		end
52 54
 	end
53 55
 
@@ -55,32 +57,6 @@ module CheckHelper
55 57
 		label rank, rank_color(rank)
56 58
 	end
57 59
 
58
-	def progress_color(percentage)
59
-		case percentage
60
-			when 0...20 then
61
-				:error
62
-			when 20...40 then
63
-				:danger
64
-			when 40...60 then
65
-				:warning
66
-			when 60...80 then
67
-				:default
68
-			when 80...90 then
69
-				:success
70
-			else
71
-				:primary
72
-		end
73
-	end
74
-
75
-	def score_progress(score)
76
-		%Q(<div class="progress">
77
-			 <div class="progress-bar progress-bar-striped progress-bar-#{progress_color score}"
78
-						style="width: #{score}%">
79
-				#{score} / 100
80
-			</div>
81
-		</div>).html_safe
82
-	end
83
-
84 60
 	def protocol_label(protocol)
85 61
 		label protocol.to_sym, protocol.status
86 62
 	end
@@ -106,31 +82,31 @@ module CheckHelper
106 82
 
107 83
 	def key_color(key)
108 84
 		case key[:size]
109
-			when nil then
110
-				:default
111
-			when 0...1024 then
112
-				:error
113
-			when 1024...2048 then
114
-				:danger
115
-			when 2048...4096 then
116
-				:warning
117
-			else
118
-				:success
85
+		when nil then
86
+			:default
87
+		when 0...1024 then
88
+			:error
89
+		when 1024...2048 then
90
+			:danger
91
+		when 2048...4096 then
92
+			:warning
93
+		else
94
+			:success
119 95
 		end
120 96
 	end
121 97
 
122 98
 	def cipher_color(key)
123 99
 		case key
124
-			when nil then
125
-				:default
126
-			when 0...128 then
127
-				:error
128
-			when 112...128 then
129
-				:danger
130
-			when 128...256 then
131
-				:success
132
-			else
133
-				:primary
100
+		when nil then
101
+			:default
102
+		when 0...128 then
103
+			:error
104
+		when 112...128 then
105
+			:danger
106
+		when 128...256 then
107
+			:success
108
+		else
109
+			:primary
134 110
 		end
135 111
 	end
136 112
 
@@ -147,14 +123,14 @@ module CheckHelper
147 123
 
148 124
 	def cipher_kex_type_cell(kex)
149 125
 		color = case kex
150
-					when :ecdh then
151
-						nil
152
-					when :dh then
153
-						:warning
154
-					when :rsa then
155
-						:error
156
-					else
157
-						:critical
126
+				when :ecdh then
127
+					nil
128
+				when :dh then
129
+					:warning
130
+				when :rsa then
131
+					:error
132
+				else
133
+					:critical
158 134
 				end
159 135
 		kex   ||= 'None'
160 136
 		cell kex.to_s.upcase, color
@@ -167,10 +143,10 @@ module CheckHelper
167 143
 
168 144
 	def cipher_auth_type_cell(auth)
169 145
 		color = case auth
170
-					when :ecdsa, :rsa then
171
-						nil
172
-					else
173
-						:critical
146
+				when :ecdsa, :rsa then
147
+					nil
148
+				else
149
+					:critical
174 150
 				end
175 151
 		auth  ||= 'None'
176 152
 		cell auth.to_s.upcase, color
@@ -183,10 +159,10 @@ module CheckHelper
183 159
 
184 160
 	def cipher_enc_type_cell(enc)
185 161
 		color = case enc
186
-					when :chacha20
187
-						:success
188
-					when nil, :rc4
189
-						:critical
162
+				when :chacha20
163
+					:success
164
+				when nil, :rc4
165
+					:critical
190 166
 				end
191 167
 		enc   ||= 'NONE'
192 168
 		cell enc.to_s.upcase, color
@@ -194,44 +170,46 @@ module CheckHelper
194 170
 
195 171
 	def cipher_enc_block_size_cell(enc)
196 172
 		color = case
197
-					when enc.nil?
198
-						nil
199
-					when enc <= 64
200
-						:critical
201
-					when enc < 128
202
-						:error
173
+				when enc == :stream
174
+					nil
175
+				when enc.nil?
176
+					nil
177
+				when enc <= 64
178
+					:critical
179
+				when enc < 128
180
+					:error
203 181
 				end
204 182
 		cell enc, color
205 183
 	end
206 184
 
207 185
 	def cipher_enc_key_size_cell(enc)
208 186
 		color = case
209
-					when enc.nil?
210
-						nil
211
-					when enc < 128
212
-						:critical
187
+				when enc.nil?
188
+					nil
189
+				when enc < 128
190
+					:critical
213 191
 				end
214 192
 		cell enc, color
215 193
 	end
216 194
 
217 195
 	def cipher_enc_mode_cell(enc)
218 196
 		color = case enc
219
-					when :gcm, :ccm, :aead
220
-						:success
197
+				when :gcm, :ccm, :aead
198
+					:success
221 199
 				end
222 200
 		cell enc.to_s.upcase, color
223 201
 	end
224 202
 
225 203
 	def cipher_mac_type_cell(mac)
226 204
 		color = case mac
227
-					when :poly1305 then
228
-						:success
229
-					when :sha384, :sha256 then
230
-						nil
231
-					when :sha1 then
232
-						:warning
233
-					else
234
-						:critical
205
+				when :poly1305 then
206
+					:success
207
+				when :sha384, :sha256 then
208
+					nil
209
+				when :sha1 then
210
+					:warning
211
+				else
212
+					:critical
235 213
 				end
236 214
 		cell mac.to_s.upcase, color
237 215
 	end

+ 2
- 10
app/views/check/show.html.erb ファイルの表示

@@ -110,17 +110,13 @@
110 110
 					<thead>
111 111
 					<tr>
112 112
 						<th rowspan="2"><%= t 'Name' %></th>
113
-						<th colspan="2"><%= t 'Key exchange' %></th>
114
-						<th colspan="2"><%= t 'Authentication' %></th>
113
+						<th rowspan="2"><%= t 'Key exchange' %></th>
114
+						<th rowspan="2"><%= t 'Authentication' %></th>
115 115
 						<th colspan="4"><%= t 'Encryption' %></th>
116 116
 						<th colspan="2"><%= t 'MAC' %></th>
117 117
 						<th rowspan="2"><%= t 'PFS' %></th>
118 118
 					</tr>
119 119
 					<tr>
120
-						<th><%= t 'Type' %></th>
121
-						<th><%= t 'Key size' %></th>
122
-						<th><%= t 'Type' %></th>
123
-						<th><%= t 'Key size' %></th>
124 120
 						<th><%= t 'Type' %></th>
125 121
 						<th><%= t 'Key size' %></th>
126 122
 						<th><%= t 'Block size' %></th>
@@ -150,11 +146,7 @@
150 146
 								<tr>
151 147
 									<th><%= cipher_name_label cipher %></th>
152 148
 									<%= cipher_kex_type_cell kex %>
153
-									<th/>
154
-									<%#= cipher_kex_size_cell kex&.last %>
155 149
 									<%= cipher_auth_type_cell auth %>
156
-									<th/>
157
-									<%#= cipher_auth_size_cell auth&.last %>
158 150
 									<%= cipher_enc_type_cell enc[0] %>
159 151
 									<%= cipher_enc_key_size_cell enc[1] %>
160 152
 									<%= cipher_enc_block_size_cell enc[2] %>

+ 7
- 7
app/views/site/ciphers.html.erb ファイルの表示

@@ -12,8 +12,8 @@
12 12
 				</tr>
13 13
 				<tr>
14 14
 					<th><%= t 'Type' %></th>
15
-					<th><%= t 'Block size' %></th>
16 15
 					<th><%= t 'Key size' %></th>
16
+					<th><%= t 'Block size' %></th>
17 17
 					<th><%= t 'Mode' %></th>
18 18
 					<th><%= t 'Type' %></th>
19 19
 					<th><%= t 'Size' %></th>
@@ -31,12 +31,12 @@
31 31
 					<th><%= cipher_name_label cipher %></th>
32 32
 					<%= cipher_auth_type_cell auth %>
33 33
 					<%= cipher_kex_type_cell kex %>
34
-					<%= cipher_enc_type_cell enc&.first %>
35
-					<%= cipher_enc_block_size_cell enc&.[] 1 %>
36
-					<%= cipher_enc_key_size_cell enc&.[] 2 %>
37
-					<%= cipher_enc_mode_cell enc&.last %>
38
-					<%= cipher_mac_type_cell mac&.first %>
39
-					<%= cipher_mac_size_cell mac&.last %>
34
+					<%= cipher_enc_type_cell enc[0] %>
35
+					<%= cipher_enc_key_size_cell enc[1] %>
36
+					<%= cipher_enc_block_size_cell enc[2] %>
37
+					<%= cipher_enc_mode_cell enc[3] %>
38
+					<%= cipher_mac_type_cell mac[0] %>
39
+					<%= cipher_mac_size_cell mac[1] %>
40 40
 					<%= cipher_pfs_cell pfs %>
41 41
 				</tr>
42 42
 				<% end %>

+ 73
- 75
app/views/site/suite.html.erb ファイルの表示

@@ -5,56 +5,55 @@
5 5
 		</div>
6 6
 	</div>
7 7
 	<div class="row">
8
-		<table class="table table-bordered table-condensed table-striped col-sm-12">
8
+		<table class="table table-bordered table-condensed table-striped center col-sm-12">
9 9
 			<thead>
10
-				<tr>
11
-					<th rowspan="2"><%= t 'User agent' %></th>
12
-					<th rowspan="2"><%= t 'Name' %></th>
13
-					<th rowspan="2"><%= t 'Key exchange' %></th>
14
-					<th rowspan="2"><%= t 'Authentication' %></th>
15
-					<th colspan="4"><%= t 'Encryption' %></th>
16
-					<th colspan="2"><%= t 'MAC' %></th>
17
-					<th rowspan="2"><%= t 'PFS' %></th>
18
-				</tr>
19
-				<tr>
20
-					<th><%= t 'Type' %></th>
21
-					<th><%= t 'Key size' %></th>
22
-					<th><%= t 'Block size' %></th>
23
-					<th><%= t 'Mode' %></th>
24
-					<th><%= t 'Type' %></th>
25
-					<th><%= t 'Size' %></th>
26
-				</tr>
10
+			<tr>
11
+				<th rowspan="2"><%= t 'User agent' %></th>
12
+				<th rowspan="2"><%= t 'Name' %></th>
13
+				<th rowspan="2"><%= t 'Key exchange' %></th>
14
+				<th rowspan="2"><%= t 'Authentication' %></th>
15
+				<th colspan="4"><%= t 'Encryption' %></th>
16
+				<th colspan="2"><%= t 'MAC' %></th>
17
+				<th rowspan="2"><%= t 'PFS' %></th>
18
+			</tr>
19
+			<tr>
20
+				<th><%= t 'Type' %></th>
21
+				<th><%= t 'Key size' %></th>
22
+				<th><%= t 'Block size' %></th>
23
+				<th><%= t 'Mode' %></th>
24
+				<th><%= t 'Type' %></th>
25
+				<th><%= t 'Size' %></th>
26
+			</tr>
27 27
 			</thead>
28 28
 			<tbody>
29 29
 			<%
30
-			   iana_ciphers = Hash[@ciphers.collect { |c| [Rails.application.config.openssl_ciphers[c.name], c] }]
31
-			   Rails.application.config.user_agents_ciphers.each do |ua, support|
32
-				   cipher = (support['ciphers'].collect(&:first) & iana_ciphers.keys).first
33
-				   if cipher
34
-					   cipher = iana_ciphers[cipher]
35
-					   params = cipher.params
36
-					   kex = params[:kex]
37
-					   auth = params[:auth]
38
-					   enc = params[:enc]
39
-					   mac = params[:mac]
40
-					   pfs = params[:pfs]
41
-				   end
30
+				iana_ciphers = Hash[@ciphers.collect { |c| [Rails.application.config.openssl_ciphers[c.name], c] }]
31
+				Rails.application.config.user_agents_ciphers.each do |ua, support|
32
+					cipher = (support['ciphers'].collect(&:first) & iana_ciphers.keys).first
33
+					if cipher
34
+						cipher = iana_ciphers[cipher]
35
+						kex    = cipher.kex
36
+						auth   = cipher.auth
37
+						enc    = cipher.encryption
38
+						mac    = cipher.hmac
39
+						pfs    = cipher.pfs?
40
+					end
42 41
 			%>
43 42
 				<tr>
44 43
 					<th><%= ua %></th>
45 44
 					<% if cipher %>
46
-					<th><%= cipher_name_label cipher %></th>
47
-					<%= cipher_kex_type_cell kex&.first %>
48
-					<%= cipher_auth_type_cell auth&.first %>
49
-					<%= cipher_enc_type_cell enc&.first %>
50
-					<%= cipher_enc_key_size_cell enc&.[] 1 %>
51
-					<%= cipher_enc_block_size_cell enc&.[] 2 %>
52
-					<%= cipher_enc_mode_cell enc&.last %>
53
-					<%= cipher_mac_type_cell mac&.first %>
54
-					<%= cipher_mac_size_cell mac&.last %>
55
-					<%= cipher_pfs_cell pfs %>
45
+						<th><%= cipher_name_label cipher %></th>
46
+						<%= cipher_auth_type_cell auth %>
47
+						<%= cipher_kex_type_cell kex %>
48
+						<%= cipher_enc_type_cell enc[0] %>
49
+						<%= cipher_enc_key_size_cell enc[1] %>
50
+						<%= cipher_enc_block_size_cell enc[2] %>
51
+						<%= cipher_enc_mode_cell enc[3] %>
52
+						<%= cipher_mac_type_cell mac[0] %>
53
+						<%= cipher_mac_size_cell mac[1] %>
54
+						<%= cipher_pfs_cell pfs %>
56 55
 					<% else %>
57
-					<td colspan="10"><%= label t('Not supported'), :error %></td>
56
+						<td colspan="10" class="left"><%= label t('Not supported'), :error, false %></td>
58 57
 					<% end %>
59 58
 				</tr>
60 59
 			<% end %>
@@ -65,46 +64,45 @@
65 64
 	<div class="row">
66 65
 		<table class="table table-bordered table-condensed table-striped center col-sm-12">
67 66
 			<thead>
68
-				<tr>
69
-					<th rowspan="2"><%= t 'Name' %></th>
70
-					<th rowspan="2"><%= t 'Key exchange' %></th>
71
-					<th rowspan="2"><%= t 'Authentication' %></th>
72
-					<th colspan="4"><%= t 'Encryption' %></th>
73
-					<th colspan="2"><%= t 'MAC' %></th>
74
-					<th rowspan="2"><%= t 'PFS' %></th>
75
-				</tr>
76
-				<tr>
77
-					<th><%= t 'Type' %></th>
78
-					<th><%= t 'Key size' %></th>
79
-					<th><%= t 'Block size' %></th>
80
-					<th><%= t 'Mode' %></th>
81
-					<th><%= t 'Type' %></th>
82
-					<th><%= t 'Size' %></th>
83
-				</tr>
67
+			<tr>
68
+				<th rowspan="2"><%= t 'Name' %></th>
69
+				<th rowspan="2"><%= t 'Key exchange' %></th>
70
+				<th rowspan="2"><%= t 'Authentication' %></th>
71
+				<th colspan="4"><%= t 'Encryption' %></th>
72
+				<th colspan="2"><%= t 'MAC' %></th>
73
+				<th rowspan="2"><%= t 'PFS' %></th>
74
+			</tr>
75
+			<tr>
76
+				<th><%= t 'Type' %></th>
77
+				<th><%= t 'Key size' %></th>
78
+				<th><%= t 'Block size' %></th>
79
+				<th><%= t 'Mode' %></th>
80
+				<th><%= t 'Type' %></th>
81
+				<th><%= t 'Size' %></th>
82
+			</tr>
84 83
 			</thead>
85 84
 			<tbody>
86
-				<% @ciphers.each do |cipher|
87
-					params = cipher.params
88
-					kex = params[:kex]
89
-					auth = params[:auth]
90
-					enc = params[:enc]
91
-					mac = params[:mac]
92
-					pfs = params[:pfs]
93
-				%>
85
+			<% @ciphers.each do |cipher|
86
+				kex  = cipher.kex
87
+				auth = cipher.auth
88
+				enc  = cipher.encryption
89
+				mac  = cipher.hmac
90
+				pfs  = cipher.pfs?
91
+			%>
94 92
 				<tr>
95 93
 					<th><%= cipher_name_label cipher %></th>
96
-					<%= cipher_kex_type_cell kex&.first %>
97
-					<%= cipher_auth_type_cell auth&.first %>
98
-					<%= cipher_enc_type_cell enc&.first %>
99
-					<%= cipher_enc_key_size_cell enc&.[] 1 %>
100
-					<%= cipher_enc_block_size_cell enc&.[] 2 %>
101
-					<%= cipher_enc_mode_cell enc&.last %>
102
-					<%= cipher_mac_type_cell mac&.first %>
103
-					<%= cipher_mac_size_cell mac&.last %>
94
+					<%= cipher_auth_type_cell auth %>
95
+					<%= cipher_kex_type_cell kex %>
96
+					<%= cipher_enc_type_cell enc[0] %>
97
+					<%= cipher_enc_key_size_cell enc[1] %>
98
+					<%= cipher_enc_block_size_cell enc[2] %>
99
+					<%= cipher_enc_mode_cell enc[3] %>
100
+					<%= cipher_mac_type_cell mac[0] %>
101
+					<%= cipher_mac_size_cell mac[1] %>
104 102
 					<%= cipher_pfs_cell pfs %>
105 103
 				</tr>
106
-				<% end %>
107
-				</tbody>
104
+			<% end %>
105
+			</tbody>
108 106
 		</table>
109 107
 	</div>
110 108
 </div>

読み込み中…
キャンセル
保存