Browse Source

Fix grade color

aeris 1 year ago
parent
commit
b6055e7d90
2 changed files with 20 additions and 3 deletions
  1. 17
    0
      lib/cryptcheck/tls/grade.rb
  2. 3
    3
      lib/cryptcheck/tls/host.rb

+ 17
- 0
lib/cryptcheck/tls/grade.rb View File

@@ -5,6 +5,23 @@ module CryptCheck
5 5
 				@grade ||= calculate_grade
6 6
 			end
7 7
 
8
+			GRADE_STATUS = {
9
+					V: :critical,
10
+					T: :critical,
11
+
12
+					G: :critical,
13
+					F: :error,
14
+					E: :warning,
15
+					D: nil,
16
+					C: :good,
17
+					B: :great,
18
+					A: :best,
19
+					:'A+' => :best
20
+			}
21
+			def grade_status
22
+				GRADE_STATUS.fetch self.grade, :unknown
23
+			end
24
+
8 25
 			private
9 26
 			def calculate_grade
10 27
 				return :V unless self.valid?

+ 3
- 3
lib/cryptcheck/tls/host.rb View File

@@ -37,7 +37,7 @@ module CryptCheck
37 37
 							server(*args)
38 38
 						end
39 39
 						Logger.info ''
40
-						Logger.info { "Grade : #{server.grade.to_s.colorize server.status}" }
40
+						Logger.info { "Grade : #{server.grade.to_s.colorize server.grade_status}" }
41 41
 						server
42 42
 					rescue Engine::TLSException, Engine::ConnectionError, Engine::Timeout => e
43 43
 						AnalysisFailure.new e
@@ -46,8 +46,8 @@ module CryptCheck
46 46
 					end
47 47
 					[[@hostname, ip, @port], result]
48 48
 				end.to_h
49
-			# rescue StandardError
50
-			# 	raise
49
+			rescue StandardError
50
+				raise
51 51
 			rescue => e
52 52
 				@error = e
53 53
 			end

Loading…
Cancel
Save