@@ -12,7 +12,7 @@ class Result
12
12
13
13
def initialize ( )
14
14
@cert = nil
15
- @ciphers = [ ]
15
+ @ciphers = Set . new
16
16
@supported_versions = [ :SSLv2 , :SSLv3 , :TLSv1 ]
17
17
end
18
18
@@ -53,7 +53,8 @@ def strong_ciphers
53
53
# @raise [ArgumentError] if the version supplied is invalid
54
54
# @return [Array] An array of accepted cipher details matching the supplied versions
55
55
def accepted ( version = :all )
56
- if version . kind_of? Symbol
56
+ case version
57
+ when Symbol
57
58
case version
58
59
when :all
59
60
return @ciphers . reject { |cipher | cipher [ :status ] == :rejected }
@@ -62,8 +63,8 @@ def accepted(version = :all)
62
63
else
63
64
raise ArgumentError , "Invalid SSL Version Supplied: #{ version } "
64
65
end
65
- elsif version . kind_of? Array
66
- version . reject! { |v | !( @supported_versions . include? v ) }
66
+ when Array
67
+ version = version . reject { |v | !( @supported_versions . include? v ) }
67
68
if version . empty?
68
69
return @ciphers . reject { |cipher | cipher [ :status ] == :rejected }
69
70
else
@@ -80,7 +81,8 @@ def accepted(version = :all)
80
81
# @raise [ArgumentError] if the version supplied is invalid
81
82
# @return [Array] An array of rejected cipher details matching the supplied versions
82
83
def rejected ( version = :all )
83
- if version . kind_of? Symbol
84
+ case version
85
+ when Symbol
84
86
case version
85
87
when :all
86
88
return @ciphers . reject { |cipher | cipher [ :status ] == :accepted }
@@ -89,8 +91,8 @@ def rejected(version = :all)
89
91
else
90
92
raise ArgumentError , "Invalid SSL Version Supplied: #{ version } "
91
93
end
92
- elsif version . kind_of? Array
93
- version . reject! { |v | !( @supported_versions . include? v ) }
94
+ when Array
95
+ version = version . reject { |v | !( @supported_versions . include? v ) }
94
96
if version . empty?
95
97
return @ciphers . reject { |cipher | cipher [ :status ] == :accepted }
96
98
else
@@ -173,7 +175,6 @@ def add_cipher(version, cipher, key_length, status)
173
175
174
176
cipher_details = { :version => version , :cipher => cipher , :key_length => key_length , :weak => weak , :status => status }
175
177
@ciphers << cipher_details
176
- @ciphers . uniq!
177
178
end
178
179
179
180
def to_s
0 commit comments