Browse Source

Better grades

new-scoring
aeris 2 years ago
parent
commit
a592f480e9
2 changed files with 13 additions and 3 deletions
  1. 10
    3
      lib/cryptcheck/state.rb
  2. 3
    0
      lib/cryptcheck/tls/grade.rb

+ 10
- 3
lib/cryptcheck/state.rb View File

@@ -2,7 +2,7 @@ module CryptCheck
2 2
 	module State
3 3
 		def states
4 4
 			# Remove duplicated test for each level
5
-			@states ||= self.checks.group_by { |c| c[1] }.collect do |level, checks|
5
+			@states ||= State.empty.merge(self.checks.group_by { |c| c[1] }.collect do |level, checks|
6 6
 				states = checks.group_by(&:first).collect do |name, checks|
7 7
 					states = checks.collect &:last
8 8
 					# true > false > nil
@@ -16,7 +16,7 @@ module CryptCheck
16 16
 					[name, state]
17 17
 				end.to_h
18 18
 				[level, states]
19
-			end.to_h
19
+			end.to_h)
20 20
 		end
21 21
 
22 22
 		def status
@@ -27,6 +27,13 @@ module CryptCheck
27 27
 		GOODS  = %i(good great best).freeze
28 28
 		LEVELS = (BADS + GOODS).freeze
29 29
 
30
+		def self.good?(level)
31
+			GOODS.include? level
32
+		end
33
+		def self.bad?(level)
34
+			BADS.include? level
35
+		end
36
+
30 37
 		extend Enumerable
31 38
 
32 39
 		def self.each(&block)
@@ -34,7 +41,7 @@ module CryptCheck
34 41
 		end
35 42
 
36 43
 		def self.empty
37
-			self.collect { |s| [s, []] }.to_h
44
+			self.collect { |s| [s, {}] }.to_h
38 45
 		end
39 46
 
40 47
 		def self.status(states)

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

@@ -5,6 +5,7 @@ module CryptCheck
5 5
 				@grade ||= calculate_grade
6 6
 			end
7 7
 
8
+			GRADES = %i(A+ A B+ B C+ C D E F G V T X)
8 9
 			GRADE_STATUS = {
9 10
 					V: :critical,
10 11
 					T: :critical,
@@ -14,7 +15,9 @@ module CryptCheck
14 15
 					E: :warning,
15 16
 					D: nil,
16 17
 					C: :good,
18
+					:'C+' => :good,
17 19
 					B: :great,
20
+					:'B+' => :great,
18 21
 					A: :best,
19 22
 					:'A+' => :best
20 23
 			}

Loading…
Cancel
Save