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
module State
def states
# Remove duplicated test for each level
@states ||= self.checks.group_by { |c| c[1] }.collect do |level, checks|
@states ||= State.empty.merge(self.checks.group_by { |c| c[1] }.collect do |level, checks|
states = checks.group_by(&:first).collect do |name, checks|
states = checks.collect &:last
# true > false > nil
@@ -16,7 +16,7 @@ module CryptCheck
[name, state]
end.to_h
[level, states]
end.to_h
end.to_h)
end

def status
@@ -27,6 +27,13 @@ module CryptCheck
GOODS = %i(good great best).freeze
LEVELS = (BADS + GOODS).freeze

def self.good?(level)
GOODS.include? level
end
def self.bad?(level)
BADS.include? level
end

extend Enumerable

def self.each(&block)
@@ -34,7 +41,7 @@ module CryptCheck
end

def self.empty
self.collect { |s| [s, []] }.to_h
self.collect { |s| [s, {}] }.to_h
end

def self.status(states)

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

@@ -5,6 +5,7 @@ module CryptCheck
@grade ||= calculate_grade
end

GRADES = %i(A+ A B+ B C+ C D E F G V T X)
GRADE_STATUS = {
V: :critical,
T: :critical,
@@ -14,7 +15,9 @@ module CryptCheck
E: :warning,
D: nil,
C: :good,
:'C+' => :good,
B: :great,
:'B+' => :great,
A: :best,
:'A+' => :best
}

Loading…
Cancel
Save