Browse Source

Fix error when multiple server results

aeris 2 years ago
parent
commit
4d3e52a188
4 changed files with 21 additions and 4 deletions
  1. 17
    0
      lib/cryptcheck.rb
  2. 1
    1
      output/https.erb
  3. 2
    2
      output/smtp.erb
  4. 1
    1
      output/xmpp.erb

+ 17
- 0
lib/cryptcheck.rb View File

@@ -20,6 +20,21 @@ module CryptCheck
20 20
 		end
21 21
 	end
22 22
 
23
+	class NoTLSAvailableServer
24
+		attr_reader :server
25
+		def initialize(server)
26
+			@server = OpenStruct.new hostname: server
27
+		end
28
+
29
+		def grade
30
+			'X'
31
+		end
32
+
33
+		def score
34
+			0
35
+		end
36
+	end
37
+
23 38
 	autoload :Logger, 'cryptcheck/logger'
24 39
 	autoload :Tls, 'cryptcheck/tls'
25 40
 	module Tls
@@ -115,6 +130,8 @@ module CryptCheck
115 130
 		::Parallel.each hosts, progress: 'Analysing', in_threads: PARALLEL_ANALYSIS, finish: lambda { |item, _, _| puts item[1] } do |description, host|
116 131
 			#hosts.each do |description, host|
117 132
 			result = block.call host.strip
133
+			result = result.values.first
134
+			result = NoTLSAvailableServer.new(host) if result.is_a? AnalysisFailure
118 135
 			semaphore.synchronize do
119 136
 				if results.include? description
120 137
 					results[description] << result

+ 1
- 1
output/https.erb View File

@@ -79,7 +79,7 @@
79 79
 								<th id="<%= s.hostname %>">
80 80
 									<a href="#<%= s.hostname %>"><%= s.hostname %></a>
81 81
 								</th>
82
-								<% if s.is_a? Tls::TlsNotSupportedServer %>
82
+								<% if n.is_a? NoTLSAvailableServer %>
83 83
 								<td class="critical" colspan="16">
84 84
 									No SSL/TLS
85 85
 								</td>

+ 2
- 2
output/smtp.erb View File

@@ -72,10 +72,10 @@
72 72
 								<td class="info">PFS</td>
73 73
 							</tr>
74 74
 							<% r[1].each do |n|
75
-							   s = n.server
75
+								s = n.server
76 76
 							%>
77 77
 							<tr>
78
-								<% if s.is_a? Tls::TlsNotSupportedServer %>
78
+								<% if n.is_a? AnalysisFailure %>
79 79
 								<th id="<%= s.hostname %>">
80 80
 									<a href="#<%= s.hostname %>"><%= s.hostname %></a>
81 81
 								</th>

+ 1
- 1
output/xmpp.erb View File

@@ -79,7 +79,7 @@
79 79
 								<th id="<%= s.hostname %>">
80 80
 									<a href="#<%= s.hostname %>"><%= s.hostname %></a>
81 81
 								</th>
82
-								<% if s.is_a? Tls::TlsNotSupportedServer %>
82
+								<% if n.is_a? AnalysisFailure %>
83 83
 									<td class="critical" colspan="16">
84 84
 										No SSL/TLS
85 85
 									</td>

Loading…
Cancel
Save